diff --git a/build.gradle b/build.gradle old mode 100755 new mode 100644 index 23a29cef4ca..445bd979d12 --- a/build.gradle +++ b/build.gradle @@ -1,363 +1,16 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - maven { url 'https://jitpack.io' } - } - dependencies { - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3' - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2' - } -} -plugins { - id "org.sonarqube" version "2.6" -} - -group 'org.tron' -version '1.0.0' - -apply plugin: 'java' -apply plugin: 'com.google.protobuf' -apply plugin: 'application' -apply plugin: 'checkstyle' -apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: "jacoco" -apply plugin: 'maven-publish' - -jar.enabled = false -shadowJar.enabled = true - -sourceCompatibility = 1.8 -[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' -mainClassName = 'org.tron.program.FullNode' - -publishing { - publications { - mavenJava(MavenPublication) { - from components.java - artifact sourceJar - } - } - repositories { - mavenLocal() - } -} - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -repositories { - mavenLocal() - mavenCentral() - maven { url 'http://repo.spring.io/plugins-release' } - // maven { url 'https://maven.aliyun.com/nexus/content/repositories/central/' } - maven { url 'https://jitpack.io' } -} -def versions = [ - checkstyle: '8.7', -] - -jacoco { - toolVersion = "0.8.1" -} - - -configurations { - checkstyleConfig - -} - -configurations.getByName('checkstyleConfig') { - transitive = false -} - -static def isWindows() { - return org.gradle.internal.os.OperatingSystem.current().isWindows() -} - -if (isWindows()) { - ext { - leveldbGroup = "org.ethereum" - leveldbName = "leveldbjni-all" - leveldbVersion = "1.18.3" - } -} else { - ext { - leveldbGroup = "org.fusesource.leveldbjni" - leveldbName = "leveldbjni-all" - leveldbVersion = "1.8" - } -} - -task version(type: Exec) { - commandLine 'bash', '-c', './ver.sh' -} - -dependencies { - //local libraries - compile fileTree(dir: 'libs', include: '*.jar') - // end local libraries - testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile group: 'org.mockito', name: 'mockito-core', version: '2.13.0' - testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '1.0.0.1' - - testCompile group: 'org.testng', name: 'testng', version: '6.14.3' - - compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' - compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25' - compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - -// compile "org.projectlombok:lombok:1.16.18" - compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2' - - compile group: 'commons-codec', name: 'commons-codec', version: '1.11' - - compile "com.madgag.spongycastle:core:1.58.0.0" - compile "com.madgag.spongycastle:prov:1.58.0.0" - - compile group: 'com.google.guava', name: 'guava', version: '24.1-jre' - - compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0' - compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.4.0' - - compile "org.iq80.leveldb:leveldb:0.7" - - compile group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10' - - compile group: leveldbGroup, name: leveldbName, version: leveldbVersion - - compile "org.apache.commons:commons-collections4:4.0" - - compile group: 'com.typesafe', name: 'config', version: '1.3.2' - - compile "com.google.code.findbugs:jsr305:3.0.0" - - compile "com.cedarsoftware:java-util:1.8.0" - - compile "org.apache.commons:commons-lang3:3.4" - - compile group: 'org.springframework', name: 'spring-context', version: '4.2.0.RELEASE' - compile group: 'org.springframework', name: 'spring-tx', version: '4.2.0.RELEASE' - - compile group: 'com.beust', name: 'jcommander', version: '1.72' - - compile group: 'junit', name: 'junit', version: '4.12' - - compile group: 'net.jcip', name: 'jcip-annotations', version: '1.0' - - compile group: 'org.fusesource.jansi', name: 'jansi', version: '1.16' - compile group: 'com.alibaba', name: 'fastjson', version: '1.2.44' - - compile group: 'com.google.inject', name: 'guice', version: '4.1.0' - - compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5' - compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5' - compile group: 'org.apache.commons', name: 'commons-math', version: '2.2' - - compile group: 'joda-time', name: 'joda-time', version: '2.3' - - compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.1.2' - -// checkstyleConfig "com.puppycrawl.tools:checkstyle:${versions.checkstyle}" - // google grpc - compile group: 'io.grpc', name: 'grpc-netty', version: '1.14.0' - compile group: 'io.grpc', name: 'grpc-protobuf', version: '1.14.0' - compile group: 'io.grpc', name: 'grpc-stub', version: '1.14.0' - // end google grpc - - compile group: 'com.carrotsearch', name: 'java-sizeof', version: '0.0.5' - - compile 'org.aspectj:aspectjrt:1.8.13' - compile 'org.aspectj:aspectjweaver:1.8.13' - compile 'org.aspectj:aspectjtools:1.8.13' - compile 'com.googlecode.cqengine:cqengine:2.12.4' - compile group: 'com.google.api.grpc', name: 'googleapis-common-protos', version: '0.0.3' - - // http - compile 'org.eclipse.jetty:jetty-server:9.4.11.v20180605' - compile 'org.eclipse.jetty:jetty-servlet:9.4.11.v20180605' - compile 'com.alibaba:fastjson:1.2.47' - compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1' - // end http - - compile "io.vavr:vavr:0.9.2" - compile group: 'org.pf4j', name: 'pf4j', version: '2.5.0' - - compile group: 'org.zeromq', name: 'jeromq', version: '0.5.0' - compile 'com.github.tronprotocol:zksnark-java-sdk:master-SNAPSHOT' - compile 'com.github.tronprotocol:chainbase:dynamicStore-SNAPSHOT' -} - -check.dependsOn 'lint' - -//checkstyle { -// toolVersion = "${versions.checkstyle}" -// config = resources.text.fromArchiveEntry(configurations.checkstyleConfig, 'google_checks.xml') -// -//} -checkstyle { - toolVersion = "${versions.checkstyle}" - configFile = file("config/checkstyle/checkStyleAll.xml") -} - - -checkstyleMain { - source = 'src/main/java' -} - -task lint(type: Checkstyle) { - // Cleaning the old log because of the creation of the new ones (not sure if totaly needed) - delete fileTree(dir: "${project.rootDir}/app/build/reports") - source 'src' - include '**/*.java' - exclude 'main/gen/**' - exclude 'test/**' - // empty classpath - classpath = files() - //Failing the build - ignoreFailures = false -} - -tasks.matching { it instanceof Test }.all { - testLogging.events = ["failed", "passed", "skipped"] -} - -if (project.hasProperty("mainClass")) { - mainClassName = mainClass -} - -sourceSets { - main { - proto { - srcDir 'src/main/protos' - } - java { - srcDir 'src/main/gen' - srcDir 'src/main/java' - } - } - -} - -protobuf { - generatedFilesBaseDir = "$projectDir/src/" - protoc { - artifact = "com.google.protobuf:protoc:3.5.1-1" - } - - plugins { - grpc { - artifact = 'io.grpc:protoc-gen-grpc-java:1.9.0' - } - } - generateProtoTasks { - all().each { task -> - task.builtins { - java { outputSubDir = "gen" } - } - } - all()*.plugins { - grpc { - outputSubDir = "gen" - } - } - } -} - -run { - if (project.hasProperty('witness')) { - standardInput = System.in - args = ['--witness'] - } -} - -shadowJar { - baseName = 'java-tron' - classifier = null - version = null -} - -test { - testLogging { - exceptionFormat = 'full' - } - jacoco { - append = true - destinationFile = file("$buildDir/jacoco/jacocoTest.exec") - classDumpDir = file("$buildDir/jacoco/classpathdumps") - } - if (isWindows()) { - exclude '**/ShieldedTransferActuatorTest.class' - exclude '**/BackupDbUtilTest.class' - exclude '**/ManagerTest.class' - exclude 'org/tron/core/zksnark/**' - } -} - -task stest(type: Test) { - - useTestNG { - suites(file('src/test/resources/testng.xml')) - parallel 'tests' - threadCount 4 - - } - - testLogging { - exceptionFormat = 'full' - showStackTraces = "true" - } - - jacoco { - append = false - destinationFile = file("$buildDir/jacoco/jacocoTest.exec") - classDumpDir = file("$buildDir/jacoco/classpathdumps") - } -} - -task dailyBuild(type: Test) { - useTestNG { - suites(file('src/test/resources/daily-build.xml')) - parallel 'tests' - threadCount 1 - } -} - - -jacocoTestReport { - reports { - xml.enabled true - csv.enabled false - html.destination file("${buildDir}/jacocoHtml") - } - executionData = files('build/jacoco/jacocoTest.exec') -} - -def binaryRelease(taskName, jarName, mainClass) { - return tasks.create("${taskName}", Jar) { - baseName = jarName - version = null - from(sourceSets.main.output) { - include "/**" - } - - from { - configurations.compile.collect { - it.isDirectory() ? it : zipTree(it) - } - } - - manifest { - attributes "Main-Class": "${mainClass}" - } - } -} - -artifacts { - archives(binaryRelease('buildSolidityNodeJar', 'SolidityNode', 'org.tron.program.SolidityNode'), - binaryRelease('buildFullNodeJar', 'FullNode', 'org.tron.program.FullNode'), - binaryRelease('buildKeystoreFactoryJar', 'KeystoreFactory', 'org.tron.program.KeystoreFactory'), - binaryRelease('buildDBConvertJar', 'DBConvert', 'org.tron.program.DBConvert')) -} +plugins { + id 'java' +} + +group 'tronprotocol' +version '1.0-SNAPSHOT' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' +} diff --git a/chainbase/build.gradle b/chainbase/build.gradle new file mode 100644 index 00000000000..445bd979d12 --- /dev/null +++ b/chainbase/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java' +} + +group 'tronprotocol' +version '1.0-SNAPSHOT' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' +} diff --git a/.circleci/config.yml b/framework/.circleci/config.yml similarity index 100% rename from .circleci/config.yml rename to framework/.circleci/config.yml diff --git a/.codeclimate.yml b/framework/.codeclimate.yml similarity index 100% rename from .codeclimate.yml rename to framework/.codeclimate.yml diff --git a/.travis.yml b/framework/.travis.yml similarity index 100% rename from .travis.yml rename to framework/.travis.yml diff --git a/CONTRIBUTING.md b/framework/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to framework/CONTRIBUTING.md diff --git a/Dockerfile b/framework/Dockerfile similarity index 100% rename from Dockerfile rename to framework/Dockerfile diff --git a/DownloadLinks.sh b/framework/DownloadLinks.sh similarity index 100% rename from DownloadLinks.sh rename to framework/DownloadLinks.sh diff --git a/LICENSE b/framework/LICENSE similarity index 100% rename from LICENSE rename to framework/LICENSE diff --git a/README.md b/framework/README.md similarity index 100% rename from README.md rename to framework/README.md diff --git a/TRON_Protobuf_Protocol_document.md b/framework/TRON_Protobuf_Protocol_document.md similarity index 100% rename from TRON_Protobuf_Protocol_document.md rename to framework/TRON_Protobuf_Protocol_document.md diff --git a/framework/build.gradle b/framework/build.gradle new file mode 100644 index 00000000000..23a29cef4ca --- /dev/null +++ b/framework/build.gradle @@ -0,0 +1,363 @@ +buildscript { + repositories { + mavenCentral() + jcenter() + maven { url 'https://jitpack.io' } + } + dependencies { + classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3' + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2' + } +} +plugins { + id "org.sonarqube" version "2.6" +} + +group 'org.tron' +version '1.0.0' + +apply plugin: 'java' +apply plugin: 'com.google.protobuf' +apply plugin: 'application' +apply plugin: 'checkstyle' +apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: "jacoco" +apply plugin: 'maven-publish' + +jar.enabled = false +shadowJar.enabled = true + +sourceCompatibility = 1.8 +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' +mainClassName = 'org.tron.program.FullNode' + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourceJar + } + } + repositories { + mavenLocal() + } +} + +task sourceJar(type: Jar, dependsOn: classes) { + classifier 'sources' + from sourceSets.main.allSource +} + +repositories { + mavenLocal() + mavenCentral() + maven { url 'http://repo.spring.io/plugins-release' } + // maven { url 'https://maven.aliyun.com/nexus/content/repositories/central/' } + maven { url 'https://jitpack.io' } +} +def versions = [ + checkstyle: '8.7', +] + +jacoco { + toolVersion = "0.8.1" +} + + +configurations { + checkstyleConfig + +} + +configurations.getByName('checkstyleConfig') { + transitive = false +} + +static def isWindows() { + return org.gradle.internal.os.OperatingSystem.current().isWindows() +} + +if (isWindows()) { + ext { + leveldbGroup = "org.ethereum" + leveldbName = "leveldbjni-all" + leveldbVersion = "1.18.3" + } +} else { + ext { + leveldbGroup = "org.fusesource.leveldbjni" + leveldbName = "leveldbjni-all" + leveldbVersion = "1.8" + } +} + +task version(type: Exec) { + commandLine 'bash', '-c', './ver.sh' +} + +dependencies { + //local libraries + compile fileTree(dir: 'libs', include: '*.jar') + // end local libraries + testCompile group: 'junit', name: 'junit', version: '4.12' + testCompile group: 'org.mockito', name: 'mockito-core', version: '2.13.0' + testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '1.0.0.1' + + testCompile group: 'org.testng', name: 'testng', version: '6.14.3' + + compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' + compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25' + compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' + +// compile "org.projectlombok:lombok:1.16.18" + compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2' + + compile group: 'commons-codec', name: 'commons-codec', version: '1.11' + + compile "com.madgag.spongycastle:core:1.58.0.0" + compile "com.madgag.spongycastle:prov:1.58.0.0" + + compile group: 'com.google.guava', name: 'guava', version: '24.1-jre' + + compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0' + compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.4.0' + + compile "org.iq80.leveldb:leveldb:0.7" + + compile group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10' + + compile group: leveldbGroup, name: leveldbName, version: leveldbVersion + + compile "org.apache.commons:commons-collections4:4.0" + + compile group: 'com.typesafe', name: 'config', version: '1.3.2' + + compile "com.google.code.findbugs:jsr305:3.0.0" + + compile "com.cedarsoftware:java-util:1.8.0" + + compile "org.apache.commons:commons-lang3:3.4" + + compile group: 'org.springframework', name: 'spring-context', version: '4.2.0.RELEASE' + compile group: 'org.springframework', name: 'spring-tx', version: '4.2.0.RELEASE' + + compile group: 'com.beust', name: 'jcommander', version: '1.72' + + compile group: 'junit', name: 'junit', version: '4.12' + + compile group: 'net.jcip', name: 'jcip-annotations', version: '1.0' + + compile group: 'org.fusesource.jansi', name: 'jansi', version: '1.16' + compile group: 'com.alibaba', name: 'fastjson', version: '1.2.44' + + compile group: 'com.google.inject', name: 'guice', version: '4.1.0' + + compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5' + compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5' + compile group: 'org.apache.commons', name: 'commons-math', version: '2.2' + + compile group: 'joda-time', name: 'joda-time', version: '2.3' + + compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.1.2' + +// checkstyleConfig "com.puppycrawl.tools:checkstyle:${versions.checkstyle}" + // google grpc + compile group: 'io.grpc', name: 'grpc-netty', version: '1.14.0' + compile group: 'io.grpc', name: 'grpc-protobuf', version: '1.14.0' + compile group: 'io.grpc', name: 'grpc-stub', version: '1.14.0' + // end google grpc + + compile group: 'com.carrotsearch', name: 'java-sizeof', version: '0.0.5' + + compile 'org.aspectj:aspectjrt:1.8.13' + compile 'org.aspectj:aspectjweaver:1.8.13' + compile 'org.aspectj:aspectjtools:1.8.13' + compile 'com.googlecode.cqengine:cqengine:2.12.4' + compile group: 'com.google.api.grpc', name: 'googleapis-common-protos', version: '0.0.3' + + // http + compile 'org.eclipse.jetty:jetty-server:9.4.11.v20180605' + compile 'org.eclipse.jetty:jetty-servlet:9.4.11.v20180605' + compile 'com.alibaba:fastjson:1.2.47' + compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1' + // end http + + compile "io.vavr:vavr:0.9.2" + compile group: 'org.pf4j', name: 'pf4j', version: '2.5.0' + + compile group: 'org.zeromq', name: 'jeromq', version: '0.5.0' + compile 'com.github.tronprotocol:zksnark-java-sdk:master-SNAPSHOT' + compile 'com.github.tronprotocol:chainbase:dynamicStore-SNAPSHOT' +} + +check.dependsOn 'lint' + +//checkstyle { +// toolVersion = "${versions.checkstyle}" +// config = resources.text.fromArchiveEntry(configurations.checkstyleConfig, 'google_checks.xml') +// +//} +checkstyle { + toolVersion = "${versions.checkstyle}" + configFile = file("config/checkstyle/checkStyleAll.xml") +} + + +checkstyleMain { + source = 'src/main/java' +} + +task lint(type: Checkstyle) { + // Cleaning the old log because of the creation of the new ones (not sure if totaly needed) + delete fileTree(dir: "${project.rootDir}/app/build/reports") + source 'src' + include '**/*.java' + exclude 'main/gen/**' + exclude 'test/**' + // empty classpath + classpath = files() + //Failing the build + ignoreFailures = false +} + +tasks.matching { it instanceof Test }.all { + testLogging.events = ["failed", "passed", "skipped"] +} + +if (project.hasProperty("mainClass")) { + mainClassName = mainClass +} + +sourceSets { + main { + proto { + srcDir 'src/main/protos' + } + java { + srcDir 'src/main/gen' + srcDir 'src/main/java' + } + } + +} + +protobuf { + generatedFilesBaseDir = "$projectDir/src/" + protoc { + artifact = "com.google.protobuf:protoc:3.5.1-1" + } + + plugins { + grpc { + artifact = 'io.grpc:protoc-gen-grpc-java:1.9.0' + } + } + generateProtoTasks { + all().each { task -> + task.builtins { + java { outputSubDir = "gen" } + } + } + all()*.plugins { + grpc { + outputSubDir = "gen" + } + } + } +} + +run { + if (project.hasProperty('witness')) { + standardInput = System.in + args = ['--witness'] + } +} + +shadowJar { + baseName = 'java-tron' + classifier = null + version = null +} + +test { + testLogging { + exceptionFormat = 'full' + } + jacoco { + append = true + destinationFile = file("$buildDir/jacoco/jacocoTest.exec") + classDumpDir = file("$buildDir/jacoco/classpathdumps") + } + if (isWindows()) { + exclude '**/ShieldedTransferActuatorTest.class' + exclude '**/BackupDbUtilTest.class' + exclude '**/ManagerTest.class' + exclude 'org/tron/core/zksnark/**' + } +} + +task stest(type: Test) { + + useTestNG { + suites(file('src/test/resources/testng.xml')) + parallel 'tests' + threadCount 4 + + } + + testLogging { + exceptionFormat = 'full' + showStackTraces = "true" + } + + jacoco { + append = false + destinationFile = file("$buildDir/jacoco/jacocoTest.exec") + classDumpDir = file("$buildDir/jacoco/classpathdumps") + } +} + +task dailyBuild(type: Test) { + useTestNG { + suites(file('src/test/resources/daily-build.xml')) + parallel 'tests' + threadCount 1 + } +} + + +jacocoTestReport { + reports { + xml.enabled true + csv.enabled false + html.destination file("${buildDir}/jacocoHtml") + } + executionData = files('build/jacoco/jacocoTest.exec') +} + +def binaryRelease(taskName, jarName, mainClass) { + return tasks.create("${taskName}", Jar) { + baseName = jarName + version = null + from(sourceSets.main.output) { + include "/**" + } + + from { + configurations.compile.collect { + it.isDirectory() ? it : zipTree(it) + } + } + + manifest { + attributes "Main-Class": "${mainClass}" + } + } +} + +artifacts { + archives(binaryRelease('buildSolidityNodeJar', 'SolidityNode', 'org.tron.program.SolidityNode'), + binaryRelease('buildFullNodeJar', 'FullNode', 'org.tron.program.FullNode'), + binaryRelease('buildKeystoreFactoryJar', 'KeystoreFactory', 'org.tron.program.KeystoreFactory'), + binaryRelease('buildDBConvertJar', 'DBConvert', 'org.tron.program.DBConvert')) +} diff --git a/build.md b/framework/build.md similarity index 100% rename from build.md rename to framework/build.md diff --git a/config/checkstyle/checkStyle.xml b/framework/config/checkstyle/checkStyle.xml similarity index 100% rename from config/checkstyle/checkStyle.xml rename to framework/config/checkstyle/checkStyle.xml diff --git a/config/checkstyle/checkStyleAll.xml b/framework/config/checkstyle/checkStyleAll.xml similarity index 100% rename from config/checkstyle/checkStyleAll.xml rename to framework/config/checkstyle/checkStyleAll.xml diff --git a/deploy.sh b/framework/deploy.sh similarity index 100% rename from deploy.sh rename to framework/deploy.sh diff --git a/docker/Dockerfile b/framework/docker/Dockerfile similarity index 100% rename from docker/Dockerfile rename to framework/docker/Dockerfile diff --git a/docker/README.md b/framework/docker/README.md similarity index 100% rename from docker/README.md rename to framework/docker/README.md diff --git a/docs/images/architecture_diagram.png b/framework/docs/images/architecture_diagram.png similarity index 100% rename from docs/images/architecture_diagram.png rename to framework/docs/images/architecture_diagram.png diff --git a/docs/images/program_configure.png b/framework/docs/images/program_configure.png similarity index 100% rename from docs/images/program_configure.png rename to framework/docs/images/program_configure.png diff --git a/docs/images/set_witness_param.jpeg b/framework/docs/images/set_witness_param.jpeg similarity index 100% rename from docs/images/set_witness_param.jpeg rename to framework/docs/images/set_witness_param.jpeg diff --git a/gen.sh b/framework/gen.sh similarity index 100% rename from gen.sh rename to framework/gen.sh diff --git a/framework/gradle/wrapper/gradle-wrapper.jar b/framework/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..27768f1bbac Binary files /dev/null and b/framework/gradle/wrapper/gradle-wrapper.jar differ diff --git a/framework/gradle/wrapper/gradle-wrapper.properties b/framework/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..244f55d0b14 --- /dev/null +++ b/framework/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Feb 14 20:55:40 CET 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip diff --git a/framework/gradlew b/framework/gradlew new file mode 100755 index 00000000000..bda416feaa4 --- /dev/null +++ b/framework/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" --no-daemon diff --git a/framework/gradlew.bat b/framework/gradlew.bat new file mode 100644 index 00000000000..e95643d6a2c --- /dev/null +++ b/framework/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jitpack.yml b/framework/jitpack.yml similarity index 100% rename from jitpack.yml rename to framework/jitpack.yml diff --git a/local.properties b/framework/local.properties similarity index 100% rename from local.properties rename to framework/local.properties diff --git a/lombok.config b/framework/lombok.config similarity index 100% rename from lombok.config rename to framework/lombok.config diff --git a/prop.properties b/framework/prop.properties similarity index 100% rename from prop.properties rename to framework/prop.properties diff --git a/querySonar.sh b/framework/querySonar.sh similarity index 100% rename from querySonar.sh rename to framework/querySonar.sh diff --git a/quickstart.md b/framework/quickstart.md similarity index 100% rename from quickstart.md rename to framework/quickstart.md diff --git a/run.md b/framework/run.md similarity index 100% rename from run.md rename to framework/run.md diff --git a/framework/settings.gradle b/framework/settings.gradle new file mode 100644 index 00000000000..977dac6036e --- /dev/null +++ b/framework/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'java-tron' + diff --git a/sonar-project.properties b/framework/sonar-project.properties similarity index 100% rename from sonar-project.properties rename to framework/sonar-project.properties diff --git a/sprout-verifying.key b/framework/sprout-verifying.key similarity index 100% rename from sprout-verifying.key rename to framework/sprout-verifying.key diff --git a/src/lombok.config b/framework/src/lombok.config similarity index 100% rename from src/lombok.config rename to framework/src/lombok.config diff --git a/framework/src/main/gen/org/tron/api/GrpcAPI.java b/framework/src/main/gen/org/tron/api/GrpcAPI.java new file mode 100644 index 00000000000..49a8ace46ab --- /dev/null +++ b/framework/src/main/gen/org/tron/api/GrpcAPI.java @@ -0,0 +1,29214 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: api/api.proto + +package org.tron.api; + +public final class GrpcAPI { + private GrpcAPI() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface ReturnOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Return) + com.google.protobuf.MessageOrBuilder { + + /** + * bool result = 1; + */ + boolean getResult(); + + /** + * .protocol.Return.response_code code = 2; + */ + int getCodeValue(); + /** + * .protocol.Return.response_code code = 2; + */ + org.tron.api.GrpcAPI.Return.response_code getCode(); + + /** + * bytes message = 3; + */ + com.google.protobuf.ByteString getMessage(); + } + /** + * Protobuf type {@code protocol.Return} + */ + public static final class Return extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Return) + ReturnOrBuilder { + private static final long serialVersionUID = 0L; + // Use Return.newBuilder() to construct. + private Return(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Return() { + result_ = false; + code_ = 0; + message_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Return( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + result_ = input.readBool(); + break; + } + case 16: { + int rawValue = input.readEnum(); + + code_ = rawValue; + break; + } + case 26: { + + message_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_Return_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_Return_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.Return.class, org.tron.api.GrpcAPI.Return.Builder.class); + } + + /** + * Protobuf enum {@code protocol.Return.response_code} + */ + public enum response_code + implements com.google.protobuf.ProtocolMessageEnum { + /** + * SUCCESS = 0; + */ + SUCCESS(0), + /** + *
+       * error in signature
+       * 
+ * + * SIGERROR = 1; + */ + SIGERROR(1), + /** + * CONTRACT_VALIDATE_ERROR = 2; + */ + CONTRACT_VALIDATE_ERROR(2), + /** + * CONTRACT_EXE_ERROR = 3; + */ + CONTRACT_EXE_ERROR(3), + /** + * BANDWITH_ERROR = 4; + */ + BANDWITH_ERROR(4), + /** + * DUP_TRANSACTION_ERROR = 5; + */ + DUP_TRANSACTION_ERROR(5), + /** + * TAPOS_ERROR = 6; + */ + TAPOS_ERROR(6), + /** + * TOO_BIG_TRANSACTION_ERROR = 7; + */ + TOO_BIG_TRANSACTION_ERROR(7), + /** + * TRANSACTION_EXPIRATION_ERROR = 8; + */ + TRANSACTION_EXPIRATION_ERROR(8), + /** + * SERVER_BUSY = 9; + */ + SERVER_BUSY(9), + /** + * NO_CONNECTION = 10; + */ + NO_CONNECTION(10), + /** + * NOT_ENOUGH_EFFECTIVE_CONNECTION = 11; + */ + NOT_ENOUGH_EFFECTIVE_CONNECTION(11), + /** + * OTHER_ERROR = 20; + */ + OTHER_ERROR(20), + UNRECOGNIZED(-1), + ; + + /** + * SUCCESS = 0; + */ + public static final int SUCCESS_VALUE = 0; + /** + *
+       * error in signature
+       * 
+ * + * SIGERROR = 1; + */ + public static final int SIGERROR_VALUE = 1; + /** + * CONTRACT_VALIDATE_ERROR = 2; + */ + public static final int CONTRACT_VALIDATE_ERROR_VALUE = 2; + /** + * CONTRACT_EXE_ERROR = 3; + */ + public static final int CONTRACT_EXE_ERROR_VALUE = 3; + /** + * BANDWITH_ERROR = 4; + */ + public static final int BANDWITH_ERROR_VALUE = 4; + /** + * DUP_TRANSACTION_ERROR = 5; + */ + public static final int DUP_TRANSACTION_ERROR_VALUE = 5; + /** + * TAPOS_ERROR = 6; + */ + public static final int TAPOS_ERROR_VALUE = 6; + /** + * TOO_BIG_TRANSACTION_ERROR = 7; + */ + public static final int TOO_BIG_TRANSACTION_ERROR_VALUE = 7; + /** + * TRANSACTION_EXPIRATION_ERROR = 8; + */ + public static final int TRANSACTION_EXPIRATION_ERROR_VALUE = 8; + /** + * SERVER_BUSY = 9; + */ + public static final int SERVER_BUSY_VALUE = 9; + /** + * NO_CONNECTION = 10; + */ + public static final int NO_CONNECTION_VALUE = 10; + /** + * NOT_ENOUGH_EFFECTIVE_CONNECTION = 11; + */ + public static final int NOT_ENOUGH_EFFECTIVE_CONNECTION_VALUE = 11; + /** + * OTHER_ERROR = 20; + */ + public static final int OTHER_ERROR_VALUE = 20; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static response_code valueOf(int value) { + return forNumber(value); + } + + public static response_code forNumber(int value) { + switch (value) { + case 0: return SUCCESS; + case 1: return SIGERROR; + case 2: return CONTRACT_VALIDATE_ERROR; + case 3: return CONTRACT_EXE_ERROR; + case 4: return BANDWITH_ERROR; + case 5: return DUP_TRANSACTION_ERROR; + case 6: return TAPOS_ERROR; + case 7: return TOO_BIG_TRANSACTION_ERROR; + case 8: return TRANSACTION_EXPIRATION_ERROR; + case 9: return SERVER_BUSY; + case 10: return NO_CONNECTION; + case 11: return NOT_ENOUGH_EFFECTIVE_CONNECTION; + case 20: return OTHER_ERROR; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + response_code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public response_code findValueByNumber(int number) { + return response_code.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.api.GrpcAPI.Return.getDescriptor().getEnumTypes().get(0); + } + + private static final response_code[] VALUES = values(); + + public static response_code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private response_code(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Return.response_code) + } + + public static final int RESULT_FIELD_NUMBER = 1; + private boolean result_; + /** + * bool result = 1; + */ + public boolean getResult() { + return result_; + } + + public static final int CODE_FIELD_NUMBER = 2; + private int code_; + /** + * .protocol.Return.response_code code = 2; + */ + public int getCodeValue() { + return code_; + } + /** + * .protocol.Return.response_code code = 2; + */ + public org.tron.api.GrpcAPI.Return.response_code getCode() { + org.tron.api.GrpcAPI.Return.response_code result = org.tron.api.GrpcAPI.Return.response_code.valueOf(code_); + return result == null ? org.tron.api.GrpcAPI.Return.response_code.UNRECOGNIZED : result; + } + + public static final int MESSAGE_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString message_; + /** + * bytes message = 3; + */ + public com.google.protobuf.ByteString getMessage() { + return message_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (result_ != false) { + output.writeBool(1, result_); + } + if (code_ != org.tron.api.GrpcAPI.Return.response_code.SUCCESS.getNumber()) { + output.writeEnum(2, code_); + } + if (!message_.isEmpty()) { + output.writeBytes(3, message_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (result_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, result_); + } + if (code_ != org.tron.api.GrpcAPI.Return.response_code.SUCCESS.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, code_); + } + if (!message_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, message_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.Return)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.Return other = (org.tron.api.GrpcAPI.Return) obj; + + boolean result = true; + result = result && (getResult() + == other.getResult()); + result = result && code_ == other.code_; + result = result && getMessage() + .equals(other.getMessage()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getResult()); + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + code_; + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.Return parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Return parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Return parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Return parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Return parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Return parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Return parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Return parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Return parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Return parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Return parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Return parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.Return prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Return} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Return) + org.tron.api.GrpcAPI.ReturnOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_Return_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_Return_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.Return.class, org.tron.api.GrpcAPI.Return.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.Return.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + result_ = false; + + code_ = 0; + + message_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_Return_descriptor; + } + + public org.tron.api.GrpcAPI.Return getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.Return.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.Return build() { + org.tron.api.GrpcAPI.Return result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.Return buildPartial() { + org.tron.api.GrpcAPI.Return result = new org.tron.api.GrpcAPI.Return(this); + result.result_ = result_; + result.code_ = code_; + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.Return) { + return mergeFrom((org.tron.api.GrpcAPI.Return)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.Return other) { + if (other == org.tron.api.GrpcAPI.Return.getDefaultInstance()) return this; + if (other.getResult() != false) { + setResult(other.getResult()); + } + if (other.code_ != 0) { + setCodeValue(other.getCodeValue()); + } + if (other.getMessage() != com.google.protobuf.ByteString.EMPTY) { + setMessage(other.getMessage()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.Return parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.Return) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean result_ ; + /** + * bool result = 1; + */ + public boolean getResult() { + return result_; + } + /** + * bool result = 1; + */ + public Builder setResult(boolean value) { + + result_ = value; + onChanged(); + return this; + } + /** + * bool result = 1; + */ + public Builder clearResult() { + + result_ = false; + onChanged(); + return this; + } + + private int code_ = 0; + /** + * .protocol.Return.response_code code = 2; + */ + public int getCodeValue() { + return code_; + } + /** + * .protocol.Return.response_code code = 2; + */ + public Builder setCodeValue(int value) { + code_ = value; + onChanged(); + return this; + } + /** + * .protocol.Return.response_code code = 2; + */ + public org.tron.api.GrpcAPI.Return.response_code getCode() { + org.tron.api.GrpcAPI.Return.response_code result = org.tron.api.GrpcAPI.Return.response_code.valueOf(code_); + return result == null ? org.tron.api.GrpcAPI.Return.response_code.UNRECOGNIZED : result; + } + /** + * .protocol.Return.response_code code = 2; + */ + public Builder setCode(org.tron.api.GrpcAPI.Return.response_code value) { + if (value == null) { + throw new NullPointerException(); + } + + code_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Return.response_code code = 2; + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString message_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes message = 3; + */ + public com.google.protobuf.ByteString getMessage() { + return message_; + } + /** + * bytes message = 3; + */ + public Builder setMessage(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * bytes message = 3; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Return) + } + + // @@protoc_insertion_point(class_scope:protocol.Return) + private static final org.tron.api.GrpcAPI.Return DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.Return(); + } + + public static org.tron.api.GrpcAPI.Return getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Return parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Return(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.Return getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockReferenceOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockReference) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 block_num = 1; + */ + long getBlockNum(); + + /** + * bytes block_hash = 2; + */ + com.google.protobuf.ByteString getBlockHash(); + } + /** + * Protobuf type {@code protocol.BlockReference} + */ + public static final class BlockReference extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockReference) + BlockReferenceOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockReference.newBuilder() to construct. + private BlockReference(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockReference() { + blockNum_ = 0L; + blockHash_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockReference( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + blockNum_ = input.readInt64(); + break; + } + case 18: { + + blockHash_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockReference_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockReference_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockReference.class, org.tron.api.GrpcAPI.BlockReference.Builder.class); + } + + public static final int BLOCK_NUM_FIELD_NUMBER = 1; + private long blockNum_; + /** + * int64 block_num = 1; + */ + public long getBlockNum() { + return blockNum_; + } + + public static final int BLOCK_HASH_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString blockHash_; + /** + * bytes block_hash = 2; + */ + public com.google.protobuf.ByteString getBlockHash() { + return blockHash_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (blockNum_ != 0L) { + output.writeInt64(1, blockNum_); + } + if (!blockHash_.isEmpty()) { + output.writeBytes(2, blockHash_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (blockNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, blockNum_); + } + if (!blockHash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, blockHash_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.BlockReference)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.BlockReference other = (org.tron.api.GrpcAPI.BlockReference) obj; + + boolean result = true; + result = result && (getBlockNum() + == other.getBlockNum()); + result = result && getBlockHash() + .equals(other.getBlockHash()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BLOCK_NUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBlockNum()); + hash = (37 * hash) + BLOCK_HASH_FIELD_NUMBER; + hash = (53 * hash) + getBlockHash().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockReference parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockReference parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockReference parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.BlockReference prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockReference} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockReference) + org.tron.api.GrpcAPI.BlockReferenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockReference_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockReference_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockReference.class, org.tron.api.GrpcAPI.BlockReference.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.BlockReference.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + blockNum_ = 0L; + + blockHash_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockReference_descriptor; + } + + public org.tron.api.GrpcAPI.BlockReference getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.BlockReference.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.BlockReference build() { + org.tron.api.GrpcAPI.BlockReference result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.BlockReference buildPartial() { + org.tron.api.GrpcAPI.BlockReference result = new org.tron.api.GrpcAPI.BlockReference(this); + result.blockNum_ = blockNum_; + result.blockHash_ = blockHash_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.BlockReference) { + return mergeFrom((org.tron.api.GrpcAPI.BlockReference)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.BlockReference other) { + if (other == org.tron.api.GrpcAPI.BlockReference.getDefaultInstance()) return this; + if (other.getBlockNum() != 0L) { + setBlockNum(other.getBlockNum()); + } + if (other.getBlockHash() != com.google.protobuf.ByteString.EMPTY) { + setBlockHash(other.getBlockHash()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.BlockReference parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.BlockReference) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long blockNum_ ; + /** + * int64 block_num = 1; + */ + public long getBlockNum() { + return blockNum_; + } + /** + * int64 block_num = 1; + */ + public Builder setBlockNum(long value) { + + blockNum_ = value; + onChanged(); + return this; + } + /** + * int64 block_num = 1; + */ + public Builder clearBlockNum() { + + blockNum_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString blockHash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes block_hash = 2; + */ + public com.google.protobuf.ByteString getBlockHash() { + return blockHash_; + } + /** + * bytes block_hash = 2; + */ + public Builder setBlockHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + blockHash_ = value; + onChanged(); + return this; + } + /** + * bytes block_hash = 2; + */ + public Builder clearBlockHash() { + + blockHash_ = getDefaultInstance().getBlockHash(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockReference) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockReference) + private static final org.tron.api.GrpcAPI.BlockReference DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.BlockReference(); + } + + public static org.tron.api.GrpcAPI.BlockReference getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockReference parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockReference(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.BlockReference getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface WitnessListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.WitnessList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Witness witnesses = 1; + */ + java.util.List + getWitnessesList(); + /** + * repeated .protocol.Witness witnesses = 1; + */ + org.tron.protos.Protocol.Witness getWitnesses(int index); + /** + * repeated .protocol.Witness witnesses = 1; + */ + int getWitnessesCount(); + /** + * repeated .protocol.Witness witnesses = 1; + */ + java.util.List + getWitnessesOrBuilderList(); + /** + * repeated .protocol.Witness witnesses = 1; + */ + org.tron.protos.Protocol.WitnessOrBuilder getWitnessesOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.WitnessList} + */ + public static final class WitnessList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.WitnessList) + WitnessListOrBuilder { + private static final long serialVersionUID = 0L; + // Use WitnessList.newBuilder() to construct. + private WitnessList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private WitnessList() { + witnesses_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private WitnessList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + witnesses_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + witnesses_.add( + input.readMessage(org.tron.protos.Protocol.Witness.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + witnesses_ = java.util.Collections.unmodifiableList(witnesses_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_WitnessList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_WitnessList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.WitnessList.class, org.tron.api.GrpcAPI.WitnessList.Builder.class); + } + + public static final int WITNESSES_FIELD_NUMBER = 1; + private java.util.List witnesses_; + /** + * repeated .protocol.Witness witnesses = 1; + */ + public java.util.List getWitnessesList() { + return witnesses_; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public java.util.List + getWitnessesOrBuilderList() { + return witnesses_; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public int getWitnessesCount() { + return witnesses_.size(); + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public org.tron.protos.Protocol.Witness getWitnesses(int index) { + return witnesses_.get(index); + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public org.tron.protos.Protocol.WitnessOrBuilder getWitnessesOrBuilder( + int index) { + return witnesses_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < witnesses_.size(); i++) { + output.writeMessage(1, witnesses_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < witnesses_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, witnesses_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.WitnessList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.WitnessList other = (org.tron.api.GrpcAPI.WitnessList) obj; + + boolean result = true; + result = result && getWitnessesList() + .equals(other.getWitnessesList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getWitnessesCount() > 0) { + hash = (37 * hash) + WITNESSES_FIELD_NUMBER; + hash = (53 * hash) + getWitnessesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.WitnessList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.WitnessList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.WitnessList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.WitnessList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.WitnessList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.WitnessList) + org.tron.api.GrpcAPI.WitnessListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_WitnessList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_WitnessList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.WitnessList.class, org.tron.api.GrpcAPI.WitnessList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.WitnessList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getWitnessesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (witnessesBuilder_ == null) { + witnesses_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + witnessesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_WitnessList_descriptor; + } + + public org.tron.api.GrpcAPI.WitnessList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.WitnessList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.WitnessList build() { + org.tron.api.GrpcAPI.WitnessList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.WitnessList buildPartial() { + org.tron.api.GrpcAPI.WitnessList result = new org.tron.api.GrpcAPI.WitnessList(this); + int from_bitField0_ = bitField0_; + if (witnessesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + witnesses_ = java.util.Collections.unmodifiableList(witnesses_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.witnesses_ = witnesses_; + } else { + result.witnesses_ = witnessesBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.WitnessList) { + return mergeFrom((org.tron.api.GrpcAPI.WitnessList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.WitnessList other) { + if (other == org.tron.api.GrpcAPI.WitnessList.getDefaultInstance()) return this; + if (witnessesBuilder_ == null) { + if (!other.witnesses_.isEmpty()) { + if (witnesses_.isEmpty()) { + witnesses_ = other.witnesses_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureWitnessesIsMutable(); + witnesses_.addAll(other.witnesses_); + } + onChanged(); + } + } else { + if (!other.witnesses_.isEmpty()) { + if (witnessesBuilder_.isEmpty()) { + witnessesBuilder_.dispose(); + witnessesBuilder_ = null; + witnesses_ = other.witnesses_; + bitField0_ = (bitField0_ & ~0x00000001); + witnessesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getWitnessesFieldBuilder() : null; + } else { + witnessesBuilder_.addAllMessages(other.witnesses_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.WitnessList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.WitnessList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List witnesses_ = + java.util.Collections.emptyList(); + private void ensureWitnessesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + witnesses_ = new java.util.ArrayList(witnesses_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Witness, org.tron.protos.Protocol.Witness.Builder, org.tron.protos.Protocol.WitnessOrBuilder> witnessesBuilder_; + + /** + * repeated .protocol.Witness witnesses = 1; + */ + public java.util.List getWitnessesList() { + if (witnessesBuilder_ == null) { + return java.util.Collections.unmodifiableList(witnesses_); + } else { + return witnessesBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public int getWitnessesCount() { + if (witnessesBuilder_ == null) { + return witnesses_.size(); + } else { + return witnessesBuilder_.getCount(); + } + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public org.tron.protos.Protocol.Witness getWitnesses(int index) { + if (witnessesBuilder_ == null) { + return witnesses_.get(index); + } else { + return witnessesBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder setWitnesses( + int index, org.tron.protos.Protocol.Witness value) { + if (witnessesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWitnessesIsMutable(); + witnesses_.set(index, value); + onChanged(); + } else { + witnessesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder setWitnesses( + int index, org.tron.protos.Protocol.Witness.Builder builderForValue) { + if (witnessesBuilder_ == null) { + ensureWitnessesIsMutable(); + witnesses_.set(index, builderForValue.build()); + onChanged(); + } else { + witnessesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder addWitnesses(org.tron.protos.Protocol.Witness value) { + if (witnessesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWitnessesIsMutable(); + witnesses_.add(value); + onChanged(); + } else { + witnessesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder addWitnesses( + int index, org.tron.protos.Protocol.Witness value) { + if (witnessesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWitnessesIsMutable(); + witnesses_.add(index, value); + onChanged(); + } else { + witnessesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder addWitnesses( + org.tron.protos.Protocol.Witness.Builder builderForValue) { + if (witnessesBuilder_ == null) { + ensureWitnessesIsMutable(); + witnesses_.add(builderForValue.build()); + onChanged(); + } else { + witnessesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder addWitnesses( + int index, org.tron.protos.Protocol.Witness.Builder builderForValue) { + if (witnessesBuilder_ == null) { + ensureWitnessesIsMutable(); + witnesses_.add(index, builderForValue.build()); + onChanged(); + } else { + witnessesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder addAllWitnesses( + java.lang.Iterable values) { + if (witnessesBuilder_ == null) { + ensureWitnessesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, witnesses_); + onChanged(); + } else { + witnessesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder clearWitnesses() { + if (witnessesBuilder_ == null) { + witnesses_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + witnessesBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public Builder removeWitnesses(int index) { + if (witnessesBuilder_ == null) { + ensureWitnessesIsMutable(); + witnesses_.remove(index); + onChanged(); + } else { + witnessesBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public org.tron.protos.Protocol.Witness.Builder getWitnessesBuilder( + int index) { + return getWitnessesFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public org.tron.protos.Protocol.WitnessOrBuilder getWitnessesOrBuilder( + int index) { + if (witnessesBuilder_ == null) { + return witnesses_.get(index); } else { + return witnessesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public java.util.List + getWitnessesOrBuilderList() { + if (witnessesBuilder_ != null) { + return witnessesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(witnesses_); + } + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public org.tron.protos.Protocol.Witness.Builder addWitnessesBuilder() { + return getWitnessesFieldBuilder().addBuilder( + org.tron.protos.Protocol.Witness.getDefaultInstance()); + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public org.tron.protos.Protocol.Witness.Builder addWitnessesBuilder( + int index) { + return getWitnessesFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Witness.getDefaultInstance()); + } + /** + * repeated .protocol.Witness witnesses = 1; + */ + public java.util.List + getWitnessesBuilderList() { + return getWitnessesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Witness, org.tron.protos.Protocol.Witness.Builder, org.tron.protos.Protocol.WitnessOrBuilder> + getWitnessesFieldBuilder() { + if (witnessesBuilder_ == null) { + witnessesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Witness, org.tron.protos.Protocol.Witness.Builder, org.tron.protos.Protocol.WitnessOrBuilder>( + witnesses_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + witnesses_ = null; + } + return witnessesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.WitnessList) + } + + // @@protoc_insertion_point(class_scope:protocol.WitnessList) + private static final org.tron.api.GrpcAPI.WitnessList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.WitnessList(); + } + + public static org.tron.api.GrpcAPI.WitnessList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public WitnessList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new WitnessList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.WitnessList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ProposalListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ProposalList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Proposal proposals = 1; + */ + java.util.List + getProposalsList(); + /** + * repeated .protocol.Proposal proposals = 1; + */ + org.tron.protos.Protocol.Proposal getProposals(int index); + /** + * repeated .protocol.Proposal proposals = 1; + */ + int getProposalsCount(); + /** + * repeated .protocol.Proposal proposals = 1; + */ + java.util.List + getProposalsOrBuilderList(); + /** + * repeated .protocol.Proposal proposals = 1; + */ + org.tron.protos.Protocol.ProposalOrBuilder getProposalsOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.ProposalList} + */ + public static final class ProposalList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ProposalList) + ProposalListOrBuilder { + private static final long serialVersionUID = 0L; + // Use ProposalList.newBuilder() to construct. + private ProposalList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ProposalList() { + proposals_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ProposalList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + proposals_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + proposals_.add( + input.readMessage(org.tron.protos.Protocol.Proposal.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + proposals_ = java.util.Collections.unmodifiableList(proposals_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_ProposalList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_ProposalList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.ProposalList.class, org.tron.api.GrpcAPI.ProposalList.Builder.class); + } + + public static final int PROPOSALS_FIELD_NUMBER = 1; + private java.util.List proposals_; + /** + * repeated .protocol.Proposal proposals = 1; + */ + public java.util.List getProposalsList() { + return proposals_; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public java.util.List + getProposalsOrBuilderList() { + return proposals_; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public int getProposalsCount() { + return proposals_.size(); + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public org.tron.protos.Protocol.Proposal getProposals(int index) { + return proposals_.get(index); + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public org.tron.protos.Protocol.ProposalOrBuilder getProposalsOrBuilder( + int index) { + return proposals_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < proposals_.size(); i++) { + output.writeMessage(1, proposals_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < proposals_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, proposals_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.ProposalList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.ProposalList other = (org.tron.api.GrpcAPI.ProposalList) obj; + + boolean result = true; + result = result && getProposalsList() + .equals(other.getProposalsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getProposalsCount() > 0) { + hash = (37 * hash) + PROPOSALS_FIELD_NUMBER; + hash = (53 * hash) + getProposalsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ProposalList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.ProposalList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.ProposalList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.ProposalList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ProposalList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ProposalList) + org.tron.api.GrpcAPI.ProposalListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_ProposalList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_ProposalList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.ProposalList.class, org.tron.api.GrpcAPI.ProposalList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.ProposalList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getProposalsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (proposalsBuilder_ == null) { + proposals_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + proposalsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_ProposalList_descriptor; + } + + public org.tron.api.GrpcAPI.ProposalList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.ProposalList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.ProposalList build() { + org.tron.api.GrpcAPI.ProposalList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.ProposalList buildPartial() { + org.tron.api.GrpcAPI.ProposalList result = new org.tron.api.GrpcAPI.ProposalList(this); + int from_bitField0_ = bitField0_; + if (proposalsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + proposals_ = java.util.Collections.unmodifiableList(proposals_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.proposals_ = proposals_; + } else { + result.proposals_ = proposalsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.ProposalList) { + return mergeFrom((org.tron.api.GrpcAPI.ProposalList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.ProposalList other) { + if (other == org.tron.api.GrpcAPI.ProposalList.getDefaultInstance()) return this; + if (proposalsBuilder_ == null) { + if (!other.proposals_.isEmpty()) { + if (proposals_.isEmpty()) { + proposals_ = other.proposals_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureProposalsIsMutable(); + proposals_.addAll(other.proposals_); + } + onChanged(); + } + } else { + if (!other.proposals_.isEmpty()) { + if (proposalsBuilder_.isEmpty()) { + proposalsBuilder_.dispose(); + proposalsBuilder_ = null; + proposals_ = other.proposals_; + bitField0_ = (bitField0_ & ~0x00000001); + proposalsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getProposalsFieldBuilder() : null; + } else { + proposalsBuilder_.addAllMessages(other.proposals_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.ProposalList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.ProposalList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List proposals_ = + java.util.Collections.emptyList(); + private void ensureProposalsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + proposals_ = new java.util.ArrayList(proposals_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Proposal, org.tron.protos.Protocol.Proposal.Builder, org.tron.protos.Protocol.ProposalOrBuilder> proposalsBuilder_; + + /** + * repeated .protocol.Proposal proposals = 1; + */ + public java.util.List getProposalsList() { + if (proposalsBuilder_ == null) { + return java.util.Collections.unmodifiableList(proposals_); + } else { + return proposalsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public int getProposalsCount() { + if (proposalsBuilder_ == null) { + return proposals_.size(); + } else { + return proposalsBuilder_.getCount(); + } + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public org.tron.protos.Protocol.Proposal getProposals(int index) { + if (proposalsBuilder_ == null) { + return proposals_.get(index); + } else { + return proposalsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder setProposals( + int index, org.tron.protos.Protocol.Proposal value) { + if (proposalsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProposalsIsMutable(); + proposals_.set(index, value); + onChanged(); + } else { + proposalsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder setProposals( + int index, org.tron.protos.Protocol.Proposal.Builder builderForValue) { + if (proposalsBuilder_ == null) { + ensureProposalsIsMutable(); + proposals_.set(index, builderForValue.build()); + onChanged(); + } else { + proposalsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder addProposals(org.tron.protos.Protocol.Proposal value) { + if (proposalsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProposalsIsMutable(); + proposals_.add(value); + onChanged(); + } else { + proposalsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder addProposals( + int index, org.tron.protos.Protocol.Proposal value) { + if (proposalsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProposalsIsMutable(); + proposals_.add(index, value); + onChanged(); + } else { + proposalsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder addProposals( + org.tron.protos.Protocol.Proposal.Builder builderForValue) { + if (proposalsBuilder_ == null) { + ensureProposalsIsMutable(); + proposals_.add(builderForValue.build()); + onChanged(); + } else { + proposalsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder addProposals( + int index, org.tron.protos.Protocol.Proposal.Builder builderForValue) { + if (proposalsBuilder_ == null) { + ensureProposalsIsMutable(); + proposals_.add(index, builderForValue.build()); + onChanged(); + } else { + proposalsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder addAllProposals( + java.lang.Iterable values) { + if (proposalsBuilder_ == null) { + ensureProposalsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, proposals_); + onChanged(); + } else { + proposalsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder clearProposals() { + if (proposalsBuilder_ == null) { + proposals_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + proposalsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public Builder removeProposals(int index) { + if (proposalsBuilder_ == null) { + ensureProposalsIsMutable(); + proposals_.remove(index); + onChanged(); + } else { + proposalsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public org.tron.protos.Protocol.Proposal.Builder getProposalsBuilder( + int index) { + return getProposalsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public org.tron.protos.Protocol.ProposalOrBuilder getProposalsOrBuilder( + int index) { + if (proposalsBuilder_ == null) { + return proposals_.get(index); } else { + return proposalsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public java.util.List + getProposalsOrBuilderList() { + if (proposalsBuilder_ != null) { + return proposalsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(proposals_); + } + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public org.tron.protos.Protocol.Proposal.Builder addProposalsBuilder() { + return getProposalsFieldBuilder().addBuilder( + org.tron.protos.Protocol.Proposal.getDefaultInstance()); + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public org.tron.protos.Protocol.Proposal.Builder addProposalsBuilder( + int index) { + return getProposalsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Proposal.getDefaultInstance()); + } + /** + * repeated .protocol.Proposal proposals = 1; + */ + public java.util.List + getProposalsBuilderList() { + return getProposalsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Proposal, org.tron.protos.Protocol.Proposal.Builder, org.tron.protos.Protocol.ProposalOrBuilder> + getProposalsFieldBuilder() { + if (proposalsBuilder_ == null) { + proposalsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Proposal, org.tron.protos.Protocol.Proposal.Builder, org.tron.protos.Protocol.ProposalOrBuilder>( + proposals_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + proposals_ = null; + } + return proposalsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ProposalList) + } + + // @@protoc_insertion_point(class_scope:protocol.ProposalList) + private static final org.tron.api.GrpcAPI.ProposalList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.ProposalList(); + } + + public static org.tron.api.GrpcAPI.ProposalList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ProposalList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ProposalList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.ProposalList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ExchangeListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ExchangeList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Exchange exchanges = 1; + */ + java.util.List + getExchangesList(); + /** + * repeated .protocol.Exchange exchanges = 1; + */ + org.tron.protos.Protocol.Exchange getExchanges(int index); + /** + * repeated .protocol.Exchange exchanges = 1; + */ + int getExchangesCount(); + /** + * repeated .protocol.Exchange exchanges = 1; + */ + java.util.List + getExchangesOrBuilderList(); + /** + * repeated .protocol.Exchange exchanges = 1; + */ + org.tron.protos.Protocol.ExchangeOrBuilder getExchangesOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.ExchangeList} + */ + public static final class ExchangeList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ExchangeList) + ExchangeListOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExchangeList.newBuilder() to construct. + private ExchangeList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExchangeList() { + exchanges_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExchangeList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + exchanges_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + exchanges_.add( + input.readMessage(org.tron.protos.Protocol.Exchange.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + exchanges_ = java.util.Collections.unmodifiableList(exchanges_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_ExchangeList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_ExchangeList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.ExchangeList.class, org.tron.api.GrpcAPI.ExchangeList.Builder.class); + } + + public static final int EXCHANGES_FIELD_NUMBER = 1; + private java.util.List exchanges_; + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public java.util.List getExchangesList() { + return exchanges_; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public java.util.List + getExchangesOrBuilderList() { + return exchanges_; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public int getExchangesCount() { + return exchanges_.size(); + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public org.tron.protos.Protocol.Exchange getExchanges(int index) { + return exchanges_.get(index); + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public org.tron.protos.Protocol.ExchangeOrBuilder getExchangesOrBuilder( + int index) { + return exchanges_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < exchanges_.size(); i++) { + output.writeMessage(1, exchanges_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < exchanges_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, exchanges_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.ExchangeList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.ExchangeList other = (org.tron.api.GrpcAPI.ExchangeList) obj; + + boolean result = true; + result = result && getExchangesList() + .equals(other.getExchangesList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getExchangesCount() > 0) { + hash = (37 * hash) + EXCHANGES_FIELD_NUMBER; + hash = (53 * hash) + getExchangesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ExchangeList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.ExchangeList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.ExchangeList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.ExchangeList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ExchangeList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ExchangeList) + org.tron.api.GrpcAPI.ExchangeListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_ExchangeList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_ExchangeList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.ExchangeList.class, org.tron.api.GrpcAPI.ExchangeList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.ExchangeList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getExchangesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (exchangesBuilder_ == null) { + exchanges_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + exchangesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_ExchangeList_descriptor; + } + + public org.tron.api.GrpcAPI.ExchangeList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.ExchangeList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.ExchangeList build() { + org.tron.api.GrpcAPI.ExchangeList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.ExchangeList buildPartial() { + org.tron.api.GrpcAPI.ExchangeList result = new org.tron.api.GrpcAPI.ExchangeList(this); + int from_bitField0_ = bitField0_; + if (exchangesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + exchanges_ = java.util.Collections.unmodifiableList(exchanges_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.exchanges_ = exchanges_; + } else { + result.exchanges_ = exchangesBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.ExchangeList) { + return mergeFrom((org.tron.api.GrpcAPI.ExchangeList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.ExchangeList other) { + if (other == org.tron.api.GrpcAPI.ExchangeList.getDefaultInstance()) return this; + if (exchangesBuilder_ == null) { + if (!other.exchanges_.isEmpty()) { + if (exchanges_.isEmpty()) { + exchanges_ = other.exchanges_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureExchangesIsMutable(); + exchanges_.addAll(other.exchanges_); + } + onChanged(); + } + } else { + if (!other.exchanges_.isEmpty()) { + if (exchangesBuilder_.isEmpty()) { + exchangesBuilder_.dispose(); + exchangesBuilder_ = null; + exchanges_ = other.exchanges_; + bitField0_ = (bitField0_ & ~0x00000001); + exchangesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getExchangesFieldBuilder() : null; + } else { + exchangesBuilder_.addAllMessages(other.exchanges_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.ExchangeList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.ExchangeList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List exchanges_ = + java.util.Collections.emptyList(); + private void ensureExchangesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + exchanges_ = new java.util.ArrayList(exchanges_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Exchange, org.tron.protos.Protocol.Exchange.Builder, org.tron.protos.Protocol.ExchangeOrBuilder> exchangesBuilder_; + + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public java.util.List getExchangesList() { + if (exchangesBuilder_ == null) { + return java.util.Collections.unmodifiableList(exchanges_); + } else { + return exchangesBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public int getExchangesCount() { + if (exchangesBuilder_ == null) { + return exchanges_.size(); + } else { + return exchangesBuilder_.getCount(); + } + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public org.tron.protos.Protocol.Exchange getExchanges(int index) { + if (exchangesBuilder_ == null) { + return exchanges_.get(index); + } else { + return exchangesBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder setExchanges( + int index, org.tron.protos.Protocol.Exchange value) { + if (exchangesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureExchangesIsMutable(); + exchanges_.set(index, value); + onChanged(); + } else { + exchangesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder setExchanges( + int index, org.tron.protos.Protocol.Exchange.Builder builderForValue) { + if (exchangesBuilder_ == null) { + ensureExchangesIsMutable(); + exchanges_.set(index, builderForValue.build()); + onChanged(); + } else { + exchangesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder addExchanges(org.tron.protos.Protocol.Exchange value) { + if (exchangesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureExchangesIsMutable(); + exchanges_.add(value); + onChanged(); + } else { + exchangesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder addExchanges( + int index, org.tron.protos.Protocol.Exchange value) { + if (exchangesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureExchangesIsMutable(); + exchanges_.add(index, value); + onChanged(); + } else { + exchangesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder addExchanges( + org.tron.protos.Protocol.Exchange.Builder builderForValue) { + if (exchangesBuilder_ == null) { + ensureExchangesIsMutable(); + exchanges_.add(builderForValue.build()); + onChanged(); + } else { + exchangesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder addExchanges( + int index, org.tron.protos.Protocol.Exchange.Builder builderForValue) { + if (exchangesBuilder_ == null) { + ensureExchangesIsMutable(); + exchanges_.add(index, builderForValue.build()); + onChanged(); + } else { + exchangesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder addAllExchanges( + java.lang.Iterable values) { + if (exchangesBuilder_ == null) { + ensureExchangesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, exchanges_); + onChanged(); + } else { + exchangesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder clearExchanges() { + if (exchangesBuilder_ == null) { + exchanges_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + exchangesBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public Builder removeExchanges(int index) { + if (exchangesBuilder_ == null) { + ensureExchangesIsMutable(); + exchanges_.remove(index); + onChanged(); + } else { + exchangesBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public org.tron.protos.Protocol.Exchange.Builder getExchangesBuilder( + int index) { + return getExchangesFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public org.tron.protos.Protocol.ExchangeOrBuilder getExchangesOrBuilder( + int index) { + if (exchangesBuilder_ == null) { + return exchanges_.get(index); } else { + return exchangesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public java.util.List + getExchangesOrBuilderList() { + if (exchangesBuilder_ != null) { + return exchangesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(exchanges_); + } + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public org.tron.protos.Protocol.Exchange.Builder addExchangesBuilder() { + return getExchangesFieldBuilder().addBuilder( + org.tron.protos.Protocol.Exchange.getDefaultInstance()); + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public org.tron.protos.Protocol.Exchange.Builder addExchangesBuilder( + int index) { + return getExchangesFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Exchange.getDefaultInstance()); + } + /** + * repeated .protocol.Exchange exchanges = 1; + */ + public java.util.List + getExchangesBuilderList() { + return getExchangesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Exchange, org.tron.protos.Protocol.Exchange.Builder, org.tron.protos.Protocol.ExchangeOrBuilder> + getExchangesFieldBuilder() { + if (exchangesBuilder_ == null) { + exchangesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Exchange, org.tron.protos.Protocol.Exchange.Builder, org.tron.protos.Protocol.ExchangeOrBuilder>( + exchanges_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + exchanges_ = null; + } + return exchangesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ExchangeList) + } + + // @@protoc_insertion_point(class_scope:protocol.ExchangeList) + private static final org.tron.api.GrpcAPI.ExchangeList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.ExchangeList(); + } + + public static org.tron.api.GrpcAPI.ExchangeList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExchangeList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExchangeList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.ExchangeList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AssetIssueListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AssetIssueList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + java.util.List + getAssetIssueList(); + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + org.tron.protos.Contract.AssetIssueContract getAssetIssue(int index); + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + int getAssetIssueCount(); + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + java.util.List + getAssetIssueOrBuilderList(); + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + org.tron.protos.Contract.AssetIssueContractOrBuilder getAssetIssueOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.AssetIssueList} + */ + public static final class AssetIssueList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AssetIssueList) + AssetIssueListOrBuilder { + private static final long serialVersionUID = 0L; + // Use AssetIssueList.newBuilder() to construct. + private AssetIssueList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AssetIssueList() { + assetIssue_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AssetIssueList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + assetIssue_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + assetIssue_.add( + input.readMessage(org.tron.protos.Contract.AssetIssueContract.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + assetIssue_ = java.util.Collections.unmodifiableList(assetIssue_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AssetIssueList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AssetIssueList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AssetIssueList.class, org.tron.api.GrpcAPI.AssetIssueList.Builder.class); + } + + public static final int ASSETISSUE_FIELD_NUMBER = 1; + private java.util.List assetIssue_; + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public java.util.List getAssetIssueList() { + return assetIssue_; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public java.util.List + getAssetIssueOrBuilderList() { + return assetIssue_; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public int getAssetIssueCount() { + return assetIssue_.size(); + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public org.tron.protos.Contract.AssetIssueContract getAssetIssue(int index) { + return assetIssue_.get(index); + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public org.tron.protos.Contract.AssetIssueContractOrBuilder getAssetIssueOrBuilder( + int index) { + return assetIssue_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < assetIssue_.size(); i++) { + output.writeMessage(1, assetIssue_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < assetIssue_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, assetIssue_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.AssetIssueList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.AssetIssueList other = (org.tron.api.GrpcAPI.AssetIssueList) obj; + + boolean result = true; + result = result && getAssetIssueList() + .equals(other.getAssetIssueList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getAssetIssueCount() > 0) { + hash = (37 * hash) + ASSETISSUE_FIELD_NUMBER; + hash = (53 * hash) + getAssetIssueList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AssetIssueList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.AssetIssueList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AssetIssueList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AssetIssueList) + org.tron.api.GrpcAPI.AssetIssueListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AssetIssueList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AssetIssueList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AssetIssueList.class, org.tron.api.GrpcAPI.AssetIssueList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.AssetIssueList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getAssetIssueFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (assetIssueBuilder_ == null) { + assetIssue_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + assetIssueBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_AssetIssueList_descriptor; + } + + public org.tron.api.GrpcAPI.AssetIssueList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.AssetIssueList build() { + org.tron.api.GrpcAPI.AssetIssueList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.AssetIssueList buildPartial() { + org.tron.api.GrpcAPI.AssetIssueList result = new org.tron.api.GrpcAPI.AssetIssueList(this); + int from_bitField0_ = bitField0_; + if (assetIssueBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + assetIssue_ = java.util.Collections.unmodifiableList(assetIssue_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.assetIssue_ = assetIssue_; + } else { + result.assetIssue_ = assetIssueBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.AssetIssueList) { + return mergeFrom((org.tron.api.GrpcAPI.AssetIssueList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.AssetIssueList other) { + if (other == org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance()) return this; + if (assetIssueBuilder_ == null) { + if (!other.assetIssue_.isEmpty()) { + if (assetIssue_.isEmpty()) { + assetIssue_ = other.assetIssue_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureAssetIssueIsMutable(); + assetIssue_.addAll(other.assetIssue_); + } + onChanged(); + } + } else { + if (!other.assetIssue_.isEmpty()) { + if (assetIssueBuilder_.isEmpty()) { + assetIssueBuilder_.dispose(); + assetIssueBuilder_ = null; + assetIssue_ = other.assetIssue_; + bitField0_ = (bitField0_ & ~0x00000001); + assetIssueBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getAssetIssueFieldBuilder() : null; + } else { + assetIssueBuilder_.addAllMessages(other.assetIssue_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.AssetIssueList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.AssetIssueList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List assetIssue_ = + java.util.Collections.emptyList(); + private void ensureAssetIssueIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + assetIssue_ = new java.util.ArrayList(assetIssue_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.AssetIssueContract, org.tron.protos.Contract.AssetIssueContract.Builder, org.tron.protos.Contract.AssetIssueContractOrBuilder> assetIssueBuilder_; + + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public java.util.List getAssetIssueList() { + if (assetIssueBuilder_ == null) { + return java.util.Collections.unmodifiableList(assetIssue_); + } else { + return assetIssueBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public int getAssetIssueCount() { + if (assetIssueBuilder_ == null) { + return assetIssue_.size(); + } else { + return assetIssueBuilder_.getCount(); + } + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public org.tron.protos.Contract.AssetIssueContract getAssetIssue(int index) { + if (assetIssueBuilder_ == null) { + return assetIssue_.get(index); + } else { + return assetIssueBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder setAssetIssue( + int index, org.tron.protos.Contract.AssetIssueContract value) { + if (assetIssueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAssetIssueIsMutable(); + assetIssue_.set(index, value); + onChanged(); + } else { + assetIssueBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder setAssetIssue( + int index, org.tron.protos.Contract.AssetIssueContract.Builder builderForValue) { + if (assetIssueBuilder_ == null) { + ensureAssetIssueIsMutable(); + assetIssue_.set(index, builderForValue.build()); + onChanged(); + } else { + assetIssueBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder addAssetIssue(org.tron.protos.Contract.AssetIssueContract value) { + if (assetIssueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAssetIssueIsMutable(); + assetIssue_.add(value); + onChanged(); + } else { + assetIssueBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder addAssetIssue( + int index, org.tron.protos.Contract.AssetIssueContract value) { + if (assetIssueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAssetIssueIsMutable(); + assetIssue_.add(index, value); + onChanged(); + } else { + assetIssueBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder addAssetIssue( + org.tron.protos.Contract.AssetIssueContract.Builder builderForValue) { + if (assetIssueBuilder_ == null) { + ensureAssetIssueIsMutable(); + assetIssue_.add(builderForValue.build()); + onChanged(); + } else { + assetIssueBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder addAssetIssue( + int index, org.tron.protos.Contract.AssetIssueContract.Builder builderForValue) { + if (assetIssueBuilder_ == null) { + ensureAssetIssueIsMutable(); + assetIssue_.add(index, builderForValue.build()); + onChanged(); + } else { + assetIssueBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder addAllAssetIssue( + java.lang.Iterable values) { + if (assetIssueBuilder_ == null) { + ensureAssetIssueIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, assetIssue_); + onChanged(); + } else { + assetIssueBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder clearAssetIssue() { + if (assetIssueBuilder_ == null) { + assetIssue_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + assetIssueBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public Builder removeAssetIssue(int index) { + if (assetIssueBuilder_ == null) { + ensureAssetIssueIsMutable(); + assetIssue_.remove(index); + onChanged(); + } else { + assetIssueBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public org.tron.protos.Contract.AssetIssueContract.Builder getAssetIssueBuilder( + int index) { + return getAssetIssueFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public org.tron.protos.Contract.AssetIssueContractOrBuilder getAssetIssueOrBuilder( + int index) { + if (assetIssueBuilder_ == null) { + return assetIssue_.get(index); } else { + return assetIssueBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public java.util.List + getAssetIssueOrBuilderList() { + if (assetIssueBuilder_ != null) { + return assetIssueBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(assetIssue_); + } + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public org.tron.protos.Contract.AssetIssueContract.Builder addAssetIssueBuilder() { + return getAssetIssueFieldBuilder().addBuilder( + org.tron.protos.Contract.AssetIssueContract.getDefaultInstance()); + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public org.tron.protos.Contract.AssetIssueContract.Builder addAssetIssueBuilder( + int index) { + return getAssetIssueFieldBuilder().addBuilder( + index, org.tron.protos.Contract.AssetIssueContract.getDefaultInstance()); + } + /** + * repeated .protocol.AssetIssueContract assetIssue = 1; + */ + public java.util.List + getAssetIssueBuilderList() { + return getAssetIssueFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.AssetIssueContract, org.tron.protos.Contract.AssetIssueContract.Builder, org.tron.protos.Contract.AssetIssueContractOrBuilder> + getAssetIssueFieldBuilder() { + if (assetIssueBuilder_ == null) { + assetIssueBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.AssetIssueContract, org.tron.protos.Contract.AssetIssueContract.Builder, org.tron.protos.Contract.AssetIssueContractOrBuilder>( + assetIssue_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + assetIssue_ = null; + } + return assetIssueBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AssetIssueList) + } + + // @@protoc_insertion_point(class_scope:protocol.AssetIssueList) + private static final org.tron.api.GrpcAPI.AssetIssueList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.AssetIssueList(); + } + + public static org.tron.api.GrpcAPI.AssetIssueList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AssetIssueList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AssetIssueList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.AssetIssueList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Block block = 1; + */ + java.util.List + getBlockList(); + /** + * repeated .protocol.Block block = 1; + */ + org.tron.protos.Protocol.Block getBlock(int index); + /** + * repeated .protocol.Block block = 1; + */ + int getBlockCount(); + /** + * repeated .protocol.Block block = 1; + */ + java.util.List + getBlockOrBuilderList(); + /** + * repeated .protocol.Block block = 1; + */ + org.tron.protos.Protocol.BlockOrBuilder getBlockOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.BlockList} + */ + public static final class BlockList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockList) + BlockListOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockList.newBuilder() to construct. + private BlockList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockList() { + block_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + block_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + block_.add( + input.readMessage(org.tron.protos.Protocol.Block.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + block_ = java.util.Collections.unmodifiableList(block_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockList.class, org.tron.api.GrpcAPI.BlockList.Builder.class); + } + + public static final int BLOCK_FIELD_NUMBER = 1; + private java.util.List block_; + /** + * repeated .protocol.Block block = 1; + */ + public java.util.List getBlockList() { + return block_; + } + /** + * repeated .protocol.Block block = 1; + */ + public java.util.List + getBlockOrBuilderList() { + return block_; + } + /** + * repeated .protocol.Block block = 1; + */ + public int getBlockCount() { + return block_.size(); + } + /** + * repeated .protocol.Block block = 1; + */ + public org.tron.protos.Protocol.Block getBlock(int index) { + return block_.get(index); + } + /** + * repeated .protocol.Block block = 1; + */ + public org.tron.protos.Protocol.BlockOrBuilder getBlockOrBuilder( + int index) { + return block_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < block_.size(); i++) { + output.writeMessage(1, block_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < block_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, block_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.BlockList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.BlockList other = (org.tron.api.GrpcAPI.BlockList) obj; + + boolean result = true; + result = result && getBlockList() + .equals(other.getBlockList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getBlockCount() > 0) { + hash = (37 * hash) + BLOCK_FIELD_NUMBER; + hash = (53 * hash) + getBlockList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.BlockList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.BlockList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockList) + org.tron.api.GrpcAPI.BlockListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockList.class, org.tron.api.GrpcAPI.BlockList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.BlockList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getBlockFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (blockBuilder_ == null) { + block_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + blockBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockList_descriptor; + } + + public org.tron.api.GrpcAPI.BlockList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.BlockList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.BlockList build() { + org.tron.api.GrpcAPI.BlockList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.BlockList buildPartial() { + org.tron.api.GrpcAPI.BlockList result = new org.tron.api.GrpcAPI.BlockList(this); + int from_bitField0_ = bitField0_; + if (blockBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + block_ = java.util.Collections.unmodifiableList(block_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.block_ = block_; + } else { + result.block_ = blockBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.BlockList) { + return mergeFrom((org.tron.api.GrpcAPI.BlockList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.BlockList other) { + if (other == org.tron.api.GrpcAPI.BlockList.getDefaultInstance()) return this; + if (blockBuilder_ == null) { + if (!other.block_.isEmpty()) { + if (block_.isEmpty()) { + block_ = other.block_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBlockIsMutable(); + block_.addAll(other.block_); + } + onChanged(); + } + } else { + if (!other.block_.isEmpty()) { + if (blockBuilder_.isEmpty()) { + blockBuilder_.dispose(); + blockBuilder_ = null; + block_ = other.block_; + bitField0_ = (bitField0_ & ~0x00000001); + blockBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getBlockFieldBuilder() : null; + } else { + blockBuilder_.addAllMessages(other.block_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.BlockList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.BlockList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List block_ = + java.util.Collections.emptyList(); + private void ensureBlockIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + block_ = new java.util.ArrayList(block_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Block, org.tron.protos.Protocol.Block.Builder, org.tron.protos.Protocol.BlockOrBuilder> blockBuilder_; + + /** + * repeated .protocol.Block block = 1; + */ + public java.util.List getBlockList() { + if (blockBuilder_ == null) { + return java.util.Collections.unmodifiableList(block_); + } else { + return blockBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Block block = 1; + */ + public int getBlockCount() { + if (blockBuilder_ == null) { + return block_.size(); + } else { + return blockBuilder_.getCount(); + } + } + /** + * repeated .protocol.Block block = 1; + */ + public org.tron.protos.Protocol.Block getBlock(int index) { + if (blockBuilder_ == null) { + return block_.get(index); + } else { + return blockBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder setBlock( + int index, org.tron.protos.Protocol.Block value) { + if (blockBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockIsMutable(); + block_.set(index, value); + onChanged(); + } else { + blockBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder setBlock( + int index, org.tron.protos.Protocol.Block.Builder builderForValue) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.set(index, builderForValue.build()); + onChanged(); + } else { + blockBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder addBlock(org.tron.protos.Protocol.Block value) { + if (blockBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockIsMutable(); + block_.add(value); + onChanged(); + } else { + blockBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder addBlock( + int index, org.tron.protos.Protocol.Block value) { + if (blockBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockIsMutable(); + block_.add(index, value); + onChanged(); + } else { + blockBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder addBlock( + org.tron.protos.Protocol.Block.Builder builderForValue) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.add(builderForValue.build()); + onChanged(); + } else { + blockBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder addBlock( + int index, org.tron.protos.Protocol.Block.Builder builderForValue) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.add(index, builderForValue.build()); + onChanged(); + } else { + blockBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder addAllBlock( + java.lang.Iterable values) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, block_); + onChanged(); + } else { + blockBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder clearBlock() { + if (blockBuilder_ == null) { + block_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + blockBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public Builder removeBlock(int index) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.remove(index); + onChanged(); + } else { + blockBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Block block = 1; + */ + public org.tron.protos.Protocol.Block.Builder getBlockBuilder( + int index) { + return getBlockFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Block block = 1; + */ + public org.tron.protos.Protocol.BlockOrBuilder getBlockOrBuilder( + int index) { + if (blockBuilder_ == null) { + return block_.get(index); } else { + return blockBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Block block = 1; + */ + public java.util.List + getBlockOrBuilderList() { + if (blockBuilder_ != null) { + return blockBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(block_); + } + } + /** + * repeated .protocol.Block block = 1; + */ + public org.tron.protos.Protocol.Block.Builder addBlockBuilder() { + return getBlockFieldBuilder().addBuilder( + org.tron.protos.Protocol.Block.getDefaultInstance()); + } + /** + * repeated .protocol.Block block = 1; + */ + public org.tron.protos.Protocol.Block.Builder addBlockBuilder( + int index) { + return getBlockFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Block.getDefaultInstance()); + } + /** + * repeated .protocol.Block block = 1; + */ + public java.util.List + getBlockBuilderList() { + return getBlockFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Block, org.tron.protos.Protocol.Block.Builder, org.tron.protos.Protocol.BlockOrBuilder> + getBlockFieldBuilder() { + if (blockBuilder_ == null) { + blockBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Block, org.tron.protos.Protocol.Block.Builder, org.tron.protos.Protocol.BlockOrBuilder>( + block_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + block_ = null; + } + return blockBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockList) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockList) + private static final org.tron.api.GrpcAPI.BlockList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.BlockList(); + } + + public static org.tron.api.GrpcAPI.BlockList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.BlockList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Transaction transaction = 1; + */ + java.util.List + getTransactionList(); + /** + * repeated .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.Transaction getTransaction(int index); + /** + * repeated .protocol.Transaction transaction = 1; + */ + int getTransactionCount(); + /** + * repeated .protocol.Transaction transaction = 1; + */ + java.util.List + getTransactionOrBuilderList(); + /** + * repeated .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.TransactionList} + */ + public static final class TransactionList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionList) + TransactionListOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionList.newBuilder() to construct. + private TransactionList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionList() { + transaction_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + transaction_.add( + input.readMessage(org.tron.protos.Protocol.Transaction.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = java.util.Collections.unmodifiableList(transaction_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionList.class, org.tron.api.GrpcAPI.TransactionList.Builder.class); + } + + public static final int TRANSACTION_FIELD_NUMBER = 1; + private java.util.List transaction_; + /** + * repeated .protocol.Transaction transaction = 1; + */ + public java.util.List getTransactionList() { + return transaction_; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public java.util.List + getTransactionOrBuilderList() { + return transaction_; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public int getTransactionCount() { + return transaction_.size(); + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction(int index) { + return transaction_.get(index); + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder( + int index) { + return transaction_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < transaction_.size(); i++) { + output.writeMessage(1, transaction_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < transaction_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, transaction_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionList other = (org.tron.api.GrpcAPI.TransactionList) obj; + + boolean result = true; + result = result && getTransactionList() + .equals(other.getTransactionList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTransactionCount() > 0) { + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransactionList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionList) + org.tron.api.GrpcAPI.TransactionListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionList.class, org.tron.api.GrpcAPI.TransactionList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTransactionFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (transactionBuilder_ == null) { + transaction_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + transactionBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionList_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionList build() { + org.tron.api.GrpcAPI.TransactionList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionList buildPartial() { + org.tron.api.GrpcAPI.TransactionList result = new org.tron.api.GrpcAPI.TransactionList(this); + int from_bitField0_ = bitField0_; + if (transactionBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = java.util.Collections.unmodifiableList(transaction_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.transaction_ = transaction_; + } else { + result.transaction_ = transactionBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionList) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionList other) { + if (other == org.tron.api.GrpcAPI.TransactionList.getDefaultInstance()) return this; + if (transactionBuilder_ == null) { + if (!other.transaction_.isEmpty()) { + if (transaction_.isEmpty()) { + transaction_ = other.transaction_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTransactionIsMutable(); + transaction_.addAll(other.transaction_); + } + onChanged(); + } + } else { + if (!other.transaction_.isEmpty()) { + if (transactionBuilder_.isEmpty()) { + transactionBuilder_.dispose(); + transactionBuilder_ = null; + transaction_ = other.transaction_; + bitField0_ = (bitField0_ & ~0x00000001); + transactionBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTransactionFieldBuilder() : null; + } else { + transactionBuilder_.addAllMessages(other.transaction_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List transaction_ = + java.util.Collections.emptyList(); + private void ensureTransactionIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = new java.util.ArrayList(transaction_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> transactionBuilder_; + + /** + * repeated .protocol.Transaction transaction = 1; + */ + public java.util.List getTransactionList() { + if (transactionBuilder_ == null) { + return java.util.Collections.unmodifiableList(transaction_); + } else { + return transactionBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public int getTransactionCount() { + if (transactionBuilder_ == null) { + return transaction_.size(); + } else { + return transactionBuilder_.getCount(); + } + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction(int index) { + if (transactionBuilder_ == null) { + return transaction_.get(index); + } else { + return transactionBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder setTransaction( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionIsMutable(); + transaction_.set(index, value); + onChanged(); + } else { + transactionBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder setTransaction( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.set(index, builderForValue.build()); + onChanged(); + } else { + transactionBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder addTransaction(org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionIsMutable(); + transaction_.add(value); + onChanged(); + } else { + transactionBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder addTransaction( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionIsMutable(); + transaction_.add(index, value); + onChanged(); + } else { + transactionBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder addTransaction( + org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.add(builderForValue.build()); + onChanged(); + } else { + transactionBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder addTransaction( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.add(index, builderForValue.build()); + onChanged(); + } else { + transactionBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder addAllTransaction( + java.lang.Iterable values) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, transaction_); + onChanged(); + } else { + transactionBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder clearTransaction() { + if (transactionBuilder_ == null) { + transaction_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + transactionBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public Builder removeTransaction(int index) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.remove(index); + onChanged(); + } else { + transactionBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder getTransactionBuilder( + int index) { + return getTransactionFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder( + int index) { + if (transactionBuilder_ == null) { + return transaction_.get(index); } else { + return transactionBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public java.util.List + getTransactionOrBuilderList() { + if (transactionBuilder_ != null) { + return transactionBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transaction_); + } + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionBuilder() { + return getTransactionFieldBuilder().addBuilder( + org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionBuilder( + int index) { + return getTransactionFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transaction = 1; + */ + public java.util.List + getTransactionBuilderList() { + return getTransactionFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> + getTransactionFieldBuilder() { + if (transactionBuilder_ == null) { + transactionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder>( + transaction_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + transaction_ = null; + } + return transactionBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionList) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionList) + private static final org.tron.api.GrpcAPI.TransactionList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionList(); + } + + public static org.tron.api.GrpcAPI.TransactionList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DelegatedResourceMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.DelegatedResourceMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes fromAddress = 1; + */ + com.google.protobuf.ByteString getFromAddress(); + + /** + * bytes toAddress = 2; + */ + com.google.protobuf.ByteString getToAddress(); + } + /** + * Protobuf type {@code protocol.DelegatedResourceMessage} + */ + public static final class DelegatedResourceMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.DelegatedResourceMessage) + DelegatedResourceMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use DelegatedResourceMessage.newBuilder() to construct. + private DelegatedResourceMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DelegatedResourceMessage() { + fromAddress_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DelegatedResourceMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + fromAddress_ = input.readBytes(); + break; + } + case 18: { + + toAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.DelegatedResourceMessage.class, org.tron.api.GrpcAPI.DelegatedResourceMessage.Builder.class); + } + + public static final int FROMADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString fromAddress_; + /** + * bytes fromAddress = 1; + */ + public com.google.protobuf.ByteString getFromAddress() { + return fromAddress_; + } + + public static final int TOADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!fromAddress_.isEmpty()) { + output.writeBytes(1, fromAddress_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(2, toAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!fromAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, fromAddress_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, toAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.DelegatedResourceMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.DelegatedResourceMessage other = (org.tron.api.GrpcAPI.DelegatedResourceMessage) obj; + + boolean result = true; + result = result && getFromAddress() + .equals(other.getFromAddress()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FROMADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getFromAddress().hashCode(); + hash = (37 * hash) + TOADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.DelegatedResourceMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.DelegatedResourceMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.DelegatedResourceMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.DelegatedResourceMessage) + org.tron.api.GrpcAPI.DelegatedResourceMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.DelegatedResourceMessage.class, org.tron.api.GrpcAPI.DelegatedResourceMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.DelegatedResourceMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + fromAddress_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceMessage_descriptor; + } + + public org.tron.api.GrpcAPI.DelegatedResourceMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.DelegatedResourceMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.DelegatedResourceMessage build() { + org.tron.api.GrpcAPI.DelegatedResourceMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.DelegatedResourceMessage buildPartial() { + org.tron.api.GrpcAPI.DelegatedResourceMessage result = new org.tron.api.GrpcAPI.DelegatedResourceMessage(this); + result.fromAddress_ = fromAddress_; + result.toAddress_ = toAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.DelegatedResourceMessage) { + return mergeFrom((org.tron.api.GrpcAPI.DelegatedResourceMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.DelegatedResourceMessage other) { + if (other == org.tron.api.GrpcAPI.DelegatedResourceMessage.getDefaultInstance()) return this; + if (other.getFromAddress() != com.google.protobuf.ByteString.EMPTY) { + setFromAddress(other.getFromAddress()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.DelegatedResourceMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.DelegatedResourceMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString fromAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes fromAddress = 1; + */ + public com.google.protobuf.ByteString getFromAddress() { + return fromAddress_; + } + /** + * bytes fromAddress = 1; + */ + public Builder setFromAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + fromAddress_ = value; + onChanged(); + return this; + } + /** + * bytes fromAddress = 1; + */ + public Builder clearFromAddress() { + + fromAddress_ = getDefaultInstance().getFromAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes toAddress = 2; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes toAddress = 2; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.DelegatedResourceMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.DelegatedResourceMessage) + private static final org.tron.api.GrpcAPI.DelegatedResourceMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.DelegatedResourceMessage(); + } + + public static org.tron.api.GrpcAPI.DelegatedResourceMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DelegatedResourceMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DelegatedResourceMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.DelegatedResourceMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DelegatedResourceListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.DelegatedResourceList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + java.util.List + getDelegatedResourceList(); + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + org.tron.protos.Protocol.DelegatedResource getDelegatedResource(int index); + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + int getDelegatedResourceCount(); + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + java.util.List + getDelegatedResourceOrBuilderList(); + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + org.tron.protos.Protocol.DelegatedResourceOrBuilder getDelegatedResourceOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.DelegatedResourceList} + */ + public static final class DelegatedResourceList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.DelegatedResourceList) + DelegatedResourceListOrBuilder { + private static final long serialVersionUID = 0L; + // Use DelegatedResourceList.newBuilder() to construct. + private DelegatedResourceList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DelegatedResourceList() { + delegatedResource_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DelegatedResourceList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + delegatedResource_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + delegatedResource_.add( + input.readMessage(org.tron.protos.Protocol.DelegatedResource.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + delegatedResource_ = java.util.Collections.unmodifiableList(delegatedResource_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.DelegatedResourceList.class, org.tron.api.GrpcAPI.DelegatedResourceList.Builder.class); + } + + public static final int DELEGATEDRESOURCE_FIELD_NUMBER = 1; + private java.util.List delegatedResource_; + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public java.util.List getDelegatedResourceList() { + return delegatedResource_; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public java.util.List + getDelegatedResourceOrBuilderList() { + return delegatedResource_; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public int getDelegatedResourceCount() { + return delegatedResource_.size(); + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public org.tron.protos.Protocol.DelegatedResource getDelegatedResource(int index) { + return delegatedResource_.get(index); + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public org.tron.protos.Protocol.DelegatedResourceOrBuilder getDelegatedResourceOrBuilder( + int index) { + return delegatedResource_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < delegatedResource_.size(); i++) { + output.writeMessage(1, delegatedResource_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < delegatedResource_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, delegatedResource_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.DelegatedResourceList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.DelegatedResourceList other = (org.tron.api.GrpcAPI.DelegatedResourceList) obj; + + boolean result = true; + result = result && getDelegatedResourceList() + .equals(other.getDelegatedResourceList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDelegatedResourceCount() > 0) { + hash = (37 * hash) + DELEGATEDRESOURCE_FIELD_NUMBER; + hash = (53 * hash) + getDelegatedResourceList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.DelegatedResourceList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.DelegatedResourceList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.DelegatedResourceList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.DelegatedResourceList) + org.tron.api.GrpcAPI.DelegatedResourceListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.DelegatedResourceList.class, org.tron.api.GrpcAPI.DelegatedResourceList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.DelegatedResourceList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getDelegatedResourceFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (delegatedResourceBuilder_ == null) { + delegatedResource_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + delegatedResourceBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_DelegatedResourceList_descriptor; + } + + public org.tron.api.GrpcAPI.DelegatedResourceList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.DelegatedResourceList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.DelegatedResourceList build() { + org.tron.api.GrpcAPI.DelegatedResourceList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.DelegatedResourceList buildPartial() { + org.tron.api.GrpcAPI.DelegatedResourceList result = new org.tron.api.GrpcAPI.DelegatedResourceList(this); + int from_bitField0_ = bitField0_; + if (delegatedResourceBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + delegatedResource_ = java.util.Collections.unmodifiableList(delegatedResource_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.delegatedResource_ = delegatedResource_; + } else { + result.delegatedResource_ = delegatedResourceBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.DelegatedResourceList) { + return mergeFrom((org.tron.api.GrpcAPI.DelegatedResourceList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.DelegatedResourceList other) { + if (other == org.tron.api.GrpcAPI.DelegatedResourceList.getDefaultInstance()) return this; + if (delegatedResourceBuilder_ == null) { + if (!other.delegatedResource_.isEmpty()) { + if (delegatedResource_.isEmpty()) { + delegatedResource_ = other.delegatedResource_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDelegatedResourceIsMutable(); + delegatedResource_.addAll(other.delegatedResource_); + } + onChanged(); + } + } else { + if (!other.delegatedResource_.isEmpty()) { + if (delegatedResourceBuilder_.isEmpty()) { + delegatedResourceBuilder_.dispose(); + delegatedResourceBuilder_ = null; + delegatedResource_ = other.delegatedResource_; + bitField0_ = (bitField0_ & ~0x00000001); + delegatedResourceBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getDelegatedResourceFieldBuilder() : null; + } else { + delegatedResourceBuilder_.addAllMessages(other.delegatedResource_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.DelegatedResourceList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.DelegatedResourceList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List delegatedResource_ = + java.util.Collections.emptyList(); + private void ensureDelegatedResourceIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + delegatedResource_ = new java.util.ArrayList(delegatedResource_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.DelegatedResource, org.tron.protos.Protocol.DelegatedResource.Builder, org.tron.protos.Protocol.DelegatedResourceOrBuilder> delegatedResourceBuilder_; + + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public java.util.List getDelegatedResourceList() { + if (delegatedResourceBuilder_ == null) { + return java.util.Collections.unmodifiableList(delegatedResource_); + } else { + return delegatedResourceBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public int getDelegatedResourceCount() { + if (delegatedResourceBuilder_ == null) { + return delegatedResource_.size(); + } else { + return delegatedResourceBuilder_.getCount(); + } + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public org.tron.protos.Protocol.DelegatedResource getDelegatedResource(int index) { + if (delegatedResourceBuilder_ == null) { + return delegatedResource_.get(index); + } else { + return delegatedResourceBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder setDelegatedResource( + int index, org.tron.protos.Protocol.DelegatedResource value) { + if (delegatedResourceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDelegatedResourceIsMutable(); + delegatedResource_.set(index, value); + onChanged(); + } else { + delegatedResourceBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder setDelegatedResource( + int index, org.tron.protos.Protocol.DelegatedResource.Builder builderForValue) { + if (delegatedResourceBuilder_ == null) { + ensureDelegatedResourceIsMutable(); + delegatedResource_.set(index, builderForValue.build()); + onChanged(); + } else { + delegatedResourceBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder addDelegatedResource(org.tron.protos.Protocol.DelegatedResource value) { + if (delegatedResourceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDelegatedResourceIsMutable(); + delegatedResource_.add(value); + onChanged(); + } else { + delegatedResourceBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder addDelegatedResource( + int index, org.tron.protos.Protocol.DelegatedResource value) { + if (delegatedResourceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDelegatedResourceIsMutable(); + delegatedResource_.add(index, value); + onChanged(); + } else { + delegatedResourceBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder addDelegatedResource( + org.tron.protos.Protocol.DelegatedResource.Builder builderForValue) { + if (delegatedResourceBuilder_ == null) { + ensureDelegatedResourceIsMutable(); + delegatedResource_.add(builderForValue.build()); + onChanged(); + } else { + delegatedResourceBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder addDelegatedResource( + int index, org.tron.protos.Protocol.DelegatedResource.Builder builderForValue) { + if (delegatedResourceBuilder_ == null) { + ensureDelegatedResourceIsMutable(); + delegatedResource_.add(index, builderForValue.build()); + onChanged(); + } else { + delegatedResourceBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder addAllDelegatedResource( + java.lang.Iterable values) { + if (delegatedResourceBuilder_ == null) { + ensureDelegatedResourceIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, delegatedResource_); + onChanged(); + } else { + delegatedResourceBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder clearDelegatedResource() { + if (delegatedResourceBuilder_ == null) { + delegatedResource_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + delegatedResourceBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public Builder removeDelegatedResource(int index) { + if (delegatedResourceBuilder_ == null) { + ensureDelegatedResourceIsMutable(); + delegatedResource_.remove(index); + onChanged(); + } else { + delegatedResourceBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public org.tron.protos.Protocol.DelegatedResource.Builder getDelegatedResourceBuilder( + int index) { + return getDelegatedResourceFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public org.tron.protos.Protocol.DelegatedResourceOrBuilder getDelegatedResourceOrBuilder( + int index) { + if (delegatedResourceBuilder_ == null) { + return delegatedResource_.get(index); } else { + return delegatedResourceBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public java.util.List + getDelegatedResourceOrBuilderList() { + if (delegatedResourceBuilder_ != null) { + return delegatedResourceBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(delegatedResource_); + } + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public org.tron.protos.Protocol.DelegatedResource.Builder addDelegatedResourceBuilder() { + return getDelegatedResourceFieldBuilder().addBuilder( + org.tron.protos.Protocol.DelegatedResource.getDefaultInstance()); + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public org.tron.protos.Protocol.DelegatedResource.Builder addDelegatedResourceBuilder( + int index) { + return getDelegatedResourceFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.DelegatedResource.getDefaultInstance()); + } + /** + * repeated .protocol.DelegatedResource delegatedResource = 1; + */ + public java.util.List + getDelegatedResourceBuilderList() { + return getDelegatedResourceFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.DelegatedResource, org.tron.protos.Protocol.DelegatedResource.Builder, org.tron.protos.Protocol.DelegatedResourceOrBuilder> + getDelegatedResourceFieldBuilder() { + if (delegatedResourceBuilder_ == null) { + delegatedResourceBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.DelegatedResource, org.tron.protos.Protocol.DelegatedResource.Builder, org.tron.protos.Protocol.DelegatedResourceOrBuilder>( + delegatedResource_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + delegatedResource_ = null; + } + return delegatedResourceBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.DelegatedResourceList) + } + + // @@protoc_insertion_point(class_scope:protocol.DelegatedResourceList) + private static final org.tron.api.GrpcAPI.DelegatedResourceList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.DelegatedResourceList(); + } + + public static org.tron.api.GrpcAPI.DelegatedResourceList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DelegatedResourceList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DelegatedResourceList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.DelegatedResourceList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface NodeListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NodeList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Node nodes = 1; + */ + java.util.List + getNodesList(); + /** + * repeated .protocol.Node nodes = 1; + */ + org.tron.api.GrpcAPI.Node getNodes(int index); + /** + * repeated .protocol.Node nodes = 1; + */ + int getNodesCount(); + /** + * repeated .protocol.Node nodes = 1; + */ + java.util.List + getNodesOrBuilderList(); + /** + * repeated .protocol.Node nodes = 1; + */ + org.tron.api.GrpcAPI.NodeOrBuilder getNodesOrBuilder( + int index); + } + /** + *
+   * Gossip node list
+   * 
+ * + * Protobuf type {@code protocol.NodeList} + */ + public static final class NodeList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NodeList) + NodeListOrBuilder { + private static final long serialVersionUID = 0L; + // Use NodeList.newBuilder() to construct. + private NodeList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NodeList() { + nodes_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NodeList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + nodes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + nodes_.add( + input.readMessage(org.tron.api.GrpcAPI.Node.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + nodes_ = java.util.Collections.unmodifiableList(nodes_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_NodeList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_NodeList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.NodeList.class, org.tron.api.GrpcAPI.NodeList.Builder.class); + } + + public static final int NODES_FIELD_NUMBER = 1; + private java.util.List nodes_; + /** + * repeated .protocol.Node nodes = 1; + */ + public java.util.List getNodesList() { + return nodes_; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public java.util.List + getNodesOrBuilderList() { + return nodes_; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public int getNodesCount() { + return nodes_.size(); + } + /** + * repeated .protocol.Node nodes = 1; + */ + public org.tron.api.GrpcAPI.Node getNodes(int index) { + return nodes_.get(index); + } + /** + * repeated .protocol.Node nodes = 1; + */ + public org.tron.api.GrpcAPI.NodeOrBuilder getNodesOrBuilder( + int index) { + return nodes_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < nodes_.size(); i++) { + output.writeMessage(1, nodes_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < nodes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, nodes_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.NodeList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.NodeList other = (org.tron.api.GrpcAPI.NodeList) obj; + + boolean result = true; + result = result && getNodesList() + .equals(other.getNodesList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getNodesCount() > 0) { + hash = (37 * hash) + NODES_FIELD_NUMBER; + hash = (53 * hash) + getNodesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.NodeList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NodeList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.NodeList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.NodeList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.NodeList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Gossip node list
+     * 
+ * + * Protobuf type {@code protocol.NodeList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NodeList) + org.tron.api.GrpcAPI.NodeListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_NodeList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_NodeList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.NodeList.class, org.tron.api.GrpcAPI.NodeList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.NodeList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getNodesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (nodesBuilder_ == null) { + nodes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + nodesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_NodeList_descriptor; + } + + public org.tron.api.GrpcAPI.NodeList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.NodeList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.NodeList build() { + org.tron.api.GrpcAPI.NodeList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.NodeList buildPartial() { + org.tron.api.GrpcAPI.NodeList result = new org.tron.api.GrpcAPI.NodeList(this); + int from_bitField0_ = bitField0_; + if (nodesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + nodes_ = java.util.Collections.unmodifiableList(nodes_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.nodes_ = nodes_; + } else { + result.nodes_ = nodesBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.NodeList) { + return mergeFrom((org.tron.api.GrpcAPI.NodeList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.NodeList other) { + if (other == org.tron.api.GrpcAPI.NodeList.getDefaultInstance()) return this; + if (nodesBuilder_ == null) { + if (!other.nodes_.isEmpty()) { + if (nodes_.isEmpty()) { + nodes_ = other.nodes_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureNodesIsMutable(); + nodes_.addAll(other.nodes_); + } + onChanged(); + } + } else { + if (!other.nodes_.isEmpty()) { + if (nodesBuilder_.isEmpty()) { + nodesBuilder_.dispose(); + nodesBuilder_ = null; + nodes_ = other.nodes_; + bitField0_ = (bitField0_ & ~0x00000001); + nodesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getNodesFieldBuilder() : null; + } else { + nodesBuilder_.addAllMessages(other.nodes_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.NodeList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.NodeList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List nodes_ = + java.util.Collections.emptyList(); + private void ensureNodesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + nodes_ = new java.util.ArrayList(nodes_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.Node, org.tron.api.GrpcAPI.Node.Builder, org.tron.api.GrpcAPI.NodeOrBuilder> nodesBuilder_; + + /** + * repeated .protocol.Node nodes = 1; + */ + public java.util.List getNodesList() { + if (nodesBuilder_ == null) { + return java.util.Collections.unmodifiableList(nodes_); + } else { + return nodesBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Node nodes = 1; + */ + public int getNodesCount() { + if (nodesBuilder_ == null) { + return nodes_.size(); + } else { + return nodesBuilder_.getCount(); + } + } + /** + * repeated .protocol.Node nodes = 1; + */ + public org.tron.api.GrpcAPI.Node getNodes(int index) { + if (nodesBuilder_ == null) { + return nodes_.get(index); + } else { + return nodesBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder setNodes( + int index, org.tron.api.GrpcAPI.Node value) { + if (nodesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodesIsMutable(); + nodes_.set(index, value); + onChanged(); + } else { + nodesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder setNodes( + int index, org.tron.api.GrpcAPI.Node.Builder builderForValue) { + if (nodesBuilder_ == null) { + ensureNodesIsMutable(); + nodes_.set(index, builderForValue.build()); + onChanged(); + } else { + nodesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder addNodes(org.tron.api.GrpcAPI.Node value) { + if (nodesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodesIsMutable(); + nodes_.add(value); + onChanged(); + } else { + nodesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder addNodes( + int index, org.tron.api.GrpcAPI.Node value) { + if (nodesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodesIsMutable(); + nodes_.add(index, value); + onChanged(); + } else { + nodesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder addNodes( + org.tron.api.GrpcAPI.Node.Builder builderForValue) { + if (nodesBuilder_ == null) { + ensureNodesIsMutable(); + nodes_.add(builderForValue.build()); + onChanged(); + } else { + nodesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder addNodes( + int index, org.tron.api.GrpcAPI.Node.Builder builderForValue) { + if (nodesBuilder_ == null) { + ensureNodesIsMutable(); + nodes_.add(index, builderForValue.build()); + onChanged(); + } else { + nodesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder addAllNodes( + java.lang.Iterable values) { + if (nodesBuilder_ == null) { + ensureNodesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, nodes_); + onChanged(); + } else { + nodesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder clearNodes() { + if (nodesBuilder_ == null) { + nodes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + nodesBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public Builder removeNodes(int index) { + if (nodesBuilder_ == null) { + ensureNodesIsMutable(); + nodes_.remove(index); + onChanged(); + } else { + nodesBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Node nodes = 1; + */ + public org.tron.api.GrpcAPI.Node.Builder getNodesBuilder( + int index) { + return getNodesFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Node nodes = 1; + */ + public org.tron.api.GrpcAPI.NodeOrBuilder getNodesOrBuilder( + int index) { + if (nodesBuilder_ == null) { + return nodes_.get(index); } else { + return nodesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Node nodes = 1; + */ + public java.util.List + getNodesOrBuilderList() { + if (nodesBuilder_ != null) { + return nodesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(nodes_); + } + } + /** + * repeated .protocol.Node nodes = 1; + */ + public org.tron.api.GrpcAPI.Node.Builder addNodesBuilder() { + return getNodesFieldBuilder().addBuilder( + org.tron.api.GrpcAPI.Node.getDefaultInstance()); + } + /** + * repeated .protocol.Node nodes = 1; + */ + public org.tron.api.GrpcAPI.Node.Builder addNodesBuilder( + int index) { + return getNodesFieldBuilder().addBuilder( + index, org.tron.api.GrpcAPI.Node.getDefaultInstance()); + } + /** + * repeated .protocol.Node nodes = 1; + */ + public java.util.List + getNodesBuilderList() { + return getNodesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.Node, org.tron.api.GrpcAPI.Node.Builder, org.tron.api.GrpcAPI.NodeOrBuilder> + getNodesFieldBuilder() { + if (nodesBuilder_ == null) { + nodesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.Node, org.tron.api.GrpcAPI.Node.Builder, org.tron.api.GrpcAPI.NodeOrBuilder>( + nodes_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + nodes_ = null; + } + return nodesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NodeList) + } + + // @@protoc_insertion_point(class_scope:protocol.NodeList) + private static final org.tron.api.GrpcAPI.NodeList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.NodeList(); + } + + public static org.tron.api.GrpcAPI.NodeList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public NodeList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NodeList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.NodeList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface NodeOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Node) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Address address = 1; + */ + boolean hasAddress(); + /** + * .protocol.Address address = 1; + */ + org.tron.api.GrpcAPI.Address getAddress(); + /** + * .protocol.Address address = 1; + */ + org.tron.api.GrpcAPI.AddressOrBuilder getAddressOrBuilder(); + } + /** + *
+   * Gossip node
+   * 
+ * + * Protobuf type {@code protocol.Node} + */ + public static final class Node extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Node) + NodeOrBuilder { + private static final long serialVersionUID = 0L; + // Use Node.newBuilder() to construct. + private Node(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Node() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Node( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.api.GrpcAPI.Address.Builder subBuilder = null; + if (address_ != null) { + subBuilder = address_.toBuilder(); + } + address_ = input.readMessage(org.tron.api.GrpcAPI.Address.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(address_); + address_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_Node_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_Node_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.Node.class, org.tron.api.GrpcAPI.Node.Builder.class); + } + + public static final int ADDRESS_FIELD_NUMBER = 1; + private org.tron.api.GrpcAPI.Address address_; + /** + * .protocol.Address address = 1; + */ + public boolean hasAddress() { + return address_ != null; + } + /** + * .protocol.Address address = 1; + */ + public org.tron.api.GrpcAPI.Address getAddress() { + return address_ == null ? org.tron.api.GrpcAPI.Address.getDefaultInstance() : address_; + } + /** + * .protocol.Address address = 1; + */ + public org.tron.api.GrpcAPI.AddressOrBuilder getAddressOrBuilder() { + return getAddress(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (address_ != null) { + output.writeMessage(1, getAddress()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (address_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getAddress()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.Node)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.Node other = (org.tron.api.GrpcAPI.Node) obj; + + boolean result = true; + result = result && (hasAddress() == other.hasAddress()); + if (hasAddress()) { + result = result && getAddress() + .equals(other.getAddress()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasAddress()) { + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.Node parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Node parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Node parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Node parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Node parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Node parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Node parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Node parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Node parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Node parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Node parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Node parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.Node prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Gossip node
+     * 
+ * + * Protobuf type {@code protocol.Node} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Node) + org.tron.api.GrpcAPI.NodeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_Node_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_Node_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.Node.class, org.tron.api.GrpcAPI.Node.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.Node.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (addressBuilder_ == null) { + address_ = null; + } else { + address_ = null; + addressBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_Node_descriptor; + } + + public org.tron.api.GrpcAPI.Node getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.Node.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.Node build() { + org.tron.api.GrpcAPI.Node result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.Node buildPartial() { + org.tron.api.GrpcAPI.Node result = new org.tron.api.GrpcAPI.Node(this); + if (addressBuilder_ == null) { + result.address_ = address_; + } else { + result.address_ = addressBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.Node) { + return mergeFrom((org.tron.api.GrpcAPI.Node)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.Node other) { + if (other == org.tron.api.GrpcAPI.Node.getDefaultInstance()) return this; + if (other.hasAddress()) { + mergeAddress(other.getAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.Node parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.Node) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.api.GrpcAPI.Address address_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Address, org.tron.api.GrpcAPI.Address.Builder, org.tron.api.GrpcAPI.AddressOrBuilder> addressBuilder_; + /** + * .protocol.Address address = 1; + */ + public boolean hasAddress() { + return addressBuilder_ != null || address_ != null; + } + /** + * .protocol.Address address = 1; + */ + public org.tron.api.GrpcAPI.Address getAddress() { + if (addressBuilder_ == null) { + return address_ == null ? org.tron.api.GrpcAPI.Address.getDefaultInstance() : address_; + } else { + return addressBuilder_.getMessage(); + } + } + /** + * .protocol.Address address = 1; + */ + public Builder setAddress(org.tron.api.GrpcAPI.Address value) { + if (addressBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + address_ = value; + onChanged(); + } else { + addressBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Address address = 1; + */ + public Builder setAddress( + org.tron.api.GrpcAPI.Address.Builder builderForValue) { + if (addressBuilder_ == null) { + address_ = builderForValue.build(); + onChanged(); + } else { + addressBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Address address = 1; + */ + public Builder mergeAddress(org.tron.api.GrpcAPI.Address value) { + if (addressBuilder_ == null) { + if (address_ != null) { + address_ = + org.tron.api.GrpcAPI.Address.newBuilder(address_).mergeFrom(value).buildPartial(); + } else { + address_ = value; + } + onChanged(); + } else { + addressBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Address address = 1; + */ + public Builder clearAddress() { + if (addressBuilder_ == null) { + address_ = null; + onChanged(); + } else { + address_ = null; + addressBuilder_ = null; + } + + return this; + } + /** + * .protocol.Address address = 1; + */ + public org.tron.api.GrpcAPI.Address.Builder getAddressBuilder() { + + onChanged(); + return getAddressFieldBuilder().getBuilder(); + } + /** + * .protocol.Address address = 1; + */ + public org.tron.api.GrpcAPI.AddressOrBuilder getAddressOrBuilder() { + if (addressBuilder_ != null) { + return addressBuilder_.getMessageOrBuilder(); + } else { + return address_ == null ? + org.tron.api.GrpcAPI.Address.getDefaultInstance() : address_; + } + } + /** + * .protocol.Address address = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Address, org.tron.api.GrpcAPI.Address.Builder, org.tron.api.GrpcAPI.AddressOrBuilder> + getAddressFieldBuilder() { + if (addressBuilder_ == null) { + addressBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Address, org.tron.api.GrpcAPI.Address.Builder, org.tron.api.GrpcAPI.AddressOrBuilder>( + getAddress(), + getParentForChildren(), + isClean()); + address_ = null; + } + return addressBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Node) + } + + // @@protoc_insertion_point(class_scope:protocol.Node) + private static final org.tron.api.GrpcAPI.Node DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.Node(); + } + + public static org.tron.api.GrpcAPI.Node getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Node parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Node(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.Node getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AddressOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Address) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes host = 1; + */ + com.google.protobuf.ByteString getHost(); + + /** + * int32 port = 2; + */ + int getPort(); + } + /** + *
+   * Gossip node address
+   * 
+ * + * Protobuf type {@code protocol.Address} + */ + public static final class Address extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Address) + AddressOrBuilder { + private static final long serialVersionUID = 0L; + // Use Address.newBuilder() to construct. + private Address(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Address() { + host_ = com.google.protobuf.ByteString.EMPTY; + port_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Address( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + host_ = input.readBytes(); + break; + } + case 16: { + + port_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_Address_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_Address_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.Address.class, org.tron.api.GrpcAPI.Address.Builder.class); + } + + public static final int HOST_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString host_; + /** + * bytes host = 1; + */ + public com.google.protobuf.ByteString getHost() { + return host_; + } + + public static final int PORT_FIELD_NUMBER = 2; + private int port_; + /** + * int32 port = 2; + */ + public int getPort() { + return port_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!host_.isEmpty()) { + output.writeBytes(1, host_); + } + if (port_ != 0) { + output.writeInt32(2, port_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!host_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, host_); + } + if (port_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, port_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.Address)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.Address other = (org.tron.api.GrpcAPI.Address) obj; + + boolean result = true; + result = result && getHost() + .equals(other.getHost()); + result = result && (getPort() + == other.getPort()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + HOST_FIELD_NUMBER; + hash = (53 * hash) + getHost().hashCode(); + hash = (37 * hash) + PORT_FIELD_NUMBER; + hash = (53 * hash) + getPort(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.Address parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Address parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Address parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Address parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Address parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.Address parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Address parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Address parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Address parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Address parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.Address parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.Address parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.Address prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Gossip node address
+     * 
+ * + * Protobuf type {@code protocol.Address} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Address) + org.tron.api.GrpcAPI.AddressOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_Address_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_Address_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.Address.class, org.tron.api.GrpcAPI.Address.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.Address.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + host_ = com.google.protobuf.ByteString.EMPTY; + + port_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_Address_descriptor; + } + + public org.tron.api.GrpcAPI.Address getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.Address.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.Address build() { + org.tron.api.GrpcAPI.Address result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.Address buildPartial() { + org.tron.api.GrpcAPI.Address result = new org.tron.api.GrpcAPI.Address(this); + result.host_ = host_; + result.port_ = port_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.Address) { + return mergeFrom((org.tron.api.GrpcAPI.Address)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.Address other) { + if (other == org.tron.api.GrpcAPI.Address.getDefaultInstance()) return this; + if (other.getHost() != com.google.protobuf.ByteString.EMPTY) { + setHost(other.getHost()); + } + if (other.getPort() != 0) { + setPort(other.getPort()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.Address parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.Address) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString host_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes host = 1; + */ + public com.google.protobuf.ByteString getHost() { + return host_; + } + /** + * bytes host = 1; + */ + public Builder setHost(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + host_ = value; + onChanged(); + return this; + } + /** + * bytes host = 1; + */ + public Builder clearHost() { + + host_ = getDefaultInstance().getHost(); + onChanged(); + return this; + } + + private int port_ ; + /** + * int32 port = 2; + */ + public int getPort() { + return port_; + } + /** + * int32 port = 2; + */ + public Builder setPort(int value) { + + port_ = value; + onChanged(); + return this; + } + /** + * int32 port = 2; + */ + public Builder clearPort() { + + port_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Address) + } + + // @@protoc_insertion_point(class_scope:protocol.Address) + private static final org.tron.api.GrpcAPI.Address DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.Address(); + } + + public static org.tron.api.GrpcAPI.Address getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser
() { + public Address parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Address(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser
parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser
getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.Address getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface EmptyMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.EmptyMessage) + com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code protocol.EmptyMessage} + */ + public static final class EmptyMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.EmptyMessage) + EmptyMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use EmptyMessage.newBuilder() to construct. + private EmptyMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EmptyMessage() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EmptyMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EmptyMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EmptyMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EmptyMessage.class, org.tron.api.GrpcAPI.EmptyMessage.Builder.class); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.EmptyMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.EmptyMessage other = (org.tron.api.GrpcAPI.EmptyMessage) obj; + + boolean result = true; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EmptyMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.EmptyMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.EmptyMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.EmptyMessage) + org.tron.api.GrpcAPI.EmptyMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EmptyMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EmptyMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EmptyMessage.class, org.tron.api.GrpcAPI.EmptyMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.EmptyMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_EmptyMessage_descriptor; + } + + public org.tron.api.GrpcAPI.EmptyMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.EmptyMessage build() { + org.tron.api.GrpcAPI.EmptyMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.EmptyMessage buildPartial() { + org.tron.api.GrpcAPI.EmptyMessage result = new org.tron.api.GrpcAPI.EmptyMessage(this); + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.EmptyMessage) { + return mergeFrom((org.tron.api.GrpcAPI.EmptyMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.EmptyMessage other) { + if (other == org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance()) return this; + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.EmptyMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.EmptyMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.EmptyMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.EmptyMessage) + private static final org.tron.api.GrpcAPI.EmptyMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.EmptyMessage(); + } + + public static org.tron.api.GrpcAPI.EmptyMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EmptyMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EmptyMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.EmptyMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface NumberMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NumberMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 num = 1; + */ + long getNum(); + } + /** + * Protobuf type {@code protocol.NumberMessage} + */ + public static final class NumberMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NumberMessage) + NumberMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use NumberMessage.newBuilder() to construct. + private NumberMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NumberMessage() { + num_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NumberMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + num_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_NumberMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_NumberMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.NumberMessage.class, org.tron.api.GrpcAPI.NumberMessage.Builder.class); + } + + public static final int NUM_FIELD_NUMBER = 1; + private long num_; + /** + * int64 num = 1; + */ + public long getNum() { + return num_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (num_ != 0L) { + output.writeInt64(1, num_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (num_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, num_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.NumberMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.NumberMessage other = (org.tron.api.GrpcAPI.NumberMessage) obj; + + boolean result = true; + result = result && (getNum() + == other.getNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNum()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NumberMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.NumberMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.NumberMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.NumberMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.NumberMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NumberMessage) + org.tron.api.GrpcAPI.NumberMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_NumberMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_NumberMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.NumberMessage.class, org.tron.api.GrpcAPI.NumberMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.NumberMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + num_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_NumberMessage_descriptor; + } + + public org.tron.api.GrpcAPI.NumberMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.NumberMessage build() { + org.tron.api.GrpcAPI.NumberMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.NumberMessage buildPartial() { + org.tron.api.GrpcAPI.NumberMessage result = new org.tron.api.GrpcAPI.NumberMessage(this); + result.num_ = num_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.NumberMessage) { + return mergeFrom((org.tron.api.GrpcAPI.NumberMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.NumberMessage other) { + if (other == org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance()) return this; + if (other.getNum() != 0L) { + setNum(other.getNum()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.NumberMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.NumberMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long num_ ; + /** + * int64 num = 1; + */ + public long getNum() { + return num_; + } + /** + * int64 num = 1; + */ + public Builder setNum(long value) { + + num_ = value; + onChanged(); + return this; + } + /** + * int64 num = 1; + */ + public Builder clearNum() { + + num_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NumberMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.NumberMessage) + private static final org.tron.api.GrpcAPI.NumberMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.NumberMessage(); + } + + public static org.tron.api.GrpcAPI.NumberMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public NumberMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NumberMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.NumberMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BytesMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BytesMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes value = 1; + */ + com.google.protobuf.ByteString getValue(); + } + /** + * Protobuf type {@code protocol.BytesMessage} + */ + public static final class BytesMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BytesMessage) + BytesMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use BytesMessage.newBuilder() to construct. + private BytesMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BytesMessage() { + value_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BytesMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + value_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BytesMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BytesMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BytesMessage.class, org.tron.api.GrpcAPI.BytesMessage.Builder.class); + } + + public static final int VALUE_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString value_; + /** + * bytes value = 1; + */ + public com.google.protobuf.ByteString getValue() { + return value_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!value_.isEmpty()) { + output.writeBytes(1, value_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!value_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, value_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.BytesMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.BytesMessage other = (org.tron.api.GrpcAPI.BytesMessage) obj; + + boolean result = true; + result = result && getValue() + .equals(other.getValue()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BytesMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BytesMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BytesMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.BytesMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BytesMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BytesMessage) + org.tron.api.GrpcAPI.BytesMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BytesMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BytesMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BytesMessage.class, org.tron.api.GrpcAPI.BytesMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.BytesMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + value_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_BytesMessage_descriptor; + } + + public org.tron.api.GrpcAPI.BytesMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.BytesMessage build() { + org.tron.api.GrpcAPI.BytesMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.BytesMessage buildPartial() { + org.tron.api.GrpcAPI.BytesMessage result = new org.tron.api.GrpcAPI.BytesMessage(this); + result.value_ = value_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.BytesMessage) { + return mergeFrom((org.tron.api.GrpcAPI.BytesMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.BytesMessage other) { + if (other == org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance()) return this; + if (other.getValue() != com.google.protobuf.ByteString.EMPTY) { + setValue(other.getValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.BytesMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.BytesMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString value_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes value = 1; + */ + public com.google.protobuf.ByteString getValue() { + return value_; + } + /** + * bytes value = 1; + */ + public Builder setValue(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + value_ = value; + onChanged(); + return this; + } + /** + * bytes value = 1; + */ + public Builder clearValue() { + + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BytesMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.BytesMessage) + private static final org.tron.api.GrpcAPI.BytesMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.BytesMessage(); + } + + public static org.tron.api.GrpcAPI.BytesMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BytesMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BytesMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.BytesMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TimeMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TimeMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 beginInMilliseconds = 1; + */ + long getBeginInMilliseconds(); + + /** + * int64 endInMilliseconds = 2; + */ + long getEndInMilliseconds(); + } + /** + * Protobuf type {@code protocol.TimeMessage} + */ + public static final class TimeMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TimeMessage) + TimeMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use TimeMessage.newBuilder() to construct. + private TimeMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TimeMessage() { + beginInMilliseconds_ = 0L; + endInMilliseconds_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TimeMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + beginInMilliseconds_ = input.readInt64(); + break; + } + case 16: { + + endInMilliseconds_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimeMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimeMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TimeMessage.class, org.tron.api.GrpcAPI.TimeMessage.Builder.class); + } + + public static final int BEGININMILLISECONDS_FIELD_NUMBER = 1; + private long beginInMilliseconds_; + /** + * int64 beginInMilliseconds = 1; + */ + public long getBeginInMilliseconds() { + return beginInMilliseconds_; + } + + public static final int ENDINMILLISECONDS_FIELD_NUMBER = 2; + private long endInMilliseconds_; + /** + * int64 endInMilliseconds = 2; + */ + public long getEndInMilliseconds() { + return endInMilliseconds_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (beginInMilliseconds_ != 0L) { + output.writeInt64(1, beginInMilliseconds_); + } + if (endInMilliseconds_ != 0L) { + output.writeInt64(2, endInMilliseconds_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (beginInMilliseconds_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, beginInMilliseconds_); + } + if (endInMilliseconds_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, endInMilliseconds_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TimeMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TimeMessage other = (org.tron.api.GrpcAPI.TimeMessage) obj; + + boolean result = true; + result = result && (getBeginInMilliseconds() + == other.getBeginInMilliseconds()); + result = result && (getEndInMilliseconds() + == other.getEndInMilliseconds()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BEGININMILLISECONDS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBeginInMilliseconds()); + hash = (37 * hash) + ENDINMILLISECONDS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEndInMilliseconds()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimeMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TimeMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TimeMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TimeMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TimeMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TimeMessage) + org.tron.api.GrpcAPI.TimeMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimeMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimeMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TimeMessage.class, org.tron.api.GrpcAPI.TimeMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TimeMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + beginInMilliseconds_ = 0L; + + endInMilliseconds_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimeMessage_descriptor; + } + + public org.tron.api.GrpcAPI.TimeMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TimeMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TimeMessage build() { + org.tron.api.GrpcAPI.TimeMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TimeMessage buildPartial() { + org.tron.api.GrpcAPI.TimeMessage result = new org.tron.api.GrpcAPI.TimeMessage(this); + result.beginInMilliseconds_ = beginInMilliseconds_; + result.endInMilliseconds_ = endInMilliseconds_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TimeMessage) { + return mergeFrom((org.tron.api.GrpcAPI.TimeMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TimeMessage other) { + if (other == org.tron.api.GrpcAPI.TimeMessage.getDefaultInstance()) return this; + if (other.getBeginInMilliseconds() != 0L) { + setBeginInMilliseconds(other.getBeginInMilliseconds()); + } + if (other.getEndInMilliseconds() != 0L) { + setEndInMilliseconds(other.getEndInMilliseconds()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TimeMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TimeMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long beginInMilliseconds_ ; + /** + * int64 beginInMilliseconds = 1; + */ + public long getBeginInMilliseconds() { + return beginInMilliseconds_; + } + /** + * int64 beginInMilliseconds = 1; + */ + public Builder setBeginInMilliseconds(long value) { + + beginInMilliseconds_ = value; + onChanged(); + return this; + } + /** + * int64 beginInMilliseconds = 1; + */ + public Builder clearBeginInMilliseconds() { + + beginInMilliseconds_ = 0L; + onChanged(); + return this; + } + + private long endInMilliseconds_ ; + /** + * int64 endInMilliseconds = 2; + */ + public long getEndInMilliseconds() { + return endInMilliseconds_; + } + /** + * int64 endInMilliseconds = 2; + */ + public Builder setEndInMilliseconds(long value) { + + endInMilliseconds_ = value; + onChanged(); + return this; + } + /** + * int64 endInMilliseconds = 2; + */ + public Builder clearEndInMilliseconds() { + + endInMilliseconds_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TimeMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.TimeMessage) + private static final org.tron.api.GrpcAPI.TimeMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TimeMessage(); + } + + public static org.tron.api.GrpcAPI.TimeMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TimeMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TimeMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TimeMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockLimitOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockLimit) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 startNum = 1; + */ + long getStartNum(); + + /** + * int64 endNum = 2; + */ + long getEndNum(); + } + /** + * Protobuf type {@code protocol.BlockLimit} + */ + public static final class BlockLimit extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockLimit) + BlockLimitOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockLimit.newBuilder() to construct. + private BlockLimit(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockLimit() { + startNum_ = 0L; + endNum_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockLimit( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + startNum_ = input.readInt64(); + break; + } + case 16: { + + endNum_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockLimit_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockLimit_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockLimit.class, org.tron.api.GrpcAPI.BlockLimit.Builder.class); + } + + public static final int STARTNUM_FIELD_NUMBER = 1; + private long startNum_; + /** + * int64 startNum = 1; + */ + public long getStartNum() { + return startNum_; + } + + public static final int ENDNUM_FIELD_NUMBER = 2; + private long endNum_; + /** + * int64 endNum = 2; + */ + public long getEndNum() { + return endNum_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (startNum_ != 0L) { + output.writeInt64(1, startNum_); + } + if (endNum_ != 0L) { + output.writeInt64(2, endNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (startNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, startNum_); + } + if (endNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, endNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.BlockLimit)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.BlockLimit other = (org.tron.api.GrpcAPI.BlockLimit) obj; + + boolean result = true; + result = result && (getStartNum() + == other.getStartNum()); + result = result && (getEndNum() + == other.getEndNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + STARTNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getStartNum()); + hash = (37 * hash) + ENDNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEndNum()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockLimit parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockLimit parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockLimit parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.BlockLimit prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockLimit} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockLimit) + org.tron.api.GrpcAPI.BlockLimitOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockLimit_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockLimit_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockLimit.class, org.tron.api.GrpcAPI.BlockLimit.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.BlockLimit.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + startNum_ = 0L; + + endNum_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockLimit_descriptor; + } + + public org.tron.api.GrpcAPI.BlockLimit getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.BlockLimit.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.BlockLimit build() { + org.tron.api.GrpcAPI.BlockLimit result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.BlockLimit buildPartial() { + org.tron.api.GrpcAPI.BlockLimit result = new org.tron.api.GrpcAPI.BlockLimit(this); + result.startNum_ = startNum_; + result.endNum_ = endNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.BlockLimit) { + return mergeFrom((org.tron.api.GrpcAPI.BlockLimit)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.BlockLimit other) { + if (other == org.tron.api.GrpcAPI.BlockLimit.getDefaultInstance()) return this; + if (other.getStartNum() != 0L) { + setStartNum(other.getStartNum()); + } + if (other.getEndNum() != 0L) { + setEndNum(other.getEndNum()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.BlockLimit parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.BlockLimit) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long startNum_ ; + /** + * int64 startNum = 1; + */ + public long getStartNum() { + return startNum_; + } + /** + * int64 startNum = 1; + */ + public Builder setStartNum(long value) { + + startNum_ = value; + onChanged(); + return this; + } + /** + * int64 startNum = 1; + */ + public Builder clearStartNum() { + + startNum_ = 0L; + onChanged(); + return this; + } + + private long endNum_ ; + /** + * int64 endNum = 2; + */ + public long getEndNum() { + return endNum_; + } + /** + * int64 endNum = 2; + */ + public Builder setEndNum(long value) { + + endNum_ = value; + onChanged(); + return this; + } + /** + * int64 endNum = 2; + */ + public Builder clearEndNum() { + + endNum_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockLimit) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockLimit) + private static final org.tron.api.GrpcAPI.BlockLimit DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.BlockLimit(); + } + + public static org.tron.api.GrpcAPI.BlockLimit getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockLimit parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockLimit(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.BlockLimit getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionLimitOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionLimit) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes transactionId = 1; + */ + com.google.protobuf.ByteString getTransactionId(); + + /** + * int64 limitNum = 2; + */ + long getLimitNum(); + } + /** + * Protobuf type {@code protocol.TransactionLimit} + */ + public static final class TransactionLimit extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionLimit) + TransactionLimitOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionLimit.newBuilder() to construct. + private TransactionLimit(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionLimit() { + transactionId_ = com.google.protobuf.ByteString.EMPTY; + limitNum_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionLimit( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + transactionId_ = input.readBytes(); + break; + } + case 16: { + + limitNum_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionLimit_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionLimit_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionLimit.class, org.tron.api.GrpcAPI.TransactionLimit.Builder.class); + } + + public static final int TRANSACTIONID_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString transactionId_; + /** + * bytes transactionId = 1; + */ + public com.google.protobuf.ByteString getTransactionId() { + return transactionId_; + } + + public static final int LIMITNUM_FIELD_NUMBER = 2; + private long limitNum_; + /** + * int64 limitNum = 2; + */ + public long getLimitNum() { + return limitNum_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!transactionId_.isEmpty()) { + output.writeBytes(1, transactionId_); + } + if (limitNum_ != 0L) { + output.writeInt64(2, limitNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!transactionId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, transactionId_); + } + if (limitNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, limitNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionLimit)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionLimit other = (org.tron.api.GrpcAPI.TransactionLimit) obj; + + boolean result = true; + result = result && getTransactionId() + .equals(other.getTransactionId()); + result = result && (getLimitNum() + == other.getLimitNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRANSACTIONID_FIELD_NUMBER; + hash = (53 * hash) + getTransactionId().hashCode(); + hash = (37 * hash) + LIMITNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLimitNum()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionLimit parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionLimit prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionLimit} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionLimit) + org.tron.api.GrpcAPI.TransactionLimitOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionLimit_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionLimit_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionLimit.class, org.tron.api.GrpcAPI.TransactionLimit.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionLimit.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + transactionId_ = com.google.protobuf.ByteString.EMPTY; + + limitNum_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionLimit_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionLimit getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionLimit.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionLimit build() { + org.tron.api.GrpcAPI.TransactionLimit result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionLimit buildPartial() { + org.tron.api.GrpcAPI.TransactionLimit result = new org.tron.api.GrpcAPI.TransactionLimit(this); + result.transactionId_ = transactionId_; + result.limitNum_ = limitNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionLimit) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionLimit)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionLimit other) { + if (other == org.tron.api.GrpcAPI.TransactionLimit.getDefaultInstance()) return this; + if (other.getTransactionId() != com.google.protobuf.ByteString.EMPTY) { + setTransactionId(other.getTransactionId()); + } + if (other.getLimitNum() != 0L) { + setLimitNum(other.getLimitNum()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionLimit parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionLimit) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString transactionId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes transactionId = 1; + */ + public com.google.protobuf.ByteString getTransactionId() { + return transactionId_; + } + /** + * bytes transactionId = 1; + */ + public Builder setTransactionId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + transactionId_ = value; + onChanged(); + return this; + } + /** + * bytes transactionId = 1; + */ + public Builder clearTransactionId() { + + transactionId_ = getDefaultInstance().getTransactionId(); + onChanged(); + return this; + } + + private long limitNum_ ; + /** + * int64 limitNum = 2; + */ + public long getLimitNum() { + return limitNum_; + } + /** + * int64 limitNum = 2; + */ + public Builder setLimitNum(long value) { + + limitNum_ = value; + onChanged(); + return this; + } + /** + * int64 limitNum = 2; + */ + public Builder clearLimitNum() { + + limitNum_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionLimit) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionLimit) + private static final org.tron.api.GrpcAPI.TransactionLimit DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionLimit(); + } + + public static org.tron.api.GrpcAPI.TransactionLimit getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionLimit parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionLimit(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionLimit getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AccountPaginatedOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AccountPaginated) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Account account = 1; + */ + boolean hasAccount(); + /** + * .protocol.Account account = 1; + */ + org.tron.protos.Protocol.Account getAccount(); + /** + * .protocol.Account account = 1; + */ + org.tron.protos.Protocol.AccountOrBuilder getAccountOrBuilder(); + + /** + * int64 offset = 2; + */ + long getOffset(); + + /** + * int64 limit = 3; + */ + long getLimit(); + } + /** + * Protobuf type {@code protocol.AccountPaginated} + */ + public static final class AccountPaginated extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AccountPaginated) + AccountPaginatedOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountPaginated.newBuilder() to construct. + private AccountPaginated(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountPaginated() { + offset_ = 0L; + limit_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountPaginated( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.Account.Builder subBuilder = null; + if (account_ != null) { + subBuilder = account_.toBuilder(); + } + account_ = input.readMessage(org.tron.protos.Protocol.Account.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(account_); + account_ = subBuilder.buildPartial(); + } + + break; + } + case 16: { + + offset_ = input.readInt64(); + break; + } + case 24: { + + limit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountPaginated_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountPaginated_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AccountPaginated.class, org.tron.api.GrpcAPI.AccountPaginated.Builder.class); + } + + public static final int ACCOUNT_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.Account account_; + /** + * .protocol.Account account = 1; + */ + public boolean hasAccount() { + return account_ != null; + } + /** + * .protocol.Account account = 1; + */ + public org.tron.protos.Protocol.Account getAccount() { + return account_ == null ? org.tron.protos.Protocol.Account.getDefaultInstance() : account_; + } + /** + * .protocol.Account account = 1; + */ + public org.tron.protos.Protocol.AccountOrBuilder getAccountOrBuilder() { + return getAccount(); + } + + public static final int OFFSET_FIELD_NUMBER = 2; + private long offset_; + /** + * int64 offset = 2; + */ + public long getOffset() { + return offset_; + } + + public static final int LIMIT_FIELD_NUMBER = 3; + private long limit_; + /** + * int64 limit = 3; + */ + public long getLimit() { + return limit_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (account_ != null) { + output.writeMessage(1, getAccount()); + } + if (offset_ != 0L) { + output.writeInt64(2, offset_); + } + if (limit_ != 0L) { + output.writeInt64(3, limit_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (account_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getAccount()); + } + if (offset_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, offset_); + } + if (limit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, limit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.AccountPaginated)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.AccountPaginated other = (org.tron.api.GrpcAPI.AccountPaginated) obj; + + boolean result = true; + result = result && (hasAccount() == other.hasAccount()); + if (hasAccount()) { + result = result && getAccount() + .equals(other.getAccount()); + } + result = result && (getOffset() + == other.getOffset()); + result = result && (getLimit() + == other.getLimit()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasAccount()) { + hash = (37 * hash) + ACCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getAccount().hashCode(); + } + hash = (37 * hash) + OFFSET_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOffset()); + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLimit()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountPaginated parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.AccountPaginated prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AccountPaginated} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AccountPaginated) + org.tron.api.GrpcAPI.AccountPaginatedOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountPaginated_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountPaginated_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AccountPaginated.class, org.tron.api.GrpcAPI.AccountPaginated.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.AccountPaginated.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (accountBuilder_ == null) { + account_ = null; + } else { + account_ = null; + accountBuilder_ = null; + } + offset_ = 0L; + + limit_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountPaginated_descriptor; + } + + public org.tron.api.GrpcAPI.AccountPaginated getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.AccountPaginated.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.AccountPaginated build() { + org.tron.api.GrpcAPI.AccountPaginated result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.AccountPaginated buildPartial() { + org.tron.api.GrpcAPI.AccountPaginated result = new org.tron.api.GrpcAPI.AccountPaginated(this); + if (accountBuilder_ == null) { + result.account_ = account_; + } else { + result.account_ = accountBuilder_.build(); + } + result.offset_ = offset_; + result.limit_ = limit_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.AccountPaginated) { + return mergeFrom((org.tron.api.GrpcAPI.AccountPaginated)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.AccountPaginated other) { + if (other == org.tron.api.GrpcAPI.AccountPaginated.getDefaultInstance()) return this; + if (other.hasAccount()) { + mergeAccount(other.getAccount()); + } + if (other.getOffset() != 0L) { + setOffset(other.getOffset()); + } + if (other.getLimit() != 0L) { + setLimit(other.getLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.AccountPaginated parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.AccountPaginated) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Protocol.Account account_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account, org.tron.protos.Protocol.Account.Builder, org.tron.protos.Protocol.AccountOrBuilder> accountBuilder_; + /** + * .protocol.Account account = 1; + */ + public boolean hasAccount() { + return accountBuilder_ != null || account_ != null; + } + /** + * .protocol.Account account = 1; + */ + public org.tron.protos.Protocol.Account getAccount() { + if (accountBuilder_ == null) { + return account_ == null ? org.tron.protos.Protocol.Account.getDefaultInstance() : account_; + } else { + return accountBuilder_.getMessage(); + } + } + /** + * .protocol.Account account = 1; + */ + public Builder setAccount(org.tron.protos.Protocol.Account value) { + if (accountBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + account_ = value; + onChanged(); + } else { + accountBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Account account = 1; + */ + public Builder setAccount( + org.tron.protos.Protocol.Account.Builder builderForValue) { + if (accountBuilder_ == null) { + account_ = builderForValue.build(); + onChanged(); + } else { + accountBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Account account = 1; + */ + public Builder mergeAccount(org.tron.protos.Protocol.Account value) { + if (accountBuilder_ == null) { + if (account_ != null) { + account_ = + org.tron.protos.Protocol.Account.newBuilder(account_).mergeFrom(value).buildPartial(); + } else { + account_ = value; + } + onChanged(); + } else { + accountBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Account account = 1; + */ + public Builder clearAccount() { + if (accountBuilder_ == null) { + account_ = null; + onChanged(); + } else { + account_ = null; + accountBuilder_ = null; + } + + return this; + } + /** + * .protocol.Account account = 1; + */ + public org.tron.protos.Protocol.Account.Builder getAccountBuilder() { + + onChanged(); + return getAccountFieldBuilder().getBuilder(); + } + /** + * .protocol.Account account = 1; + */ + public org.tron.protos.Protocol.AccountOrBuilder getAccountOrBuilder() { + if (accountBuilder_ != null) { + return accountBuilder_.getMessageOrBuilder(); + } else { + return account_ == null ? + org.tron.protos.Protocol.Account.getDefaultInstance() : account_; + } + } + /** + * .protocol.Account account = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account, org.tron.protos.Protocol.Account.Builder, org.tron.protos.Protocol.AccountOrBuilder> + getAccountFieldBuilder() { + if (accountBuilder_ == null) { + accountBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account, org.tron.protos.Protocol.Account.Builder, org.tron.protos.Protocol.AccountOrBuilder>( + getAccount(), + getParentForChildren(), + isClean()); + account_ = null; + } + return accountBuilder_; + } + + private long offset_ ; + /** + * int64 offset = 2; + */ + public long getOffset() { + return offset_; + } + /** + * int64 offset = 2; + */ + public Builder setOffset(long value) { + + offset_ = value; + onChanged(); + return this; + } + /** + * int64 offset = 2; + */ + public Builder clearOffset() { + + offset_ = 0L; + onChanged(); + return this; + } + + private long limit_ ; + /** + * int64 limit = 3; + */ + public long getLimit() { + return limit_; + } + /** + * int64 limit = 3; + */ + public Builder setLimit(long value) { + + limit_ = value; + onChanged(); + return this; + } + /** + * int64 limit = 3; + */ + public Builder clearLimit() { + + limit_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AccountPaginated) + } + + // @@protoc_insertion_point(class_scope:protocol.AccountPaginated) + private static final org.tron.api.GrpcAPI.AccountPaginated DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.AccountPaginated(); + } + + public static org.tron.api.GrpcAPI.AccountPaginated getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountPaginated parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountPaginated(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.AccountPaginated getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TimePaginatedMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TimePaginatedMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.TimeMessage timeMessage = 1; + */ + boolean hasTimeMessage(); + /** + * .protocol.TimeMessage timeMessage = 1; + */ + org.tron.api.GrpcAPI.TimeMessage getTimeMessage(); + /** + * .protocol.TimeMessage timeMessage = 1; + */ + org.tron.api.GrpcAPI.TimeMessageOrBuilder getTimeMessageOrBuilder(); + + /** + * int64 offset = 2; + */ + long getOffset(); + + /** + * int64 limit = 3; + */ + long getLimit(); + } + /** + * Protobuf type {@code protocol.TimePaginatedMessage} + */ + public static final class TimePaginatedMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TimePaginatedMessage) + TimePaginatedMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use TimePaginatedMessage.newBuilder() to construct. + private TimePaginatedMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TimePaginatedMessage() { + offset_ = 0L; + limit_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TimePaginatedMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.api.GrpcAPI.TimeMessage.Builder subBuilder = null; + if (timeMessage_ != null) { + subBuilder = timeMessage_.toBuilder(); + } + timeMessage_ = input.readMessage(org.tron.api.GrpcAPI.TimeMessage.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(timeMessage_); + timeMessage_ = subBuilder.buildPartial(); + } + + break; + } + case 16: { + + offset_ = input.readInt64(); + break; + } + case 24: { + + limit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimePaginatedMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimePaginatedMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TimePaginatedMessage.class, org.tron.api.GrpcAPI.TimePaginatedMessage.Builder.class); + } + + public static final int TIMEMESSAGE_FIELD_NUMBER = 1; + private org.tron.api.GrpcAPI.TimeMessage timeMessage_; + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public boolean hasTimeMessage() { + return timeMessage_ != null; + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public org.tron.api.GrpcAPI.TimeMessage getTimeMessage() { + return timeMessage_ == null ? org.tron.api.GrpcAPI.TimeMessage.getDefaultInstance() : timeMessage_; + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public org.tron.api.GrpcAPI.TimeMessageOrBuilder getTimeMessageOrBuilder() { + return getTimeMessage(); + } + + public static final int OFFSET_FIELD_NUMBER = 2; + private long offset_; + /** + * int64 offset = 2; + */ + public long getOffset() { + return offset_; + } + + public static final int LIMIT_FIELD_NUMBER = 3; + private long limit_; + /** + * int64 limit = 3; + */ + public long getLimit() { + return limit_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (timeMessage_ != null) { + output.writeMessage(1, getTimeMessage()); + } + if (offset_ != 0L) { + output.writeInt64(2, offset_); + } + if (limit_ != 0L) { + output.writeInt64(3, limit_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (timeMessage_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getTimeMessage()); + } + if (offset_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, offset_); + } + if (limit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, limit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TimePaginatedMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TimePaginatedMessage other = (org.tron.api.GrpcAPI.TimePaginatedMessage) obj; + + boolean result = true; + result = result && (hasTimeMessage() == other.hasTimeMessage()); + if (hasTimeMessage()) { + result = result && getTimeMessage() + .equals(other.getTimeMessage()); + } + result = result && (getOffset() + == other.getOffset()); + result = result && (getLimit() + == other.getLimit()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasTimeMessage()) { + hash = (37 * hash) + TIMEMESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getTimeMessage().hashCode(); + } + hash = (37 * hash) + OFFSET_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOffset()); + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLimit()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TimePaginatedMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TimePaginatedMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TimePaginatedMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TimePaginatedMessage) + org.tron.api.GrpcAPI.TimePaginatedMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimePaginatedMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimePaginatedMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TimePaginatedMessage.class, org.tron.api.GrpcAPI.TimePaginatedMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TimePaginatedMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (timeMessageBuilder_ == null) { + timeMessage_ = null; + } else { + timeMessage_ = null; + timeMessageBuilder_ = null; + } + offset_ = 0L; + + limit_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TimePaginatedMessage_descriptor; + } + + public org.tron.api.GrpcAPI.TimePaginatedMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TimePaginatedMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TimePaginatedMessage build() { + org.tron.api.GrpcAPI.TimePaginatedMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TimePaginatedMessage buildPartial() { + org.tron.api.GrpcAPI.TimePaginatedMessage result = new org.tron.api.GrpcAPI.TimePaginatedMessage(this); + if (timeMessageBuilder_ == null) { + result.timeMessage_ = timeMessage_; + } else { + result.timeMessage_ = timeMessageBuilder_.build(); + } + result.offset_ = offset_; + result.limit_ = limit_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TimePaginatedMessage) { + return mergeFrom((org.tron.api.GrpcAPI.TimePaginatedMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TimePaginatedMessage other) { + if (other == org.tron.api.GrpcAPI.TimePaginatedMessage.getDefaultInstance()) return this; + if (other.hasTimeMessage()) { + mergeTimeMessage(other.getTimeMessage()); + } + if (other.getOffset() != 0L) { + setOffset(other.getOffset()); + } + if (other.getLimit() != 0L) { + setLimit(other.getLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TimePaginatedMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TimePaginatedMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.api.GrpcAPI.TimeMessage timeMessage_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TimeMessage, org.tron.api.GrpcAPI.TimeMessage.Builder, org.tron.api.GrpcAPI.TimeMessageOrBuilder> timeMessageBuilder_; + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public boolean hasTimeMessage() { + return timeMessageBuilder_ != null || timeMessage_ != null; + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public org.tron.api.GrpcAPI.TimeMessage getTimeMessage() { + if (timeMessageBuilder_ == null) { + return timeMessage_ == null ? org.tron.api.GrpcAPI.TimeMessage.getDefaultInstance() : timeMessage_; + } else { + return timeMessageBuilder_.getMessage(); + } + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public Builder setTimeMessage(org.tron.api.GrpcAPI.TimeMessage value) { + if (timeMessageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + timeMessage_ = value; + onChanged(); + } else { + timeMessageBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public Builder setTimeMessage( + org.tron.api.GrpcAPI.TimeMessage.Builder builderForValue) { + if (timeMessageBuilder_ == null) { + timeMessage_ = builderForValue.build(); + onChanged(); + } else { + timeMessageBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public Builder mergeTimeMessage(org.tron.api.GrpcAPI.TimeMessage value) { + if (timeMessageBuilder_ == null) { + if (timeMessage_ != null) { + timeMessage_ = + org.tron.api.GrpcAPI.TimeMessage.newBuilder(timeMessage_).mergeFrom(value).buildPartial(); + } else { + timeMessage_ = value; + } + onChanged(); + } else { + timeMessageBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public Builder clearTimeMessage() { + if (timeMessageBuilder_ == null) { + timeMessage_ = null; + onChanged(); + } else { + timeMessage_ = null; + timeMessageBuilder_ = null; + } + + return this; + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public org.tron.api.GrpcAPI.TimeMessage.Builder getTimeMessageBuilder() { + + onChanged(); + return getTimeMessageFieldBuilder().getBuilder(); + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + public org.tron.api.GrpcAPI.TimeMessageOrBuilder getTimeMessageOrBuilder() { + if (timeMessageBuilder_ != null) { + return timeMessageBuilder_.getMessageOrBuilder(); + } else { + return timeMessage_ == null ? + org.tron.api.GrpcAPI.TimeMessage.getDefaultInstance() : timeMessage_; + } + } + /** + * .protocol.TimeMessage timeMessage = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TimeMessage, org.tron.api.GrpcAPI.TimeMessage.Builder, org.tron.api.GrpcAPI.TimeMessageOrBuilder> + getTimeMessageFieldBuilder() { + if (timeMessageBuilder_ == null) { + timeMessageBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TimeMessage, org.tron.api.GrpcAPI.TimeMessage.Builder, org.tron.api.GrpcAPI.TimeMessageOrBuilder>( + getTimeMessage(), + getParentForChildren(), + isClean()); + timeMessage_ = null; + } + return timeMessageBuilder_; + } + + private long offset_ ; + /** + * int64 offset = 2; + */ + public long getOffset() { + return offset_; + } + /** + * int64 offset = 2; + */ + public Builder setOffset(long value) { + + offset_ = value; + onChanged(); + return this; + } + /** + * int64 offset = 2; + */ + public Builder clearOffset() { + + offset_ = 0L; + onChanged(); + return this; + } + + private long limit_ ; + /** + * int64 limit = 3; + */ + public long getLimit() { + return limit_; + } + /** + * int64 limit = 3; + */ + public Builder setLimit(long value) { + + limit_ = value; + onChanged(); + return this; + } + /** + * int64 limit = 3; + */ + public Builder clearLimit() { + + limit_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TimePaginatedMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.TimePaginatedMessage) + private static final org.tron.api.GrpcAPI.TimePaginatedMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TimePaginatedMessage(); + } + + public static org.tron.api.GrpcAPI.TimePaginatedMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TimePaginatedMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TimePaginatedMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TimePaginatedMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AccountNetMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AccountNetMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 freeNetUsed = 1; + */ + long getFreeNetUsed(); + + /** + * int64 freeNetLimit = 2; + */ + long getFreeNetLimit(); + + /** + * int64 NetUsed = 3; + */ + long getNetUsed(); + + /** + * int64 NetLimit = 4; + */ + long getNetLimit(); + + /** + * map<string, int64> assetNetUsed = 5; + */ + int getAssetNetUsedCount(); + /** + * map<string, int64> assetNetUsed = 5; + */ + boolean containsAssetNetUsed( + java.lang.String key); + /** + * Use {@link #getAssetNetUsedMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getAssetNetUsed(); + /** + * map<string, int64> assetNetUsed = 5; + */ + java.util.Map + getAssetNetUsedMap(); + /** + * map<string, int64> assetNetUsed = 5; + */ + + long getAssetNetUsedOrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> assetNetUsed = 5; + */ + + long getAssetNetUsedOrThrow( + java.lang.String key); + + /** + * map<string, int64> assetNetLimit = 6; + */ + int getAssetNetLimitCount(); + /** + * map<string, int64> assetNetLimit = 6; + */ + boolean containsAssetNetLimit( + java.lang.String key); + /** + * Use {@link #getAssetNetLimitMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getAssetNetLimit(); + /** + * map<string, int64> assetNetLimit = 6; + */ + java.util.Map + getAssetNetLimitMap(); + /** + * map<string, int64> assetNetLimit = 6; + */ + + long getAssetNetLimitOrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> assetNetLimit = 6; + */ + + long getAssetNetLimitOrThrow( + java.lang.String key); + + /** + * int64 TotalNetLimit = 7; + */ + long getTotalNetLimit(); + + /** + * int64 TotalNetWeight = 8; + */ + long getTotalNetWeight(); + } + /** + *
+   *deprecated
+   * 
+ * + * Protobuf type {@code protocol.AccountNetMessage} + */ + public static final class AccountNetMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AccountNetMessage) + AccountNetMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountNetMessage.newBuilder() to construct. + private AccountNetMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountNetMessage() { + freeNetUsed_ = 0L; + freeNetLimit_ = 0L; + netUsed_ = 0L; + netLimit_ = 0L; + totalNetLimit_ = 0L; + totalNetWeight_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountNetMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + freeNetUsed_ = input.readInt64(); + break; + } + case 16: { + + freeNetLimit_ = input.readInt64(); + break; + } + case 24: { + + netUsed_ = input.readInt64(); + break; + } + case 32: { + + netLimit_ = input.readInt64(); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + assetNetUsed_ = com.google.protobuf.MapField.newMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000010; + } + com.google.protobuf.MapEntry + assetNetUsed__ = input.readMessage( + AssetNetUsedDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + assetNetUsed_.getMutableMap().put( + assetNetUsed__.getKey(), assetNetUsed__.getValue()); + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + assetNetLimit_ = com.google.protobuf.MapField.newMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000020; + } + com.google.protobuf.MapEntry + assetNetLimit__ = input.readMessage( + AssetNetLimitDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + assetNetLimit_.getMutableMap().put( + assetNetLimit__.getKey(), assetNetLimit__.getValue()); + break; + } + case 56: { + + totalNetLimit_ = input.readInt64(); + break; + } + case 64: { + + totalNetWeight_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountNetMessage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 5: + return internalGetAssetNetUsed(); + case 6: + return internalGetAssetNetLimit(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountNetMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AccountNetMessage.class, org.tron.api.GrpcAPI.AccountNetMessage.Builder.class); + } + + private int bitField0_; + public static final int FREENETUSED_FIELD_NUMBER = 1; + private long freeNetUsed_; + /** + * int64 freeNetUsed = 1; + */ + public long getFreeNetUsed() { + return freeNetUsed_; + } + + public static final int FREENETLIMIT_FIELD_NUMBER = 2; + private long freeNetLimit_; + /** + * int64 freeNetLimit = 2; + */ + public long getFreeNetLimit() { + return freeNetLimit_; + } + + public static final int NETUSED_FIELD_NUMBER = 3; + private long netUsed_; + /** + * int64 NetUsed = 3; + */ + public long getNetUsed() { + return netUsed_; + } + + public static final int NETLIMIT_FIELD_NUMBER = 4; + private long netLimit_; + /** + * int64 NetLimit = 4; + */ + public long getNetLimit() { + return netLimit_; + } + + public static final int ASSETNETUSED_FIELD_NUMBER = 5; + private static final class AssetNetUsedDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.api.GrpcAPI.internal_static_protocol_AccountNetMessage_AssetNetUsedEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetUsed_; + private com.google.protobuf.MapField + internalGetAssetNetUsed() { + if (assetNetUsed_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + } + return assetNetUsed_; + } + + public int getAssetNetUsedCount() { + return internalGetAssetNetUsed().getMap().size(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public boolean containsAssetNetUsed( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetUsed().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetUsedMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetUsed() { + return getAssetNetUsedMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public java.util.Map getAssetNetUsedMap() { + return internalGetAssetNetUsed().getMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int ASSETNETLIMIT_FIELD_NUMBER = 6; + private static final class AssetNetLimitDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.api.GrpcAPI.internal_static_protocol_AccountNetMessage_AssetNetLimitEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetLimit_; + private com.google.protobuf.MapField + internalGetAssetNetLimit() { + if (assetNetLimit_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + } + return assetNetLimit_; + } + + public int getAssetNetLimitCount() { + return internalGetAssetNetLimit().getMap().size(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public boolean containsAssetNetLimit( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetLimit().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetLimitMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetLimit() { + return getAssetNetLimitMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public java.util.Map getAssetNetLimitMap() { + return internalGetAssetNetLimit().getMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int TOTALNETLIMIT_FIELD_NUMBER = 7; + private long totalNetLimit_; + /** + * int64 TotalNetLimit = 7; + */ + public long getTotalNetLimit() { + return totalNetLimit_; + } + + public static final int TOTALNETWEIGHT_FIELD_NUMBER = 8; + private long totalNetWeight_; + /** + * int64 TotalNetWeight = 8; + */ + public long getTotalNetWeight() { + return totalNetWeight_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (freeNetUsed_ != 0L) { + output.writeInt64(1, freeNetUsed_); + } + if (freeNetLimit_ != 0L) { + output.writeInt64(2, freeNetLimit_); + } + if (netUsed_ != 0L) { + output.writeInt64(3, netUsed_); + } + if (netLimit_ != 0L) { + output.writeInt64(4, netLimit_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetAssetNetUsed(), + AssetNetUsedDefaultEntryHolder.defaultEntry, + 5); + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetAssetNetLimit(), + AssetNetLimitDefaultEntryHolder.defaultEntry, + 6); + if (totalNetLimit_ != 0L) { + output.writeInt64(7, totalNetLimit_); + } + if (totalNetWeight_ != 0L) { + output.writeInt64(8, totalNetWeight_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (freeNetUsed_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, freeNetUsed_); + } + if (freeNetLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, freeNetLimit_); + } + if (netUsed_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, netUsed_); + } + if (netLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, netLimit_); + } + for (java.util.Map.Entry entry + : internalGetAssetNetUsed().getMap().entrySet()) { + com.google.protobuf.MapEntry + assetNetUsed__ = AssetNetUsedDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, assetNetUsed__); + } + for (java.util.Map.Entry entry + : internalGetAssetNetLimit().getMap().entrySet()) { + com.google.protobuf.MapEntry + assetNetLimit__ = AssetNetLimitDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, assetNetLimit__); + } + if (totalNetLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, totalNetLimit_); + } + if (totalNetWeight_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, totalNetWeight_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.AccountNetMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.AccountNetMessage other = (org.tron.api.GrpcAPI.AccountNetMessage) obj; + + boolean result = true; + result = result && (getFreeNetUsed() + == other.getFreeNetUsed()); + result = result && (getFreeNetLimit() + == other.getFreeNetLimit()); + result = result && (getNetUsed() + == other.getNetUsed()); + result = result && (getNetLimit() + == other.getNetLimit()); + result = result && internalGetAssetNetUsed().equals( + other.internalGetAssetNetUsed()); + result = result && internalGetAssetNetLimit().equals( + other.internalGetAssetNetLimit()); + result = result && (getTotalNetLimit() + == other.getTotalNetLimit()); + result = result && (getTotalNetWeight() + == other.getTotalNetWeight()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FREENETUSED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFreeNetUsed()); + hash = (37 * hash) + FREENETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFreeNetLimit()); + hash = (37 * hash) + NETUSED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNetUsed()); + hash = (37 * hash) + NETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNetLimit()); + if (!internalGetAssetNetUsed().getMap().isEmpty()) { + hash = (37 * hash) + ASSETNETUSED_FIELD_NUMBER; + hash = (53 * hash) + internalGetAssetNetUsed().hashCode(); + } + if (!internalGetAssetNetLimit().getMap().isEmpty()) { + hash = (37 * hash) + ASSETNETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + internalGetAssetNetLimit().hashCode(); + } + hash = (37 * hash) + TOTALNETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalNetLimit()); + hash = (37 * hash) + TOTALNETWEIGHT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalNetWeight()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountNetMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.AccountNetMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     *deprecated
+     * 
+ * + * Protobuf type {@code protocol.AccountNetMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AccountNetMessage) + org.tron.api.GrpcAPI.AccountNetMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountNetMessage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 5: + return internalGetAssetNetUsed(); + case 6: + return internalGetAssetNetLimit(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 5: + return internalGetMutableAssetNetUsed(); + case 6: + return internalGetMutableAssetNetLimit(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountNetMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AccountNetMessage.class, org.tron.api.GrpcAPI.AccountNetMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.AccountNetMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + freeNetUsed_ = 0L; + + freeNetLimit_ = 0L; + + netUsed_ = 0L; + + netLimit_ = 0L; + + internalGetMutableAssetNetUsed().clear(); + internalGetMutableAssetNetLimit().clear(); + totalNetLimit_ = 0L; + + totalNetWeight_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountNetMessage_descriptor; + } + + public org.tron.api.GrpcAPI.AccountNetMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.AccountNetMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.AccountNetMessage build() { + org.tron.api.GrpcAPI.AccountNetMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.AccountNetMessage buildPartial() { + org.tron.api.GrpcAPI.AccountNetMessage result = new org.tron.api.GrpcAPI.AccountNetMessage(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.freeNetUsed_ = freeNetUsed_; + result.freeNetLimit_ = freeNetLimit_; + result.netUsed_ = netUsed_; + result.netLimit_ = netLimit_; + result.assetNetUsed_ = internalGetAssetNetUsed(); + result.assetNetUsed_.makeImmutable(); + result.assetNetLimit_ = internalGetAssetNetLimit(); + result.assetNetLimit_.makeImmutable(); + result.totalNetLimit_ = totalNetLimit_; + result.totalNetWeight_ = totalNetWeight_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.AccountNetMessage) { + return mergeFrom((org.tron.api.GrpcAPI.AccountNetMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.AccountNetMessage other) { + if (other == org.tron.api.GrpcAPI.AccountNetMessage.getDefaultInstance()) return this; + if (other.getFreeNetUsed() != 0L) { + setFreeNetUsed(other.getFreeNetUsed()); + } + if (other.getFreeNetLimit() != 0L) { + setFreeNetLimit(other.getFreeNetLimit()); + } + if (other.getNetUsed() != 0L) { + setNetUsed(other.getNetUsed()); + } + if (other.getNetLimit() != 0L) { + setNetLimit(other.getNetLimit()); + } + internalGetMutableAssetNetUsed().mergeFrom( + other.internalGetAssetNetUsed()); + internalGetMutableAssetNetLimit().mergeFrom( + other.internalGetAssetNetLimit()); + if (other.getTotalNetLimit() != 0L) { + setTotalNetLimit(other.getTotalNetLimit()); + } + if (other.getTotalNetWeight() != 0L) { + setTotalNetWeight(other.getTotalNetWeight()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.AccountNetMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.AccountNetMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long freeNetUsed_ ; + /** + * int64 freeNetUsed = 1; + */ + public long getFreeNetUsed() { + return freeNetUsed_; + } + /** + * int64 freeNetUsed = 1; + */ + public Builder setFreeNetUsed(long value) { + + freeNetUsed_ = value; + onChanged(); + return this; + } + /** + * int64 freeNetUsed = 1; + */ + public Builder clearFreeNetUsed() { + + freeNetUsed_ = 0L; + onChanged(); + return this; + } + + private long freeNetLimit_ ; + /** + * int64 freeNetLimit = 2; + */ + public long getFreeNetLimit() { + return freeNetLimit_; + } + /** + * int64 freeNetLimit = 2; + */ + public Builder setFreeNetLimit(long value) { + + freeNetLimit_ = value; + onChanged(); + return this; + } + /** + * int64 freeNetLimit = 2; + */ + public Builder clearFreeNetLimit() { + + freeNetLimit_ = 0L; + onChanged(); + return this; + } + + private long netUsed_ ; + /** + * int64 NetUsed = 3; + */ + public long getNetUsed() { + return netUsed_; + } + /** + * int64 NetUsed = 3; + */ + public Builder setNetUsed(long value) { + + netUsed_ = value; + onChanged(); + return this; + } + /** + * int64 NetUsed = 3; + */ + public Builder clearNetUsed() { + + netUsed_ = 0L; + onChanged(); + return this; + } + + private long netLimit_ ; + /** + * int64 NetLimit = 4; + */ + public long getNetLimit() { + return netLimit_; + } + /** + * int64 NetLimit = 4; + */ + public Builder setNetLimit(long value) { + + netLimit_ = value; + onChanged(); + return this; + } + /** + * int64 NetLimit = 4; + */ + public Builder clearNetLimit() { + + netLimit_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetUsed_; + private com.google.protobuf.MapField + internalGetAssetNetUsed() { + if (assetNetUsed_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + } + return assetNetUsed_; + } + private com.google.protobuf.MapField + internalGetMutableAssetNetUsed() { + onChanged();; + if (assetNetUsed_ == null) { + assetNetUsed_ = com.google.protobuf.MapField.newMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + } + if (!assetNetUsed_.isMutable()) { + assetNetUsed_ = assetNetUsed_.copy(); + } + return assetNetUsed_; + } + + public int getAssetNetUsedCount() { + return internalGetAssetNetUsed().getMap().size(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public boolean containsAssetNetUsed( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetUsed().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetUsedMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetUsed() { + return getAssetNetUsedMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public java.util.Map getAssetNetUsedMap() { + return internalGetAssetNetUsed().getMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearAssetNetUsed() { + internalGetMutableAssetNetUsed().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public Builder removeAssetNetUsed( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAssetNetUsed().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableAssetNetUsed() { + return internalGetMutableAssetNetUsed().getMutableMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + public Builder putAssetNetUsed( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableAssetNetUsed().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public Builder putAllAssetNetUsed( + java.util.Map values) { + internalGetMutableAssetNetUsed().getMutableMap() + .putAll(values); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetLimit_; + private com.google.protobuf.MapField + internalGetAssetNetLimit() { + if (assetNetLimit_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + } + return assetNetLimit_; + } + private com.google.protobuf.MapField + internalGetMutableAssetNetLimit() { + onChanged();; + if (assetNetLimit_ == null) { + assetNetLimit_ = com.google.protobuf.MapField.newMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + } + if (!assetNetLimit_.isMutable()) { + assetNetLimit_ = assetNetLimit_.copy(); + } + return assetNetLimit_; + } + + public int getAssetNetLimitCount() { + return internalGetAssetNetLimit().getMap().size(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public boolean containsAssetNetLimit( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetLimit().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetLimitMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetLimit() { + return getAssetNetLimitMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public java.util.Map getAssetNetLimitMap() { + return internalGetAssetNetLimit().getMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearAssetNetLimit() { + internalGetMutableAssetNetLimit().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public Builder removeAssetNetLimit( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAssetNetLimit().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableAssetNetLimit() { + return internalGetMutableAssetNetLimit().getMutableMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + public Builder putAssetNetLimit( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableAssetNetLimit().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public Builder putAllAssetNetLimit( + java.util.Map values) { + internalGetMutableAssetNetLimit().getMutableMap() + .putAll(values); + return this; + } + + private long totalNetLimit_ ; + /** + * int64 TotalNetLimit = 7; + */ + public long getTotalNetLimit() { + return totalNetLimit_; + } + /** + * int64 TotalNetLimit = 7; + */ + public Builder setTotalNetLimit(long value) { + + totalNetLimit_ = value; + onChanged(); + return this; + } + /** + * int64 TotalNetLimit = 7; + */ + public Builder clearTotalNetLimit() { + + totalNetLimit_ = 0L; + onChanged(); + return this; + } + + private long totalNetWeight_ ; + /** + * int64 TotalNetWeight = 8; + */ + public long getTotalNetWeight() { + return totalNetWeight_; + } + /** + * int64 TotalNetWeight = 8; + */ + public Builder setTotalNetWeight(long value) { + + totalNetWeight_ = value; + onChanged(); + return this; + } + /** + * int64 TotalNetWeight = 8; + */ + public Builder clearTotalNetWeight() { + + totalNetWeight_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AccountNetMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.AccountNetMessage) + private static final org.tron.api.GrpcAPI.AccountNetMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.AccountNetMessage(); + } + + public static org.tron.api.GrpcAPI.AccountNetMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountNetMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountNetMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.AccountNetMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AccountResourceMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AccountResourceMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 freeNetUsed = 1; + */ + long getFreeNetUsed(); + + /** + * int64 freeNetLimit = 2; + */ + long getFreeNetLimit(); + + /** + * int64 NetUsed = 3; + */ + long getNetUsed(); + + /** + * int64 NetLimit = 4; + */ + long getNetLimit(); + + /** + * map<string, int64> assetNetUsed = 5; + */ + int getAssetNetUsedCount(); + /** + * map<string, int64> assetNetUsed = 5; + */ + boolean containsAssetNetUsed( + java.lang.String key); + /** + * Use {@link #getAssetNetUsedMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getAssetNetUsed(); + /** + * map<string, int64> assetNetUsed = 5; + */ + java.util.Map + getAssetNetUsedMap(); + /** + * map<string, int64> assetNetUsed = 5; + */ + + long getAssetNetUsedOrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> assetNetUsed = 5; + */ + + long getAssetNetUsedOrThrow( + java.lang.String key); + + /** + * map<string, int64> assetNetLimit = 6; + */ + int getAssetNetLimitCount(); + /** + * map<string, int64> assetNetLimit = 6; + */ + boolean containsAssetNetLimit( + java.lang.String key); + /** + * Use {@link #getAssetNetLimitMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getAssetNetLimit(); + /** + * map<string, int64> assetNetLimit = 6; + */ + java.util.Map + getAssetNetLimitMap(); + /** + * map<string, int64> assetNetLimit = 6; + */ + + long getAssetNetLimitOrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> assetNetLimit = 6; + */ + + long getAssetNetLimitOrThrow( + java.lang.String key); + + /** + * int64 TotalNetLimit = 7; + */ + long getTotalNetLimit(); + + /** + * int64 TotalNetWeight = 8; + */ + long getTotalNetWeight(); + + /** + * int64 EnergyUsed = 13; + */ + long getEnergyUsed(); + + /** + * int64 EnergyLimit = 14; + */ + long getEnergyLimit(); + + /** + * int64 TotalEnergyLimit = 15; + */ + long getTotalEnergyLimit(); + + /** + * int64 TotalEnergyWeight = 16; + */ + long getTotalEnergyWeight(); + + /** + * int64 storageUsed = 21; + */ + long getStorageUsed(); + + /** + * int64 storageLimit = 22; + */ + long getStorageLimit(); + } + /** + * Protobuf type {@code protocol.AccountResourceMessage} + */ + public static final class AccountResourceMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AccountResourceMessage) + AccountResourceMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountResourceMessage.newBuilder() to construct. + private AccountResourceMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountResourceMessage() { + freeNetUsed_ = 0L; + freeNetLimit_ = 0L; + netUsed_ = 0L; + netLimit_ = 0L; + totalNetLimit_ = 0L; + totalNetWeight_ = 0L; + energyUsed_ = 0L; + energyLimit_ = 0L; + totalEnergyLimit_ = 0L; + totalEnergyWeight_ = 0L; + storageUsed_ = 0L; + storageLimit_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountResourceMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + freeNetUsed_ = input.readInt64(); + break; + } + case 16: { + + freeNetLimit_ = input.readInt64(); + break; + } + case 24: { + + netUsed_ = input.readInt64(); + break; + } + case 32: { + + netLimit_ = input.readInt64(); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + assetNetUsed_ = com.google.protobuf.MapField.newMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000010; + } + com.google.protobuf.MapEntry + assetNetUsed__ = input.readMessage( + AssetNetUsedDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + assetNetUsed_.getMutableMap().put( + assetNetUsed__.getKey(), assetNetUsed__.getValue()); + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + assetNetLimit_ = com.google.protobuf.MapField.newMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000020; + } + com.google.protobuf.MapEntry + assetNetLimit__ = input.readMessage( + AssetNetLimitDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + assetNetLimit_.getMutableMap().put( + assetNetLimit__.getKey(), assetNetLimit__.getValue()); + break; + } + case 56: { + + totalNetLimit_ = input.readInt64(); + break; + } + case 64: { + + totalNetWeight_ = input.readInt64(); + break; + } + case 104: { + + energyUsed_ = input.readInt64(); + break; + } + case 112: { + + energyLimit_ = input.readInt64(); + break; + } + case 120: { + + totalEnergyLimit_ = input.readInt64(); + break; + } + case 128: { + + totalEnergyWeight_ = input.readInt64(); + break; + } + case 168: { + + storageUsed_ = input.readInt64(); + break; + } + case 176: { + + storageLimit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountResourceMessage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 5: + return internalGetAssetNetUsed(); + case 6: + return internalGetAssetNetLimit(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountResourceMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AccountResourceMessage.class, org.tron.api.GrpcAPI.AccountResourceMessage.Builder.class); + } + + private int bitField0_; + public static final int FREENETUSED_FIELD_NUMBER = 1; + private long freeNetUsed_; + /** + * int64 freeNetUsed = 1; + */ + public long getFreeNetUsed() { + return freeNetUsed_; + } + + public static final int FREENETLIMIT_FIELD_NUMBER = 2; + private long freeNetLimit_; + /** + * int64 freeNetLimit = 2; + */ + public long getFreeNetLimit() { + return freeNetLimit_; + } + + public static final int NETUSED_FIELD_NUMBER = 3; + private long netUsed_; + /** + * int64 NetUsed = 3; + */ + public long getNetUsed() { + return netUsed_; + } + + public static final int NETLIMIT_FIELD_NUMBER = 4; + private long netLimit_; + /** + * int64 NetLimit = 4; + */ + public long getNetLimit() { + return netLimit_; + } + + public static final int ASSETNETUSED_FIELD_NUMBER = 5; + private static final class AssetNetUsedDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.api.GrpcAPI.internal_static_protocol_AccountResourceMessage_AssetNetUsedEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetUsed_; + private com.google.protobuf.MapField + internalGetAssetNetUsed() { + if (assetNetUsed_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + } + return assetNetUsed_; + } + + public int getAssetNetUsedCount() { + return internalGetAssetNetUsed().getMap().size(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public boolean containsAssetNetUsed( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetUsed().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetUsedMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetUsed() { + return getAssetNetUsedMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public java.util.Map getAssetNetUsedMap() { + return internalGetAssetNetUsed().getMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int ASSETNETLIMIT_FIELD_NUMBER = 6; + private static final class AssetNetLimitDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.api.GrpcAPI.internal_static_protocol_AccountResourceMessage_AssetNetLimitEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetLimit_; + private com.google.protobuf.MapField + internalGetAssetNetLimit() { + if (assetNetLimit_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + } + return assetNetLimit_; + } + + public int getAssetNetLimitCount() { + return internalGetAssetNetLimit().getMap().size(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public boolean containsAssetNetLimit( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetLimit().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetLimitMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetLimit() { + return getAssetNetLimitMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public java.util.Map getAssetNetLimitMap() { + return internalGetAssetNetLimit().getMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int TOTALNETLIMIT_FIELD_NUMBER = 7; + private long totalNetLimit_; + /** + * int64 TotalNetLimit = 7; + */ + public long getTotalNetLimit() { + return totalNetLimit_; + } + + public static final int TOTALNETWEIGHT_FIELD_NUMBER = 8; + private long totalNetWeight_; + /** + * int64 TotalNetWeight = 8; + */ + public long getTotalNetWeight() { + return totalNetWeight_; + } + + public static final int ENERGYUSED_FIELD_NUMBER = 13; + private long energyUsed_; + /** + * int64 EnergyUsed = 13; + */ + public long getEnergyUsed() { + return energyUsed_; + } + + public static final int ENERGYLIMIT_FIELD_NUMBER = 14; + private long energyLimit_; + /** + * int64 EnergyLimit = 14; + */ + public long getEnergyLimit() { + return energyLimit_; + } + + public static final int TOTALENERGYLIMIT_FIELD_NUMBER = 15; + private long totalEnergyLimit_; + /** + * int64 TotalEnergyLimit = 15; + */ + public long getTotalEnergyLimit() { + return totalEnergyLimit_; + } + + public static final int TOTALENERGYWEIGHT_FIELD_NUMBER = 16; + private long totalEnergyWeight_; + /** + * int64 TotalEnergyWeight = 16; + */ + public long getTotalEnergyWeight() { + return totalEnergyWeight_; + } + + public static final int STORAGEUSED_FIELD_NUMBER = 21; + private long storageUsed_; + /** + * int64 storageUsed = 21; + */ + public long getStorageUsed() { + return storageUsed_; + } + + public static final int STORAGELIMIT_FIELD_NUMBER = 22; + private long storageLimit_; + /** + * int64 storageLimit = 22; + */ + public long getStorageLimit() { + return storageLimit_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (freeNetUsed_ != 0L) { + output.writeInt64(1, freeNetUsed_); + } + if (freeNetLimit_ != 0L) { + output.writeInt64(2, freeNetLimit_); + } + if (netUsed_ != 0L) { + output.writeInt64(3, netUsed_); + } + if (netLimit_ != 0L) { + output.writeInt64(4, netLimit_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetAssetNetUsed(), + AssetNetUsedDefaultEntryHolder.defaultEntry, + 5); + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetAssetNetLimit(), + AssetNetLimitDefaultEntryHolder.defaultEntry, + 6); + if (totalNetLimit_ != 0L) { + output.writeInt64(7, totalNetLimit_); + } + if (totalNetWeight_ != 0L) { + output.writeInt64(8, totalNetWeight_); + } + if (energyUsed_ != 0L) { + output.writeInt64(13, energyUsed_); + } + if (energyLimit_ != 0L) { + output.writeInt64(14, energyLimit_); + } + if (totalEnergyLimit_ != 0L) { + output.writeInt64(15, totalEnergyLimit_); + } + if (totalEnergyWeight_ != 0L) { + output.writeInt64(16, totalEnergyWeight_); + } + if (storageUsed_ != 0L) { + output.writeInt64(21, storageUsed_); + } + if (storageLimit_ != 0L) { + output.writeInt64(22, storageLimit_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (freeNetUsed_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, freeNetUsed_); + } + if (freeNetLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, freeNetLimit_); + } + if (netUsed_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, netUsed_); + } + if (netLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, netLimit_); + } + for (java.util.Map.Entry entry + : internalGetAssetNetUsed().getMap().entrySet()) { + com.google.protobuf.MapEntry + assetNetUsed__ = AssetNetUsedDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, assetNetUsed__); + } + for (java.util.Map.Entry entry + : internalGetAssetNetLimit().getMap().entrySet()) { + com.google.protobuf.MapEntry + assetNetLimit__ = AssetNetLimitDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, assetNetLimit__); + } + if (totalNetLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, totalNetLimit_); + } + if (totalNetWeight_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, totalNetWeight_); + } + if (energyUsed_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(13, energyUsed_); + } + if (energyLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(14, energyLimit_); + } + if (totalEnergyLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(15, totalEnergyLimit_); + } + if (totalEnergyWeight_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(16, totalEnergyWeight_); + } + if (storageUsed_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(21, storageUsed_); + } + if (storageLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(22, storageLimit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.AccountResourceMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.AccountResourceMessage other = (org.tron.api.GrpcAPI.AccountResourceMessage) obj; + + boolean result = true; + result = result && (getFreeNetUsed() + == other.getFreeNetUsed()); + result = result && (getFreeNetLimit() + == other.getFreeNetLimit()); + result = result && (getNetUsed() + == other.getNetUsed()); + result = result && (getNetLimit() + == other.getNetLimit()); + result = result && internalGetAssetNetUsed().equals( + other.internalGetAssetNetUsed()); + result = result && internalGetAssetNetLimit().equals( + other.internalGetAssetNetLimit()); + result = result && (getTotalNetLimit() + == other.getTotalNetLimit()); + result = result && (getTotalNetWeight() + == other.getTotalNetWeight()); + result = result && (getEnergyUsed() + == other.getEnergyUsed()); + result = result && (getEnergyLimit() + == other.getEnergyLimit()); + result = result && (getTotalEnergyLimit() + == other.getTotalEnergyLimit()); + result = result && (getTotalEnergyWeight() + == other.getTotalEnergyWeight()); + result = result && (getStorageUsed() + == other.getStorageUsed()); + result = result && (getStorageLimit() + == other.getStorageLimit()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FREENETUSED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFreeNetUsed()); + hash = (37 * hash) + FREENETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFreeNetLimit()); + hash = (37 * hash) + NETUSED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNetUsed()); + hash = (37 * hash) + NETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNetLimit()); + if (!internalGetAssetNetUsed().getMap().isEmpty()) { + hash = (37 * hash) + ASSETNETUSED_FIELD_NUMBER; + hash = (53 * hash) + internalGetAssetNetUsed().hashCode(); + } + if (!internalGetAssetNetLimit().getMap().isEmpty()) { + hash = (37 * hash) + ASSETNETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + internalGetAssetNetLimit().hashCode(); + } + hash = (37 * hash) + TOTALNETLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalNetLimit()); + hash = (37 * hash) + TOTALNETWEIGHT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalNetWeight()); + hash = (37 * hash) + ENERGYUSED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEnergyUsed()); + hash = (37 * hash) + ENERGYLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEnergyLimit()); + hash = (37 * hash) + TOTALENERGYLIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalEnergyLimit()); + hash = (37 * hash) + TOTALENERGYWEIGHT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalEnergyWeight()); + hash = (37 * hash) + STORAGEUSED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getStorageUsed()); + hash = (37 * hash) + STORAGELIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getStorageLimit()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AccountResourceMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.AccountResourceMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AccountResourceMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AccountResourceMessage) + org.tron.api.GrpcAPI.AccountResourceMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountResourceMessage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 5: + return internalGetAssetNetUsed(); + case 6: + return internalGetAssetNetLimit(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 5: + return internalGetMutableAssetNetUsed(); + case 6: + return internalGetMutableAssetNetLimit(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountResourceMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AccountResourceMessage.class, org.tron.api.GrpcAPI.AccountResourceMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.AccountResourceMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + freeNetUsed_ = 0L; + + freeNetLimit_ = 0L; + + netUsed_ = 0L; + + netLimit_ = 0L; + + internalGetMutableAssetNetUsed().clear(); + internalGetMutableAssetNetLimit().clear(); + totalNetLimit_ = 0L; + + totalNetWeight_ = 0L; + + energyUsed_ = 0L; + + energyLimit_ = 0L; + + totalEnergyLimit_ = 0L; + + totalEnergyWeight_ = 0L; + + storageUsed_ = 0L; + + storageLimit_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_AccountResourceMessage_descriptor; + } + + public org.tron.api.GrpcAPI.AccountResourceMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.AccountResourceMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.AccountResourceMessage build() { + org.tron.api.GrpcAPI.AccountResourceMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.AccountResourceMessage buildPartial() { + org.tron.api.GrpcAPI.AccountResourceMessage result = new org.tron.api.GrpcAPI.AccountResourceMessage(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.freeNetUsed_ = freeNetUsed_; + result.freeNetLimit_ = freeNetLimit_; + result.netUsed_ = netUsed_; + result.netLimit_ = netLimit_; + result.assetNetUsed_ = internalGetAssetNetUsed(); + result.assetNetUsed_.makeImmutable(); + result.assetNetLimit_ = internalGetAssetNetLimit(); + result.assetNetLimit_.makeImmutable(); + result.totalNetLimit_ = totalNetLimit_; + result.totalNetWeight_ = totalNetWeight_; + result.energyUsed_ = energyUsed_; + result.energyLimit_ = energyLimit_; + result.totalEnergyLimit_ = totalEnergyLimit_; + result.totalEnergyWeight_ = totalEnergyWeight_; + result.storageUsed_ = storageUsed_; + result.storageLimit_ = storageLimit_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.AccountResourceMessage) { + return mergeFrom((org.tron.api.GrpcAPI.AccountResourceMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.AccountResourceMessage other) { + if (other == org.tron.api.GrpcAPI.AccountResourceMessage.getDefaultInstance()) return this; + if (other.getFreeNetUsed() != 0L) { + setFreeNetUsed(other.getFreeNetUsed()); + } + if (other.getFreeNetLimit() != 0L) { + setFreeNetLimit(other.getFreeNetLimit()); + } + if (other.getNetUsed() != 0L) { + setNetUsed(other.getNetUsed()); + } + if (other.getNetLimit() != 0L) { + setNetLimit(other.getNetLimit()); + } + internalGetMutableAssetNetUsed().mergeFrom( + other.internalGetAssetNetUsed()); + internalGetMutableAssetNetLimit().mergeFrom( + other.internalGetAssetNetLimit()); + if (other.getTotalNetLimit() != 0L) { + setTotalNetLimit(other.getTotalNetLimit()); + } + if (other.getTotalNetWeight() != 0L) { + setTotalNetWeight(other.getTotalNetWeight()); + } + if (other.getEnergyUsed() != 0L) { + setEnergyUsed(other.getEnergyUsed()); + } + if (other.getEnergyLimit() != 0L) { + setEnergyLimit(other.getEnergyLimit()); + } + if (other.getTotalEnergyLimit() != 0L) { + setTotalEnergyLimit(other.getTotalEnergyLimit()); + } + if (other.getTotalEnergyWeight() != 0L) { + setTotalEnergyWeight(other.getTotalEnergyWeight()); + } + if (other.getStorageUsed() != 0L) { + setStorageUsed(other.getStorageUsed()); + } + if (other.getStorageLimit() != 0L) { + setStorageLimit(other.getStorageLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.AccountResourceMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.AccountResourceMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long freeNetUsed_ ; + /** + * int64 freeNetUsed = 1; + */ + public long getFreeNetUsed() { + return freeNetUsed_; + } + /** + * int64 freeNetUsed = 1; + */ + public Builder setFreeNetUsed(long value) { + + freeNetUsed_ = value; + onChanged(); + return this; + } + /** + * int64 freeNetUsed = 1; + */ + public Builder clearFreeNetUsed() { + + freeNetUsed_ = 0L; + onChanged(); + return this; + } + + private long freeNetLimit_ ; + /** + * int64 freeNetLimit = 2; + */ + public long getFreeNetLimit() { + return freeNetLimit_; + } + /** + * int64 freeNetLimit = 2; + */ + public Builder setFreeNetLimit(long value) { + + freeNetLimit_ = value; + onChanged(); + return this; + } + /** + * int64 freeNetLimit = 2; + */ + public Builder clearFreeNetLimit() { + + freeNetLimit_ = 0L; + onChanged(); + return this; + } + + private long netUsed_ ; + /** + * int64 NetUsed = 3; + */ + public long getNetUsed() { + return netUsed_; + } + /** + * int64 NetUsed = 3; + */ + public Builder setNetUsed(long value) { + + netUsed_ = value; + onChanged(); + return this; + } + /** + * int64 NetUsed = 3; + */ + public Builder clearNetUsed() { + + netUsed_ = 0L; + onChanged(); + return this; + } + + private long netLimit_ ; + /** + * int64 NetLimit = 4; + */ + public long getNetLimit() { + return netLimit_; + } + /** + * int64 NetLimit = 4; + */ + public Builder setNetLimit(long value) { + + netLimit_ = value; + onChanged(); + return this; + } + /** + * int64 NetLimit = 4; + */ + public Builder clearNetLimit() { + + netLimit_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetUsed_; + private com.google.protobuf.MapField + internalGetAssetNetUsed() { + if (assetNetUsed_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + } + return assetNetUsed_; + } + private com.google.protobuf.MapField + internalGetMutableAssetNetUsed() { + onChanged();; + if (assetNetUsed_ == null) { + assetNetUsed_ = com.google.protobuf.MapField.newMapField( + AssetNetUsedDefaultEntryHolder.defaultEntry); + } + if (!assetNetUsed_.isMutable()) { + assetNetUsed_ = assetNetUsed_.copy(); + } + return assetNetUsed_; + } + + public int getAssetNetUsedCount() { + return internalGetAssetNetUsed().getMap().size(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public boolean containsAssetNetUsed( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetUsed().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetUsedMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetUsed() { + return getAssetNetUsedMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public java.util.Map getAssetNetUsedMap() { + return internalGetAssetNetUsed().getMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public long getAssetNetUsedOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetUsed().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearAssetNetUsed() { + internalGetMutableAssetNetUsed().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public Builder removeAssetNetUsed( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAssetNetUsed().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableAssetNetUsed() { + return internalGetMutableAssetNetUsed().getMutableMap(); + } + /** + * map<string, int64> assetNetUsed = 5; + */ + public Builder putAssetNetUsed( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableAssetNetUsed().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> assetNetUsed = 5; + */ + + public Builder putAllAssetNetUsed( + java.util.Map values) { + internalGetMutableAssetNetUsed().getMutableMap() + .putAll(values); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetNetLimit_; + private com.google.protobuf.MapField + internalGetAssetNetLimit() { + if (assetNetLimit_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + } + return assetNetLimit_; + } + private com.google.protobuf.MapField + internalGetMutableAssetNetLimit() { + onChanged();; + if (assetNetLimit_ == null) { + assetNetLimit_ = com.google.protobuf.MapField.newMapField( + AssetNetLimitDefaultEntryHolder.defaultEntry); + } + if (!assetNetLimit_.isMutable()) { + assetNetLimit_ = assetNetLimit_.copy(); + } + return assetNetLimit_; + } + + public int getAssetNetLimitCount() { + return internalGetAssetNetLimit().getMap().size(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public boolean containsAssetNetLimit( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetNetLimit().getMap().containsKey(key); + } + /** + * Use {@link #getAssetNetLimitMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetNetLimit() { + return getAssetNetLimitMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public java.util.Map getAssetNetLimitMap() { + return internalGetAssetNetLimit().getMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public long getAssetNetLimitOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetNetLimit().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearAssetNetLimit() { + internalGetMutableAssetNetLimit().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public Builder removeAssetNetLimit( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAssetNetLimit().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableAssetNetLimit() { + return internalGetMutableAssetNetLimit().getMutableMap(); + } + /** + * map<string, int64> assetNetLimit = 6; + */ + public Builder putAssetNetLimit( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableAssetNetLimit().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> assetNetLimit = 6; + */ + + public Builder putAllAssetNetLimit( + java.util.Map values) { + internalGetMutableAssetNetLimit().getMutableMap() + .putAll(values); + return this; + } + + private long totalNetLimit_ ; + /** + * int64 TotalNetLimit = 7; + */ + public long getTotalNetLimit() { + return totalNetLimit_; + } + /** + * int64 TotalNetLimit = 7; + */ + public Builder setTotalNetLimit(long value) { + + totalNetLimit_ = value; + onChanged(); + return this; + } + /** + * int64 TotalNetLimit = 7; + */ + public Builder clearTotalNetLimit() { + + totalNetLimit_ = 0L; + onChanged(); + return this; + } + + private long totalNetWeight_ ; + /** + * int64 TotalNetWeight = 8; + */ + public long getTotalNetWeight() { + return totalNetWeight_; + } + /** + * int64 TotalNetWeight = 8; + */ + public Builder setTotalNetWeight(long value) { + + totalNetWeight_ = value; + onChanged(); + return this; + } + /** + * int64 TotalNetWeight = 8; + */ + public Builder clearTotalNetWeight() { + + totalNetWeight_ = 0L; + onChanged(); + return this; + } + + private long energyUsed_ ; + /** + * int64 EnergyUsed = 13; + */ + public long getEnergyUsed() { + return energyUsed_; + } + /** + * int64 EnergyUsed = 13; + */ + public Builder setEnergyUsed(long value) { + + energyUsed_ = value; + onChanged(); + return this; + } + /** + * int64 EnergyUsed = 13; + */ + public Builder clearEnergyUsed() { + + energyUsed_ = 0L; + onChanged(); + return this; + } + + private long energyLimit_ ; + /** + * int64 EnergyLimit = 14; + */ + public long getEnergyLimit() { + return energyLimit_; + } + /** + * int64 EnergyLimit = 14; + */ + public Builder setEnergyLimit(long value) { + + energyLimit_ = value; + onChanged(); + return this; + } + /** + * int64 EnergyLimit = 14; + */ + public Builder clearEnergyLimit() { + + energyLimit_ = 0L; + onChanged(); + return this; + } + + private long totalEnergyLimit_ ; + /** + * int64 TotalEnergyLimit = 15; + */ + public long getTotalEnergyLimit() { + return totalEnergyLimit_; + } + /** + * int64 TotalEnergyLimit = 15; + */ + public Builder setTotalEnergyLimit(long value) { + + totalEnergyLimit_ = value; + onChanged(); + return this; + } + /** + * int64 TotalEnergyLimit = 15; + */ + public Builder clearTotalEnergyLimit() { + + totalEnergyLimit_ = 0L; + onChanged(); + return this; + } + + private long totalEnergyWeight_ ; + /** + * int64 TotalEnergyWeight = 16; + */ + public long getTotalEnergyWeight() { + return totalEnergyWeight_; + } + /** + * int64 TotalEnergyWeight = 16; + */ + public Builder setTotalEnergyWeight(long value) { + + totalEnergyWeight_ = value; + onChanged(); + return this; + } + /** + * int64 TotalEnergyWeight = 16; + */ + public Builder clearTotalEnergyWeight() { + + totalEnergyWeight_ = 0L; + onChanged(); + return this; + } + + private long storageUsed_ ; + /** + * int64 storageUsed = 21; + */ + public long getStorageUsed() { + return storageUsed_; + } + /** + * int64 storageUsed = 21; + */ + public Builder setStorageUsed(long value) { + + storageUsed_ = value; + onChanged(); + return this; + } + /** + * int64 storageUsed = 21; + */ + public Builder clearStorageUsed() { + + storageUsed_ = 0L; + onChanged(); + return this; + } + + private long storageLimit_ ; + /** + * int64 storageLimit = 22; + */ + public long getStorageLimit() { + return storageLimit_; + } + /** + * int64 storageLimit = 22; + */ + public Builder setStorageLimit(long value) { + + storageLimit_ = value; + onChanged(); + return this; + } + /** + * int64 storageLimit = 22; + */ + public Builder clearStorageLimit() { + + storageLimit_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AccountResourceMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.AccountResourceMessage) + private static final org.tron.api.GrpcAPI.AccountResourceMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.AccountResourceMessage(); + } + + public static org.tron.api.GrpcAPI.AccountResourceMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountResourceMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountResourceMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.AccountResourceMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface PaginatedMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.PaginatedMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 offset = 1; + */ + long getOffset(); + + /** + * int64 limit = 2; + */ + long getLimit(); + } + /** + * Protobuf type {@code protocol.PaginatedMessage} + */ + public static final class PaginatedMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.PaginatedMessage) + PaginatedMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use PaginatedMessage.newBuilder() to construct. + private PaginatedMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PaginatedMessage() { + offset_ = 0L; + limit_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PaginatedMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + offset_ = input.readInt64(); + break; + } + case 16: { + + limit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_PaginatedMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_PaginatedMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.PaginatedMessage.class, org.tron.api.GrpcAPI.PaginatedMessage.Builder.class); + } + + public static final int OFFSET_FIELD_NUMBER = 1; + private long offset_; + /** + * int64 offset = 1; + */ + public long getOffset() { + return offset_; + } + + public static final int LIMIT_FIELD_NUMBER = 2; + private long limit_; + /** + * int64 limit = 2; + */ + public long getLimit() { + return limit_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (offset_ != 0L) { + output.writeInt64(1, offset_); + } + if (limit_ != 0L) { + output.writeInt64(2, limit_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (offset_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, offset_); + } + if (limit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, limit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.PaginatedMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.PaginatedMessage other = (org.tron.api.GrpcAPI.PaginatedMessage) obj; + + boolean result = true; + result = result && (getOffset() + == other.getOffset()); + result = result && (getLimit() + == other.getLimit()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OFFSET_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOffset()); + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLimit()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.PaginatedMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.PaginatedMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.PaginatedMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.PaginatedMessage) + org.tron.api.GrpcAPI.PaginatedMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_PaginatedMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_PaginatedMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.PaginatedMessage.class, org.tron.api.GrpcAPI.PaginatedMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.PaginatedMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + offset_ = 0L; + + limit_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_PaginatedMessage_descriptor; + } + + public org.tron.api.GrpcAPI.PaginatedMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.PaginatedMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.PaginatedMessage build() { + org.tron.api.GrpcAPI.PaginatedMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.PaginatedMessage buildPartial() { + org.tron.api.GrpcAPI.PaginatedMessage result = new org.tron.api.GrpcAPI.PaginatedMessage(this); + result.offset_ = offset_; + result.limit_ = limit_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.PaginatedMessage) { + return mergeFrom((org.tron.api.GrpcAPI.PaginatedMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.PaginatedMessage other) { + if (other == org.tron.api.GrpcAPI.PaginatedMessage.getDefaultInstance()) return this; + if (other.getOffset() != 0L) { + setOffset(other.getOffset()); + } + if (other.getLimit() != 0L) { + setLimit(other.getLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.PaginatedMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.PaginatedMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long offset_ ; + /** + * int64 offset = 1; + */ + public long getOffset() { + return offset_; + } + /** + * int64 offset = 1; + */ + public Builder setOffset(long value) { + + offset_ = value; + onChanged(); + return this; + } + /** + * int64 offset = 1; + */ + public Builder clearOffset() { + + offset_ = 0L; + onChanged(); + return this; + } + + private long limit_ ; + /** + * int64 limit = 2; + */ + public long getLimit() { + return limit_; + } + /** + * int64 limit = 2; + */ + public Builder setLimit(long value) { + + limit_ = value; + onChanged(); + return this; + } + /** + * int64 limit = 2; + */ + public Builder clearLimit() { + + limit_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.PaginatedMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.PaginatedMessage) + private static final org.tron.api.GrpcAPI.PaginatedMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.PaginatedMessage(); + } + + public static org.tron.api.GrpcAPI.PaginatedMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PaginatedMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PaginatedMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.PaginatedMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface EasyTransferMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.EasyTransferMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes passPhrase = 1; + */ + com.google.protobuf.ByteString getPassPhrase(); + + /** + * bytes toAddress = 2; + */ + com.google.protobuf.ByteString getToAddress(); + + /** + * int64 amount = 3; + */ + long getAmount(); + } + /** + * Protobuf type {@code protocol.EasyTransferMessage} + */ + public static final class EasyTransferMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.EasyTransferMessage) + EasyTransferMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use EasyTransferMessage.newBuilder() to construct. + private EasyTransferMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EasyTransferMessage() { + passPhrase_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + amount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EasyTransferMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + passPhrase_ = input.readBytes(); + break; + } + case 18: { + + toAddress_ = input.readBytes(); + break; + } + case 24: { + + amount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferMessage.class, org.tron.api.GrpcAPI.EasyTransferMessage.Builder.class); + } + + public static final int PASSPHRASE_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString passPhrase_; + /** + * bytes passPhrase = 1; + */ + public com.google.protobuf.ByteString getPassPhrase() { + return passPhrase_; + } + + public static final int TOADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + public static final int AMOUNT_FIELD_NUMBER = 3; + private long amount_; + /** + * int64 amount = 3; + */ + public long getAmount() { + return amount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!passPhrase_.isEmpty()) { + output.writeBytes(1, passPhrase_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(2, toAddress_); + } + if (amount_ != 0L) { + output.writeInt64(3, amount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!passPhrase_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, passPhrase_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, toAddress_); + } + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, amount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.EasyTransferMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.EasyTransferMessage other = (org.tron.api.GrpcAPI.EasyTransferMessage) obj; + + boolean result = true; + result = result && getPassPhrase() + .equals(other.getPassPhrase()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && (getAmount() + == other.getAmount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PASSPHRASE_FIELD_NUMBER; + hash = (53 * hash) + getPassPhrase().hashCode(); + hash = (37 * hash) + TOADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.EasyTransferMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.EasyTransferMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.EasyTransferMessage) + org.tron.api.GrpcAPI.EasyTransferMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferMessage.class, org.tron.api.GrpcAPI.EasyTransferMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.EasyTransferMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + passPhrase_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + amount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferMessage_descriptor; + } + + public org.tron.api.GrpcAPI.EasyTransferMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.EasyTransferMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.EasyTransferMessage build() { + org.tron.api.GrpcAPI.EasyTransferMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.EasyTransferMessage buildPartial() { + org.tron.api.GrpcAPI.EasyTransferMessage result = new org.tron.api.GrpcAPI.EasyTransferMessage(this); + result.passPhrase_ = passPhrase_; + result.toAddress_ = toAddress_; + result.amount_ = amount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.EasyTransferMessage) { + return mergeFrom((org.tron.api.GrpcAPI.EasyTransferMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.EasyTransferMessage other) { + if (other == org.tron.api.GrpcAPI.EasyTransferMessage.getDefaultInstance()) return this; + if (other.getPassPhrase() != com.google.protobuf.ByteString.EMPTY) { + setPassPhrase(other.getPassPhrase()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.EasyTransferMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.EasyTransferMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString passPhrase_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes passPhrase = 1; + */ + public com.google.protobuf.ByteString getPassPhrase() { + return passPhrase_; + } + /** + * bytes passPhrase = 1; + */ + public Builder setPassPhrase(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + passPhrase_ = value; + onChanged(); + return this; + } + /** + * bytes passPhrase = 1; + */ + public Builder clearPassPhrase() { + + passPhrase_ = getDefaultInstance().getPassPhrase(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes toAddress = 2; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes toAddress = 2; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + + private long amount_ ; + /** + * int64 amount = 3; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 3; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 3; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.EasyTransferMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.EasyTransferMessage) + private static final org.tron.api.GrpcAPI.EasyTransferMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.EasyTransferMessage(); + } + + public static org.tron.api.GrpcAPI.EasyTransferMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EasyTransferMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EasyTransferMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.EasyTransferMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface EasyTransferAssetMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.EasyTransferAssetMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes passPhrase = 1; + */ + com.google.protobuf.ByteString getPassPhrase(); + + /** + * bytes toAddress = 2; + */ + com.google.protobuf.ByteString getToAddress(); + + /** + * string assetId = 3; + */ + java.lang.String getAssetId(); + /** + * string assetId = 3; + */ + com.google.protobuf.ByteString + getAssetIdBytes(); + + /** + * int64 amount = 4; + */ + long getAmount(); + } + /** + * Protobuf type {@code protocol.EasyTransferAssetMessage} + */ + public static final class EasyTransferAssetMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.EasyTransferAssetMessage) + EasyTransferAssetMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use EasyTransferAssetMessage.newBuilder() to construct. + private EasyTransferAssetMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EasyTransferAssetMessage() { + passPhrase_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + assetId_ = ""; + amount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EasyTransferAssetMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + passPhrase_ = input.readBytes(); + break; + } + case 18: { + + toAddress_ = input.readBytes(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + assetId_ = s; + break; + } + case 32: { + + amount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferAssetMessage.class, org.tron.api.GrpcAPI.EasyTransferAssetMessage.Builder.class); + } + + public static final int PASSPHRASE_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString passPhrase_; + /** + * bytes passPhrase = 1; + */ + public com.google.protobuf.ByteString getPassPhrase() { + return passPhrase_; + } + + public static final int TOADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + public static final int ASSETID_FIELD_NUMBER = 3; + private volatile java.lang.Object assetId_; + /** + * string assetId = 3; + */ + public java.lang.String getAssetId() { + java.lang.Object ref = assetId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetId_ = s; + return s; + } + } + /** + * string assetId = 3; + */ + public com.google.protobuf.ByteString + getAssetIdBytes() { + java.lang.Object ref = assetId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int AMOUNT_FIELD_NUMBER = 4; + private long amount_; + /** + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!passPhrase_.isEmpty()) { + output.writeBytes(1, passPhrase_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(2, toAddress_); + } + if (!getAssetIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, assetId_); + } + if (amount_ != 0L) { + output.writeInt64(4, amount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!passPhrase_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, passPhrase_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, toAddress_); + } + if (!getAssetIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, assetId_); + } + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, amount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.EasyTransferAssetMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.EasyTransferAssetMessage other = (org.tron.api.GrpcAPI.EasyTransferAssetMessage) obj; + + boolean result = true; + result = result && getPassPhrase() + .equals(other.getPassPhrase()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && getAssetId() + .equals(other.getAssetId()); + result = result && (getAmount() + == other.getAmount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PASSPHRASE_FIELD_NUMBER; + hash = (53 * hash) + getPassPhrase().hashCode(); + hash = (37 * hash) + TOADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (37 * hash) + ASSETID_FIELD_NUMBER; + hash = (53 * hash) + getAssetId().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.EasyTransferAssetMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.EasyTransferAssetMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.EasyTransferAssetMessage) + org.tron.api.GrpcAPI.EasyTransferAssetMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferAssetMessage.class, org.tron.api.GrpcAPI.EasyTransferAssetMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.EasyTransferAssetMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + passPhrase_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + assetId_ = ""; + + amount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetMessage_descriptor; + } + + public org.tron.api.GrpcAPI.EasyTransferAssetMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.EasyTransferAssetMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.EasyTransferAssetMessage build() { + org.tron.api.GrpcAPI.EasyTransferAssetMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.EasyTransferAssetMessage buildPartial() { + org.tron.api.GrpcAPI.EasyTransferAssetMessage result = new org.tron.api.GrpcAPI.EasyTransferAssetMessage(this); + result.passPhrase_ = passPhrase_; + result.toAddress_ = toAddress_; + result.assetId_ = assetId_; + result.amount_ = amount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.EasyTransferAssetMessage) { + return mergeFrom((org.tron.api.GrpcAPI.EasyTransferAssetMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.EasyTransferAssetMessage other) { + if (other == org.tron.api.GrpcAPI.EasyTransferAssetMessage.getDefaultInstance()) return this; + if (other.getPassPhrase() != com.google.protobuf.ByteString.EMPTY) { + setPassPhrase(other.getPassPhrase()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + if (!other.getAssetId().isEmpty()) { + assetId_ = other.assetId_; + onChanged(); + } + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.EasyTransferAssetMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.EasyTransferAssetMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString passPhrase_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes passPhrase = 1; + */ + public com.google.protobuf.ByteString getPassPhrase() { + return passPhrase_; + } + /** + * bytes passPhrase = 1; + */ + public Builder setPassPhrase(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + passPhrase_ = value; + onChanged(); + return this; + } + /** + * bytes passPhrase = 1; + */ + public Builder clearPassPhrase() { + + passPhrase_ = getDefaultInstance().getPassPhrase(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes toAddress = 2; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes toAddress = 2; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + + private java.lang.Object assetId_ = ""; + /** + * string assetId = 3; + */ + public java.lang.String getAssetId() { + java.lang.Object ref = assetId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string assetId = 3; + */ + public com.google.protobuf.ByteString + getAssetIdBytes() { + java.lang.Object ref = assetId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string assetId = 3; + */ + public Builder setAssetId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + assetId_ = value; + onChanged(); + return this; + } + /** + * string assetId = 3; + */ + public Builder clearAssetId() { + + assetId_ = getDefaultInstance().getAssetId(); + onChanged(); + return this; + } + /** + * string assetId = 3; + */ + public Builder setAssetIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + assetId_ = value; + onChanged(); + return this; + } + + private long amount_ ; + /** + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 4; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 4; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.EasyTransferAssetMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.EasyTransferAssetMessage) + private static final org.tron.api.GrpcAPI.EasyTransferAssetMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.EasyTransferAssetMessage(); + } + + public static org.tron.api.GrpcAPI.EasyTransferAssetMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EasyTransferAssetMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EasyTransferAssetMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.EasyTransferAssetMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface EasyTransferByPrivateMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.EasyTransferByPrivateMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes privateKey = 1; + */ + com.google.protobuf.ByteString getPrivateKey(); + + /** + * bytes toAddress = 2; + */ + com.google.protobuf.ByteString getToAddress(); + + /** + * int64 amount = 3; + */ + long getAmount(); + } + /** + * Protobuf type {@code protocol.EasyTransferByPrivateMessage} + */ + public static final class EasyTransferByPrivateMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.EasyTransferByPrivateMessage) + EasyTransferByPrivateMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use EasyTransferByPrivateMessage.newBuilder() to construct. + private EasyTransferByPrivateMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EasyTransferByPrivateMessage() { + privateKey_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + amount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EasyTransferByPrivateMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + privateKey_ = input.readBytes(); + break; + } + case 18: { + + toAddress_ = input.readBytes(); + break; + } + case 24: { + + amount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferByPrivateMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferByPrivateMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.class, org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.Builder.class); + } + + public static final int PRIVATEKEY_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString privateKey_; + /** + * bytes privateKey = 1; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + + public static final int TOADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + public static final int AMOUNT_FIELD_NUMBER = 3; + private long amount_; + /** + * int64 amount = 3; + */ + public long getAmount() { + return amount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!privateKey_.isEmpty()) { + output.writeBytes(1, privateKey_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(2, toAddress_); + } + if (amount_ != 0L) { + output.writeInt64(3, amount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!privateKey_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, privateKey_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, toAddress_); + } + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, amount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.EasyTransferByPrivateMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage other = (org.tron.api.GrpcAPI.EasyTransferByPrivateMessage) obj; + + boolean result = true; + result = result && getPrivateKey() + .equals(other.getPrivateKey()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && (getAmount() + == other.getAmount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PRIVATEKEY_FIELD_NUMBER; + hash = (53 * hash) + getPrivateKey().hashCode(); + hash = (37 * hash) + TOADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.EasyTransferByPrivateMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.EasyTransferByPrivateMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.EasyTransferByPrivateMessage) + org.tron.api.GrpcAPI.EasyTransferByPrivateMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferByPrivateMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferByPrivateMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.class, org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + privateKey_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + amount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferByPrivateMessage_descriptor; + } + + public org.tron.api.GrpcAPI.EasyTransferByPrivateMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.EasyTransferByPrivateMessage build() { + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.EasyTransferByPrivateMessage buildPartial() { + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage result = new org.tron.api.GrpcAPI.EasyTransferByPrivateMessage(this); + result.privateKey_ = privateKey_; + result.toAddress_ = toAddress_; + result.amount_ = amount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.EasyTransferByPrivateMessage) { + return mergeFrom((org.tron.api.GrpcAPI.EasyTransferByPrivateMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.EasyTransferByPrivateMessage other) { + if (other == org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.getDefaultInstance()) return this; + if (other.getPrivateKey() != com.google.protobuf.ByteString.EMPTY) { + setPrivateKey(other.getPrivateKey()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.EasyTransferByPrivateMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes privateKey = 1; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + /** + * bytes privateKey = 1; + */ + public Builder setPrivateKey(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + privateKey_ = value; + onChanged(); + return this; + } + /** + * bytes privateKey = 1; + */ + public Builder clearPrivateKey() { + + privateKey_ = getDefaultInstance().getPrivateKey(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes toAddress = 2; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes toAddress = 2; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + + private long amount_ ; + /** + * int64 amount = 3; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 3; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 3; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.EasyTransferByPrivateMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.EasyTransferByPrivateMessage) + private static final org.tron.api.GrpcAPI.EasyTransferByPrivateMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.EasyTransferByPrivateMessage(); + } + + public static org.tron.api.GrpcAPI.EasyTransferByPrivateMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EasyTransferByPrivateMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EasyTransferByPrivateMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.EasyTransferByPrivateMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface EasyTransferAssetByPrivateMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.EasyTransferAssetByPrivateMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes privateKey = 1; + */ + com.google.protobuf.ByteString getPrivateKey(); + + /** + * bytes toAddress = 2; + */ + com.google.protobuf.ByteString getToAddress(); + + /** + * string assetId = 3; + */ + java.lang.String getAssetId(); + /** + * string assetId = 3; + */ + com.google.protobuf.ByteString + getAssetIdBytes(); + + /** + * int64 amount = 4; + */ + long getAmount(); + } + /** + * Protobuf type {@code protocol.EasyTransferAssetByPrivateMessage} + */ + public static final class EasyTransferAssetByPrivateMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.EasyTransferAssetByPrivateMessage) + EasyTransferAssetByPrivateMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use EasyTransferAssetByPrivateMessage.newBuilder() to construct. + private EasyTransferAssetByPrivateMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EasyTransferAssetByPrivateMessage() { + privateKey_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + assetId_ = ""; + amount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EasyTransferAssetByPrivateMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + privateKey_ = input.readBytes(); + break; + } + case 18: { + + toAddress_ = input.readBytes(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + assetId_ = s; + break; + } + case 32: { + + amount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetByPrivateMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetByPrivateMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.class, org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.Builder.class); + } + + public static final int PRIVATEKEY_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString privateKey_; + /** + * bytes privateKey = 1; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + + public static final int TOADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + public static final int ASSETID_FIELD_NUMBER = 3; + private volatile java.lang.Object assetId_; + /** + * string assetId = 3; + */ + public java.lang.String getAssetId() { + java.lang.Object ref = assetId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetId_ = s; + return s; + } + } + /** + * string assetId = 3; + */ + public com.google.protobuf.ByteString + getAssetIdBytes() { + java.lang.Object ref = assetId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int AMOUNT_FIELD_NUMBER = 4; + private long amount_; + /** + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!privateKey_.isEmpty()) { + output.writeBytes(1, privateKey_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(2, toAddress_); + } + if (!getAssetIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, assetId_); + } + if (amount_ != 0L) { + output.writeInt64(4, amount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!privateKey_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, privateKey_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, toAddress_); + } + if (!getAssetIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, assetId_); + } + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, amount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage other = (org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage) obj; + + boolean result = true; + result = result && getPrivateKey() + .equals(other.getPrivateKey()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && getAssetId() + .equals(other.getAssetId()); + result = result && (getAmount() + == other.getAmount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PRIVATEKEY_FIELD_NUMBER; + hash = (53 * hash) + getPrivateKey().hashCode(); + hash = (37 * hash) + TOADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (37 * hash) + ASSETID_FIELD_NUMBER; + hash = (53 * hash) + getAssetId().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.EasyTransferAssetByPrivateMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.EasyTransferAssetByPrivateMessage) + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetByPrivateMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetByPrivateMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.class, org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + privateKey_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + assetId_ = ""; + + amount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferAssetByPrivateMessage_descriptor; + } + + public org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage build() { + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage buildPartial() { + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage result = new org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage(this); + result.privateKey_ = privateKey_; + result.toAddress_ = toAddress_; + result.assetId_ = assetId_; + result.amount_ = amount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage) { + return mergeFrom((org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage other) { + if (other == org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.getDefaultInstance()) return this; + if (other.getPrivateKey() != com.google.protobuf.ByteString.EMPTY) { + setPrivateKey(other.getPrivateKey()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + if (!other.getAssetId().isEmpty()) { + assetId_ = other.assetId_; + onChanged(); + } + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes privateKey = 1; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + /** + * bytes privateKey = 1; + */ + public Builder setPrivateKey(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + privateKey_ = value; + onChanged(); + return this; + } + /** + * bytes privateKey = 1; + */ + public Builder clearPrivateKey() { + + privateKey_ = getDefaultInstance().getPrivateKey(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes toAddress = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes toAddress = 2; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes toAddress = 2; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + + private java.lang.Object assetId_ = ""; + /** + * string assetId = 3; + */ + public java.lang.String getAssetId() { + java.lang.Object ref = assetId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string assetId = 3; + */ + public com.google.protobuf.ByteString + getAssetIdBytes() { + java.lang.Object ref = assetId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string assetId = 3; + */ + public Builder setAssetId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + assetId_ = value; + onChanged(); + return this; + } + /** + * string assetId = 3; + */ + public Builder clearAssetId() { + + assetId_ = getDefaultInstance().getAssetId(); + onChanged(); + return this; + } + /** + * string assetId = 3; + */ + public Builder setAssetIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + assetId_ = value; + onChanged(); + return this; + } + + private long amount_ ; + /** + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 4; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 4; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.EasyTransferAssetByPrivateMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.EasyTransferAssetByPrivateMessage) + private static final org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage(); + } + + public static org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EasyTransferAssetByPrivateMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EasyTransferAssetByPrivateMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface EasyTransferResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.EasyTransferResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Transaction transaction = 1; + */ + boolean hasTransaction(); + /** + * .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.Transaction getTransaction(); + /** + * .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder(); + + /** + * .protocol.Return result = 2; + */ + boolean hasResult(); + /** + * .protocol.Return result = 2; + */ + org.tron.api.GrpcAPI.Return getResult(); + /** + * .protocol.Return result = 2; + */ + org.tron.api.GrpcAPI.ReturnOrBuilder getResultOrBuilder(); + + /** + *
+     *transaction id =  sha256(transaction.rowdata)
+     * 
+ * + * bytes txid = 3; + */ + com.google.protobuf.ByteString getTxid(); + } + /** + * Protobuf type {@code protocol.EasyTransferResponse} + */ + public static final class EasyTransferResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.EasyTransferResponse) + EasyTransferResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use EasyTransferResponse.newBuilder() to construct. + private EasyTransferResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private EasyTransferResponse() { + txid_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private EasyTransferResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.Transaction.Builder subBuilder = null; + if (transaction_ != null) { + subBuilder = transaction_.toBuilder(); + } + transaction_ = input.readMessage(org.tron.protos.Protocol.Transaction.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(transaction_); + transaction_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + org.tron.api.GrpcAPI.Return.Builder subBuilder = null; + if (result_ != null) { + subBuilder = result_.toBuilder(); + } + result_ = input.readMessage(org.tron.api.GrpcAPI.Return.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(result_); + result_ = subBuilder.buildPartial(); + } + + break; + } + case 26: { + + txid_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferResponse.class, org.tron.api.GrpcAPI.EasyTransferResponse.Builder.class); + } + + public static final int TRANSACTION_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.Transaction transaction_; + /** + * .protocol.Transaction transaction = 1; + */ + public boolean hasTransaction() { + return transaction_ != null; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction() { + return transaction_ == null ? org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder() { + return getTransaction(); + } + + public static final int RESULT_FIELD_NUMBER = 2; + private org.tron.api.GrpcAPI.Return result_; + /** + * .protocol.Return result = 2; + */ + public boolean hasResult() { + return result_ != null; + } + /** + * .protocol.Return result = 2; + */ + public org.tron.api.GrpcAPI.Return getResult() { + return result_ == null ? org.tron.api.GrpcAPI.Return.getDefaultInstance() : result_; + } + /** + * .protocol.Return result = 2; + */ + public org.tron.api.GrpcAPI.ReturnOrBuilder getResultOrBuilder() { + return getResult(); + } + + public static final int TXID_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString txid_; + /** + *
+     *transaction id =  sha256(transaction.rowdata)
+     * 
+ * + * bytes txid = 3; + */ + public com.google.protobuf.ByteString getTxid() { + return txid_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (transaction_ != null) { + output.writeMessage(1, getTransaction()); + } + if (result_ != null) { + output.writeMessage(2, getResult()); + } + if (!txid_.isEmpty()) { + output.writeBytes(3, txid_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (transaction_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getTransaction()); + } + if (result_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getResult()); + } + if (!txid_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, txid_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.EasyTransferResponse)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.EasyTransferResponse other = (org.tron.api.GrpcAPI.EasyTransferResponse) obj; + + boolean result = true; + result = result && (hasTransaction() == other.hasTransaction()); + if (hasTransaction()) { + result = result && getTransaction() + .equals(other.getTransaction()); + } + result = result && (hasResult() == other.hasResult()); + if (hasResult()) { + result = result && getResult() + .equals(other.getResult()); + } + result = result && getTxid() + .equals(other.getTxid()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasTransaction()) { + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + } + if (hasResult()) { + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + getResult().hashCode(); + } + hash = (37 * hash) + TXID_FIELD_NUMBER; + hash = (53 * hash) + getTxid().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.EasyTransferResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.EasyTransferResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.EasyTransferResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.EasyTransferResponse) + org.tron.api.GrpcAPI.EasyTransferResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.EasyTransferResponse.class, org.tron.api.GrpcAPI.EasyTransferResponse.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.EasyTransferResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (transactionBuilder_ == null) { + transaction_ = null; + } else { + transaction_ = null; + transactionBuilder_ = null; + } + if (resultBuilder_ == null) { + result_ = null; + } else { + result_ = null; + resultBuilder_ = null; + } + txid_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_EasyTransferResponse_descriptor; + } + + public org.tron.api.GrpcAPI.EasyTransferResponse getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.EasyTransferResponse.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.EasyTransferResponse build() { + org.tron.api.GrpcAPI.EasyTransferResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.EasyTransferResponse buildPartial() { + org.tron.api.GrpcAPI.EasyTransferResponse result = new org.tron.api.GrpcAPI.EasyTransferResponse(this); + if (transactionBuilder_ == null) { + result.transaction_ = transaction_; + } else { + result.transaction_ = transactionBuilder_.build(); + } + if (resultBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = resultBuilder_.build(); + } + result.txid_ = txid_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.EasyTransferResponse) { + return mergeFrom((org.tron.api.GrpcAPI.EasyTransferResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.EasyTransferResponse other) { + if (other == org.tron.api.GrpcAPI.EasyTransferResponse.getDefaultInstance()) return this; + if (other.hasTransaction()) { + mergeTransaction(other.getTransaction()); + } + if (other.hasResult()) { + mergeResult(other.getResult()); + } + if (other.getTxid() != com.google.protobuf.ByteString.EMPTY) { + setTxid(other.getTxid()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.EasyTransferResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.EasyTransferResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Protocol.Transaction transaction_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> transactionBuilder_; + /** + * .protocol.Transaction transaction = 1; + */ + public boolean hasTransaction() { + return transactionBuilder_ != null || transaction_ != null; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction() { + if (transactionBuilder_ == null) { + return transaction_ == null ? org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } else { + return transactionBuilder_.getMessage(); + } + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder setTransaction(org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + onChanged(); + } else { + transactionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder setTransaction( + org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionBuilder_ == null) { + transaction_ = builderForValue.build(); + onChanged(); + } else { + transactionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder mergeTransaction(org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (transaction_ != null) { + transaction_ = + org.tron.protos.Protocol.Transaction.newBuilder(transaction_).mergeFrom(value).buildPartial(); + } else { + transaction_ = value; + } + onChanged(); + } else { + transactionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder clearTransaction() { + if (transactionBuilder_ == null) { + transaction_ = null; + onChanged(); + } else { + transaction_ = null; + transactionBuilder_ = null; + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder getTransactionBuilder() { + + onChanged(); + return getTransactionFieldBuilder().getBuilder(); + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder() { + if (transactionBuilder_ != null) { + return transactionBuilder_.getMessageOrBuilder(); + } else { + return transaction_ == null ? + org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } + } + /** + * .protocol.Transaction transaction = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> + getTransactionFieldBuilder() { + if (transactionBuilder_ == null) { + transactionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder>( + getTransaction(), + getParentForChildren(), + isClean()); + transaction_ = null; + } + return transactionBuilder_; + } + + private org.tron.api.GrpcAPI.Return result_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Return, org.tron.api.GrpcAPI.Return.Builder, org.tron.api.GrpcAPI.ReturnOrBuilder> resultBuilder_; + /** + * .protocol.Return result = 2; + */ + public boolean hasResult() { + return resultBuilder_ != null || result_ != null; + } + /** + * .protocol.Return result = 2; + */ + public org.tron.api.GrpcAPI.Return getResult() { + if (resultBuilder_ == null) { + return result_ == null ? org.tron.api.GrpcAPI.Return.getDefaultInstance() : result_; + } else { + return resultBuilder_.getMessage(); + } + } + /** + * .protocol.Return result = 2; + */ + public Builder setResult(org.tron.api.GrpcAPI.Return value) { + if (resultBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + resultBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Return result = 2; + */ + public Builder setResult( + org.tron.api.GrpcAPI.Return.Builder builderForValue) { + if (resultBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + resultBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Return result = 2; + */ + public Builder mergeResult(org.tron.api.GrpcAPI.Return value) { + if (resultBuilder_ == null) { + if (result_ != null) { + result_ = + org.tron.api.GrpcAPI.Return.newBuilder(result_).mergeFrom(value).buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + resultBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Return result = 2; + */ + public Builder clearResult() { + if (resultBuilder_ == null) { + result_ = null; + onChanged(); + } else { + result_ = null; + resultBuilder_ = null; + } + + return this; + } + /** + * .protocol.Return result = 2; + */ + public org.tron.api.GrpcAPI.Return.Builder getResultBuilder() { + + onChanged(); + return getResultFieldBuilder().getBuilder(); + } + /** + * .protocol.Return result = 2; + */ + public org.tron.api.GrpcAPI.ReturnOrBuilder getResultOrBuilder() { + if (resultBuilder_ != null) { + return resultBuilder_.getMessageOrBuilder(); + } else { + return result_ == null ? + org.tron.api.GrpcAPI.Return.getDefaultInstance() : result_; + } + } + /** + * .protocol.Return result = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Return, org.tron.api.GrpcAPI.Return.Builder, org.tron.api.GrpcAPI.ReturnOrBuilder> + getResultFieldBuilder() { + if (resultBuilder_ == null) { + resultBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Return, org.tron.api.GrpcAPI.Return.Builder, org.tron.api.GrpcAPI.ReturnOrBuilder>( + getResult(), + getParentForChildren(), + isClean()); + result_ = null; + } + return resultBuilder_; + } + + private com.google.protobuf.ByteString txid_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       *transaction id =  sha256(transaction.rowdata)
+       * 
+ * + * bytes txid = 3; + */ + public com.google.protobuf.ByteString getTxid() { + return txid_; + } + /** + *
+       *transaction id =  sha256(transaction.rowdata)
+       * 
+ * + * bytes txid = 3; + */ + public Builder setTxid(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + txid_ = value; + onChanged(); + return this; + } + /** + *
+       *transaction id =  sha256(transaction.rowdata)
+       * 
+ * + * bytes txid = 3; + */ + public Builder clearTxid() { + + txid_ = getDefaultInstance().getTxid(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.EasyTransferResponse) + } + + // @@protoc_insertion_point(class_scope:protocol.EasyTransferResponse) + private static final org.tron.api.GrpcAPI.EasyTransferResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.EasyTransferResponse(); + } + + public static org.tron.api.GrpcAPI.EasyTransferResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public EasyTransferResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EasyTransferResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.EasyTransferResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AddressPrKeyPairMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AddressPrKeyPairMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * string address = 1; + */ + java.lang.String getAddress(); + /** + * string address = 1; + */ + com.google.protobuf.ByteString + getAddressBytes(); + + /** + * string privateKey = 2; + */ + java.lang.String getPrivateKey(); + /** + * string privateKey = 2; + */ + com.google.protobuf.ByteString + getPrivateKeyBytes(); + } + /** + * Protobuf type {@code protocol.AddressPrKeyPairMessage} + */ + public static final class AddressPrKeyPairMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AddressPrKeyPairMessage) + AddressPrKeyPairMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use AddressPrKeyPairMessage.newBuilder() to construct. + private AddressPrKeyPairMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AddressPrKeyPairMessage() { + address_ = ""; + privateKey_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AddressPrKeyPairMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + address_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + privateKey_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AddressPrKeyPairMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AddressPrKeyPairMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AddressPrKeyPairMessage.class, org.tron.api.GrpcAPI.AddressPrKeyPairMessage.Builder.class); + } + + public static final int ADDRESS_FIELD_NUMBER = 1; + private volatile java.lang.Object address_; + /** + * string address = 1; + */ + public java.lang.String getAddress() { + java.lang.Object ref = address_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + address_ = s; + return s; + } + } + /** + * string address = 1; + */ + public com.google.protobuf.ByteString + getAddressBytes() { + java.lang.Object ref = address_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + address_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PRIVATEKEY_FIELD_NUMBER = 2; + private volatile java.lang.Object privateKey_; + /** + * string privateKey = 2; + */ + public java.lang.String getPrivateKey() { + java.lang.Object ref = privateKey_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + privateKey_ = s; + return s; + } + } + /** + * string privateKey = 2; + */ + public com.google.protobuf.ByteString + getPrivateKeyBytes() { + java.lang.Object ref = privateKey_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + privateKey_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getAddressBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, address_); + } + if (!getPrivateKeyBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, privateKey_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getAddressBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, address_); + } + if (!getPrivateKeyBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, privateKey_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.AddressPrKeyPairMessage)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.AddressPrKeyPairMessage other = (org.tron.api.GrpcAPI.AddressPrKeyPairMessage) obj; + + boolean result = true; + result = result && getAddress() + .equals(other.getAddress()); + result = result && getPrivateKey() + .equals(other.getPrivateKey()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + hash = (37 * hash) + PRIVATEKEY_FIELD_NUMBER; + hash = (53 * hash) + getPrivateKey().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.AddressPrKeyPairMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AddressPrKeyPairMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AddressPrKeyPairMessage) + org.tron.api.GrpcAPI.AddressPrKeyPairMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_AddressPrKeyPairMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_AddressPrKeyPairMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.AddressPrKeyPairMessage.class, org.tron.api.GrpcAPI.AddressPrKeyPairMessage.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.AddressPrKeyPairMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + address_ = ""; + + privateKey_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_AddressPrKeyPairMessage_descriptor; + } + + public org.tron.api.GrpcAPI.AddressPrKeyPairMessage getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.AddressPrKeyPairMessage.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.AddressPrKeyPairMessage build() { + org.tron.api.GrpcAPI.AddressPrKeyPairMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.AddressPrKeyPairMessage buildPartial() { + org.tron.api.GrpcAPI.AddressPrKeyPairMessage result = new org.tron.api.GrpcAPI.AddressPrKeyPairMessage(this); + result.address_ = address_; + result.privateKey_ = privateKey_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.AddressPrKeyPairMessage) { + return mergeFrom((org.tron.api.GrpcAPI.AddressPrKeyPairMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.AddressPrKeyPairMessage other) { + if (other == org.tron.api.GrpcAPI.AddressPrKeyPairMessage.getDefaultInstance()) return this; + if (!other.getAddress().isEmpty()) { + address_ = other.address_; + onChanged(); + } + if (!other.getPrivateKey().isEmpty()) { + privateKey_ = other.privateKey_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.AddressPrKeyPairMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.AddressPrKeyPairMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object address_ = ""; + /** + * string address = 1; + */ + public java.lang.String getAddress() { + java.lang.Object ref = address_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + address_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string address = 1; + */ + public com.google.protobuf.ByteString + getAddressBytes() { + java.lang.Object ref = address_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + address_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string address = 1; + */ + public Builder setAddress( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + * string address = 1; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + /** + * string address = 1; + */ + public Builder setAddressBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + address_ = value; + onChanged(); + return this; + } + + private java.lang.Object privateKey_ = ""; + /** + * string privateKey = 2; + */ + public java.lang.String getPrivateKey() { + java.lang.Object ref = privateKey_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + privateKey_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string privateKey = 2; + */ + public com.google.protobuf.ByteString + getPrivateKeyBytes() { + java.lang.Object ref = privateKey_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + privateKey_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string privateKey = 2; + */ + public Builder setPrivateKey( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + privateKey_ = value; + onChanged(); + return this; + } + /** + * string privateKey = 2; + */ + public Builder clearPrivateKey() { + + privateKey_ = getDefaultInstance().getPrivateKey(); + onChanged(); + return this; + } + /** + * string privateKey = 2; + */ + public Builder setPrivateKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + privateKey_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AddressPrKeyPairMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.AddressPrKeyPairMessage) + private static final org.tron.api.GrpcAPI.AddressPrKeyPairMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.AddressPrKeyPairMessage(); + } + + public static org.tron.api.GrpcAPI.AddressPrKeyPairMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AddressPrKeyPairMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AddressPrKeyPairMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.AddressPrKeyPairMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionExtentionOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionExtention) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Transaction transaction = 1; + */ + boolean hasTransaction(); + /** + * .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.Transaction getTransaction(); + /** + * .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder(); + + /** + *
+     *transaction id =  sha256(transaction.rowdata)
+     * 
+ * + * bytes txid = 2; + */ + com.google.protobuf.ByteString getTxid(); + + /** + * repeated bytes constant_result = 3; + */ + java.util.List getConstantResultList(); + /** + * repeated bytes constant_result = 3; + */ + int getConstantResultCount(); + /** + * repeated bytes constant_result = 3; + */ + com.google.protobuf.ByteString getConstantResult(int index); + + /** + * .protocol.Return result = 4; + */ + boolean hasResult(); + /** + * .protocol.Return result = 4; + */ + org.tron.api.GrpcAPI.Return getResult(); + /** + * .protocol.Return result = 4; + */ + org.tron.api.GrpcAPI.ReturnOrBuilder getResultOrBuilder(); + } + /** + * Protobuf type {@code protocol.TransactionExtention} + */ + public static final class TransactionExtention extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionExtention) + TransactionExtentionOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionExtention.newBuilder() to construct. + private TransactionExtention(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionExtention() { + txid_ = com.google.protobuf.ByteString.EMPTY; + constantResult_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionExtention( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.Transaction.Builder subBuilder = null; + if (transaction_ != null) { + subBuilder = transaction_.toBuilder(); + } + transaction_ = input.readMessage(org.tron.protos.Protocol.Transaction.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(transaction_); + transaction_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + + txid_ = input.readBytes(); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + constantResult_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + constantResult_.add(input.readBytes()); + break; + } + case 34: { + org.tron.api.GrpcAPI.Return.Builder subBuilder = null; + if (result_ != null) { + subBuilder = result_.toBuilder(); + } + result_ = input.readMessage(org.tron.api.GrpcAPI.Return.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(result_); + result_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + constantResult_ = java.util.Collections.unmodifiableList(constantResult_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionExtention.class, org.tron.api.GrpcAPI.TransactionExtention.Builder.class); + } + + private int bitField0_; + public static final int TRANSACTION_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.Transaction transaction_; + /** + * .protocol.Transaction transaction = 1; + */ + public boolean hasTransaction() { + return transaction_ != null; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction() { + return transaction_ == null ? org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder() { + return getTransaction(); + } + + public static final int TXID_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString txid_; + /** + *
+     *transaction id =  sha256(transaction.rowdata)
+     * 
+ * + * bytes txid = 2; + */ + public com.google.protobuf.ByteString getTxid() { + return txid_; + } + + public static final int CONSTANT_RESULT_FIELD_NUMBER = 3; + private java.util.List constantResult_; + /** + * repeated bytes constant_result = 3; + */ + public java.util.List + getConstantResultList() { + return constantResult_; + } + /** + * repeated bytes constant_result = 3; + */ + public int getConstantResultCount() { + return constantResult_.size(); + } + /** + * repeated bytes constant_result = 3; + */ + public com.google.protobuf.ByteString getConstantResult(int index) { + return constantResult_.get(index); + } + + public static final int RESULT_FIELD_NUMBER = 4; + private org.tron.api.GrpcAPI.Return result_; + /** + * .protocol.Return result = 4; + */ + public boolean hasResult() { + return result_ != null; + } + /** + * .protocol.Return result = 4; + */ + public org.tron.api.GrpcAPI.Return getResult() { + return result_ == null ? org.tron.api.GrpcAPI.Return.getDefaultInstance() : result_; + } + /** + * .protocol.Return result = 4; + */ + public org.tron.api.GrpcAPI.ReturnOrBuilder getResultOrBuilder() { + return getResult(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (transaction_ != null) { + output.writeMessage(1, getTransaction()); + } + if (!txid_.isEmpty()) { + output.writeBytes(2, txid_); + } + for (int i = 0; i < constantResult_.size(); i++) { + output.writeBytes(3, constantResult_.get(i)); + } + if (result_ != null) { + output.writeMessage(4, getResult()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (transaction_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getTransaction()); + } + if (!txid_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, txid_); + } + { + int dataSize = 0; + for (int i = 0; i < constantResult_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(constantResult_.get(i)); + } + size += dataSize; + size += 1 * getConstantResultList().size(); + } + if (result_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getResult()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionExtention)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionExtention other = (org.tron.api.GrpcAPI.TransactionExtention) obj; + + boolean result = true; + result = result && (hasTransaction() == other.hasTransaction()); + if (hasTransaction()) { + result = result && getTransaction() + .equals(other.getTransaction()); + } + result = result && getTxid() + .equals(other.getTxid()); + result = result && getConstantResultList() + .equals(other.getConstantResultList()); + result = result && (hasResult() == other.hasResult()); + if (hasResult()) { + result = result && getResult() + .equals(other.getResult()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasTransaction()) { + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + } + hash = (37 * hash) + TXID_FIELD_NUMBER; + hash = (53 * hash) + getTxid().hashCode(); + if (getConstantResultCount() > 0) { + hash = (37 * hash) + CONSTANT_RESULT_FIELD_NUMBER; + hash = (53 * hash) + getConstantResultList().hashCode(); + } + if (hasResult()) { + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + getResult().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionExtention parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionExtention prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionExtention} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionExtention) + org.tron.api.GrpcAPI.TransactionExtentionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionExtention.class, org.tron.api.GrpcAPI.TransactionExtention.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionExtention.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (transactionBuilder_ == null) { + transaction_ = null; + } else { + transaction_ = null; + transactionBuilder_ = null; + } + txid_ = com.google.protobuf.ByteString.EMPTY; + + constantResult_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + if (resultBuilder_ == null) { + result_ = null; + } else { + result_ = null; + resultBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionExtention_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionExtention getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionExtention build() { + org.tron.api.GrpcAPI.TransactionExtention result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionExtention buildPartial() { + org.tron.api.GrpcAPI.TransactionExtention result = new org.tron.api.GrpcAPI.TransactionExtention(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (transactionBuilder_ == null) { + result.transaction_ = transaction_; + } else { + result.transaction_ = transactionBuilder_.build(); + } + result.txid_ = txid_; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + constantResult_ = java.util.Collections.unmodifiableList(constantResult_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.constantResult_ = constantResult_; + if (resultBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = resultBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionExtention) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionExtention)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionExtention other) { + if (other == org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance()) return this; + if (other.hasTransaction()) { + mergeTransaction(other.getTransaction()); + } + if (other.getTxid() != com.google.protobuf.ByteString.EMPTY) { + setTxid(other.getTxid()); + } + if (!other.constantResult_.isEmpty()) { + if (constantResult_.isEmpty()) { + constantResult_ = other.constantResult_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureConstantResultIsMutable(); + constantResult_.addAll(other.constantResult_); + } + onChanged(); + } + if (other.hasResult()) { + mergeResult(other.getResult()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionExtention parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionExtention) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private org.tron.protos.Protocol.Transaction transaction_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> transactionBuilder_; + /** + * .protocol.Transaction transaction = 1; + */ + public boolean hasTransaction() { + return transactionBuilder_ != null || transaction_ != null; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction() { + if (transactionBuilder_ == null) { + return transaction_ == null ? org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } else { + return transactionBuilder_.getMessage(); + } + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder setTransaction(org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + onChanged(); + } else { + transactionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder setTransaction( + org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionBuilder_ == null) { + transaction_ = builderForValue.build(); + onChanged(); + } else { + transactionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder mergeTransaction(org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (transaction_ != null) { + transaction_ = + org.tron.protos.Protocol.Transaction.newBuilder(transaction_).mergeFrom(value).buildPartial(); + } else { + transaction_ = value; + } + onChanged(); + } else { + transactionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder clearTransaction() { + if (transactionBuilder_ == null) { + transaction_ = null; + onChanged(); + } else { + transaction_ = null; + transactionBuilder_ = null; + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder getTransactionBuilder() { + + onChanged(); + return getTransactionFieldBuilder().getBuilder(); + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder() { + if (transactionBuilder_ != null) { + return transactionBuilder_.getMessageOrBuilder(); + } else { + return transaction_ == null ? + org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } + } + /** + * .protocol.Transaction transaction = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> + getTransactionFieldBuilder() { + if (transactionBuilder_ == null) { + transactionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder>( + getTransaction(), + getParentForChildren(), + isClean()); + transaction_ = null; + } + return transactionBuilder_; + } + + private com.google.protobuf.ByteString txid_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       *transaction id =  sha256(transaction.rowdata)
+       * 
+ * + * bytes txid = 2; + */ + public com.google.protobuf.ByteString getTxid() { + return txid_; + } + /** + *
+       *transaction id =  sha256(transaction.rowdata)
+       * 
+ * + * bytes txid = 2; + */ + public Builder setTxid(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + txid_ = value; + onChanged(); + return this; + } + /** + *
+       *transaction id =  sha256(transaction.rowdata)
+       * 
+ * + * bytes txid = 2; + */ + public Builder clearTxid() { + + txid_ = getDefaultInstance().getTxid(); + onChanged(); + return this; + } + + private java.util.List constantResult_ = java.util.Collections.emptyList(); + private void ensureConstantResultIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + constantResult_ = new java.util.ArrayList(constantResult_); + bitField0_ |= 0x00000004; + } + } + /** + * repeated bytes constant_result = 3; + */ + public java.util.List + getConstantResultList() { + return java.util.Collections.unmodifiableList(constantResult_); + } + /** + * repeated bytes constant_result = 3; + */ + public int getConstantResultCount() { + return constantResult_.size(); + } + /** + * repeated bytes constant_result = 3; + */ + public com.google.protobuf.ByteString getConstantResult(int index) { + return constantResult_.get(index); + } + /** + * repeated bytes constant_result = 3; + */ + public Builder setConstantResult( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureConstantResultIsMutable(); + constantResult_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes constant_result = 3; + */ + public Builder addConstantResult(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureConstantResultIsMutable(); + constantResult_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes constant_result = 3; + */ + public Builder addAllConstantResult( + java.lang.Iterable values) { + ensureConstantResultIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, constantResult_); + onChanged(); + return this; + } + /** + * repeated bytes constant_result = 3; + */ + public Builder clearConstantResult() { + constantResult_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + private org.tron.api.GrpcAPI.Return result_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Return, org.tron.api.GrpcAPI.Return.Builder, org.tron.api.GrpcAPI.ReturnOrBuilder> resultBuilder_; + /** + * .protocol.Return result = 4; + */ + public boolean hasResult() { + return resultBuilder_ != null || result_ != null; + } + /** + * .protocol.Return result = 4; + */ + public org.tron.api.GrpcAPI.Return getResult() { + if (resultBuilder_ == null) { + return result_ == null ? org.tron.api.GrpcAPI.Return.getDefaultInstance() : result_; + } else { + return resultBuilder_.getMessage(); + } + } + /** + * .protocol.Return result = 4; + */ + public Builder setResult(org.tron.api.GrpcAPI.Return value) { + if (resultBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + resultBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Return result = 4; + */ + public Builder setResult( + org.tron.api.GrpcAPI.Return.Builder builderForValue) { + if (resultBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + resultBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Return result = 4; + */ + public Builder mergeResult(org.tron.api.GrpcAPI.Return value) { + if (resultBuilder_ == null) { + if (result_ != null) { + result_ = + org.tron.api.GrpcAPI.Return.newBuilder(result_).mergeFrom(value).buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + resultBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Return result = 4; + */ + public Builder clearResult() { + if (resultBuilder_ == null) { + result_ = null; + onChanged(); + } else { + result_ = null; + resultBuilder_ = null; + } + + return this; + } + /** + * .protocol.Return result = 4; + */ + public org.tron.api.GrpcAPI.Return.Builder getResultBuilder() { + + onChanged(); + return getResultFieldBuilder().getBuilder(); + } + /** + * .protocol.Return result = 4; + */ + public org.tron.api.GrpcAPI.ReturnOrBuilder getResultOrBuilder() { + if (resultBuilder_ != null) { + return resultBuilder_.getMessageOrBuilder(); + } else { + return result_ == null ? + org.tron.api.GrpcAPI.Return.getDefaultInstance() : result_; + } + } + /** + * .protocol.Return result = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Return, org.tron.api.GrpcAPI.Return.Builder, org.tron.api.GrpcAPI.ReturnOrBuilder> + getResultFieldBuilder() { + if (resultBuilder_ == null) { + resultBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.Return, org.tron.api.GrpcAPI.Return.Builder, org.tron.api.GrpcAPI.ReturnOrBuilder>( + getResult(), + getParentForChildren(), + isClean()); + result_ = null; + } + return resultBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionExtention) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionExtention) + private static final org.tron.api.GrpcAPI.TransactionExtention DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionExtention(); + } + + public static org.tron.api.GrpcAPI.TransactionExtention getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionExtention parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionExtention(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionExtention getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockExtentionOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockExtention) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + java.util.List + getTransactionsList(); + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + org.tron.api.GrpcAPI.TransactionExtention getTransactions(int index); + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + int getTransactionsCount(); + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + java.util.List + getTransactionsOrBuilderList(); + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionsOrBuilder( + int index); + + /** + * .protocol.BlockHeader block_header = 2; + */ + boolean hasBlockHeader(); + /** + * .protocol.BlockHeader block_header = 2; + */ + org.tron.protos.Protocol.BlockHeader getBlockHeader(); + /** + * .protocol.BlockHeader block_header = 2; + */ + org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeaderOrBuilder(); + + /** + * bytes blockid = 3; + */ + com.google.protobuf.ByteString getBlockid(); + } + /** + * Protobuf type {@code protocol.BlockExtention} + */ + public static final class BlockExtention extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockExtention) + BlockExtentionOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockExtention.newBuilder() to construct. + private BlockExtention(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockExtention() { + transactions_ = java.util.Collections.emptyList(); + blockid_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockExtention( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + transactions_.add( + input.readMessage(org.tron.api.GrpcAPI.TransactionExtention.parser(), extensionRegistry)); + break; + } + case 18: { + org.tron.protos.Protocol.BlockHeader.Builder subBuilder = null; + if (blockHeader_ != null) { + subBuilder = blockHeader_.toBuilder(); + } + blockHeader_ = input.readMessage(org.tron.protos.Protocol.BlockHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(blockHeader_); + blockHeader_ = subBuilder.buildPartial(); + } + + break; + } + case 26: { + + blockid_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockExtention.class, org.tron.api.GrpcAPI.BlockExtention.Builder.class); + } + + private int bitField0_; + public static final int TRANSACTIONS_FIELD_NUMBER = 1; + private java.util.List transactions_; + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public java.util.List getTransactionsList() { + return transactions_; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public java.util.List + getTransactionsOrBuilderList() { + return transactions_; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public int getTransactionsCount() { + return transactions_.size(); + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransactions(int index) { + return transactions_.get(index); + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionsOrBuilder( + int index) { + return transactions_.get(index); + } + + public static final int BLOCK_HEADER_FIELD_NUMBER = 2; + private org.tron.protos.Protocol.BlockHeader blockHeader_; + /** + * .protocol.BlockHeader block_header = 2; + */ + public boolean hasBlockHeader() { + return blockHeader_ != null; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeader getBlockHeader() { + return blockHeader_ == null ? org.tron.protos.Protocol.BlockHeader.getDefaultInstance() : blockHeader_; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeaderOrBuilder() { + return getBlockHeader(); + } + + public static final int BLOCKID_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString blockid_; + /** + * bytes blockid = 3; + */ + public com.google.protobuf.ByteString getBlockid() { + return blockid_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < transactions_.size(); i++) { + output.writeMessage(1, transactions_.get(i)); + } + if (blockHeader_ != null) { + output.writeMessage(2, getBlockHeader()); + } + if (!blockid_.isEmpty()) { + output.writeBytes(3, blockid_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < transactions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, transactions_.get(i)); + } + if (blockHeader_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getBlockHeader()); + } + if (!blockid_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, blockid_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.BlockExtention)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.BlockExtention other = (org.tron.api.GrpcAPI.BlockExtention) obj; + + boolean result = true; + result = result && getTransactionsList() + .equals(other.getTransactionsList()); + result = result && (hasBlockHeader() == other.hasBlockHeader()); + if (hasBlockHeader()) { + result = result && getBlockHeader() + .equals(other.getBlockHeader()); + } + result = result && getBlockid() + .equals(other.getBlockid()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTransactionsCount() > 0) { + hash = (37 * hash) + TRANSACTIONS_FIELD_NUMBER; + hash = (53 * hash) + getTransactionsList().hashCode(); + } + if (hasBlockHeader()) { + hash = (37 * hash) + BLOCK_HEADER_FIELD_NUMBER; + hash = (53 * hash) + getBlockHeader().hashCode(); + } + hash = (37 * hash) + BLOCKID_FIELD_NUMBER; + hash = (53 * hash) + getBlockid().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockExtention parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockExtention parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockExtention parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.BlockExtention prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockExtention} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockExtention) + org.tron.api.GrpcAPI.BlockExtentionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockExtention.class, org.tron.api.GrpcAPI.BlockExtention.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.BlockExtention.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTransactionsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + transactionsBuilder_.clear(); + } + if (blockHeaderBuilder_ == null) { + blockHeader_ = null; + } else { + blockHeader_ = null; + blockHeaderBuilder_ = null; + } + blockid_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockExtention_descriptor; + } + + public org.tron.api.GrpcAPI.BlockExtention getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.BlockExtention build() { + org.tron.api.GrpcAPI.BlockExtention result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.BlockExtention buildPartial() { + org.tron.api.GrpcAPI.BlockExtention result = new org.tron.api.GrpcAPI.BlockExtention(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (transactionsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.transactions_ = transactions_; + } else { + result.transactions_ = transactionsBuilder_.build(); + } + if (blockHeaderBuilder_ == null) { + result.blockHeader_ = blockHeader_; + } else { + result.blockHeader_ = blockHeaderBuilder_.build(); + } + result.blockid_ = blockid_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.BlockExtention) { + return mergeFrom((org.tron.api.GrpcAPI.BlockExtention)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.BlockExtention other) { + if (other == org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance()) return this; + if (transactionsBuilder_ == null) { + if (!other.transactions_.isEmpty()) { + if (transactions_.isEmpty()) { + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTransactionsIsMutable(); + transactions_.addAll(other.transactions_); + } + onChanged(); + } + } else { + if (!other.transactions_.isEmpty()) { + if (transactionsBuilder_.isEmpty()) { + transactionsBuilder_.dispose(); + transactionsBuilder_ = null; + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000001); + transactionsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTransactionsFieldBuilder() : null; + } else { + transactionsBuilder_.addAllMessages(other.transactions_); + } + } + } + if (other.hasBlockHeader()) { + mergeBlockHeader(other.getBlockHeader()); + } + if (other.getBlockid() != com.google.protobuf.ByteString.EMPTY) { + setBlockid(other.getBlockid()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.BlockExtention parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.BlockExtention) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List transactions_ = + java.util.Collections.emptyList(); + private void ensureTransactionsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = new java.util.ArrayList(transactions_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> transactionsBuilder_; + + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public java.util.List getTransactionsList() { + if (transactionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(transactions_); + } else { + return transactionsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public int getTransactionsCount() { + if (transactionsBuilder_ == null) { + return transactions_.size(); + } else { + return transactionsBuilder_.getCount(); + } + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransactions(int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); + } else { + return transactionsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder setTransactions( + int index, org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.set(index, value); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder setTransactions( + int index, org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.set(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder addTransactions(org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(value); + onChanged(); + } else { + transactionsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder addTransactions( + int index, org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(index, value); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder addTransactions( + org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder addTransactions( + int index, org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder addAllTransactions( + java.lang.Iterable values) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, transactions_); + onChanged(); + } else { + transactionsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder clearTransactions() { + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + transactionsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public Builder removeTransactions(int index) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.remove(index); + onChanged(); + } else { + transactionsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder getTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionsOrBuilder( + int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); } else { + return transactionsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public java.util.List + getTransactionsOrBuilderList() { + if (transactionsBuilder_ != null) { + return transactionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transactions_); + } + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder addTransactionsBuilder() { + return getTransactionsFieldBuilder().addBuilder( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder addTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().addBuilder( + index, org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionExtention transactions = 1; + */ + public java.util.List + getTransactionsBuilderList() { + return getTransactionsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> + getTransactionsFieldBuilder() { + if (transactionsBuilder_ == null) { + transactionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder>( + transactions_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + transactions_ = null; + } + return transactionsBuilder_; + } + + private org.tron.protos.Protocol.BlockHeader blockHeader_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder> blockHeaderBuilder_; + /** + * .protocol.BlockHeader block_header = 2; + */ + public boolean hasBlockHeader() { + return blockHeaderBuilder_ != null || blockHeader_ != null; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeader getBlockHeader() { + if (blockHeaderBuilder_ == null) { + return blockHeader_ == null ? org.tron.protos.Protocol.BlockHeader.getDefaultInstance() : blockHeader_; + } else { + return blockHeaderBuilder_.getMessage(); + } + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder setBlockHeader(org.tron.protos.Protocol.BlockHeader value) { + if (blockHeaderBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + blockHeader_ = value; + onChanged(); + } else { + blockHeaderBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder setBlockHeader( + org.tron.protos.Protocol.BlockHeader.Builder builderForValue) { + if (blockHeaderBuilder_ == null) { + blockHeader_ = builderForValue.build(); + onChanged(); + } else { + blockHeaderBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder mergeBlockHeader(org.tron.protos.Protocol.BlockHeader value) { + if (blockHeaderBuilder_ == null) { + if (blockHeader_ != null) { + blockHeader_ = + org.tron.protos.Protocol.BlockHeader.newBuilder(blockHeader_).mergeFrom(value).buildPartial(); + } else { + blockHeader_ = value; + } + onChanged(); + } else { + blockHeaderBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder clearBlockHeader() { + if (blockHeaderBuilder_ == null) { + blockHeader_ = null; + onChanged(); + } else { + blockHeader_ = null; + blockHeaderBuilder_ = null; + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeader.Builder getBlockHeaderBuilder() { + + onChanged(); + return getBlockHeaderFieldBuilder().getBuilder(); + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeaderOrBuilder() { + if (blockHeaderBuilder_ != null) { + return blockHeaderBuilder_.getMessageOrBuilder(); + } else { + return blockHeader_ == null ? + org.tron.protos.Protocol.BlockHeader.getDefaultInstance() : blockHeader_; + } + } + /** + * .protocol.BlockHeader block_header = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder> + getBlockHeaderFieldBuilder() { + if (blockHeaderBuilder_ == null) { + blockHeaderBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder>( + getBlockHeader(), + getParentForChildren(), + isClean()); + blockHeader_ = null; + } + return blockHeaderBuilder_; + } + + private com.google.protobuf.ByteString blockid_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes blockid = 3; + */ + public com.google.protobuf.ByteString getBlockid() { + return blockid_; + } + /** + * bytes blockid = 3; + */ + public Builder setBlockid(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + blockid_ = value; + onChanged(); + return this; + } + /** + * bytes blockid = 3; + */ + public Builder clearBlockid() { + + blockid_ = getDefaultInstance().getBlockid(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockExtention) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockExtention) + private static final org.tron.api.GrpcAPI.BlockExtention DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.BlockExtention(); + } + + public static org.tron.api.GrpcAPI.BlockExtention getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockExtention parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockExtention(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.BlockExtention getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockListExtentionOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockListExtention) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.BlockExtention block = 1; + */ + java.util.List + getBlockList(); + /** + * repeated .protocol.BlockExtention block = 1; + */ + org.tron.api.GrpcAPI.BlockExtention getBlock(int index); + /** + * repeated .protocol.BlockExtention block = 1; + */ + int getBlockCount(); + /** + * repeated .protocol.BlockExtention block = 1; + */ + java.util.List + getBlockOrBuilderList(); + /** + * repeated .protocol.BlockExtention block = 1; + */ + org.tron.api.GrpcAPI.BlockExtentionOrBuilder getBlockOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.BlockListExtention} + */ + public static final class BlockListExtention extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockListExtention) + BlockListExtentionOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockListExtention.newBuilder() to construct. + private BlockListExtention(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockListExtention() { + block_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockListExtention( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + block_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + block_.add( + input.readMessage(org.tron.api.GrpcAPI.BlockExtention.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + block_ = java.util.Collections.unmodifiableList(block_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockListExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockListExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockListExtention.class, org.tron.api.GrpcAPI.BlockListExtention.Builder.class); + } + + public static final int BLOCK_FIELD_NUMBER = 1; + private java.util.List block_; + /** + * repeated .protocol.BlockExtention block = 1; + */ + public java.util.List getBlockList() { + return block_; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public java.util.List + getBlockOrBuilderList() { + return block_; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public int getBlockCount() { + return block_.size(); + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public org.tron.api.GrpcAPI.BlockExtention getBlock(int index) { + return block_.get(index); + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public org.tron.api.GrpcAPI.BlockExtentionOrBuilder getBlockOrBuilder( + int index) { + return block_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < block_.size(); i++) { + output.writeMessage(1, block_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < block_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, block_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.BlockListExtention)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.BlockListExtention other = (org.tron.api.GrpcAPI.BlockListExtention) obj; + + boolean result = true; + result = result && getBlockList() + .equals(other.getBlockList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getBlockCount() > 0) { + hash = (37 * hash) + BLOCK_FIELD_NUMBER; + hash = (53 * hash) + getBlockList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.BlockListExtention parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.BlockListExtention prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockListExtention} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockListExtention) + org.tron.api.GrpcAPI.BlockListExtentionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockListExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockListExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.BlockListExtention.class, org.tron.api.GrpcAPI.BlockListExtention.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.BlockListExtention.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getBlockFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (blockBuilder_ == null) { + block_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + blockBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_BlockListExtention_descriptor; + } + + public org.tron.api.GrpcAPI.BlockListExtention getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.BlockListExtention.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.BlockListExtention build() { + org.tron.api.GrpcAPI.BlockListExtention result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.BlockListExtention buildPartial() { + org.tron.api.GrpcAPI.BlockListExtention result = new org.tron.api.GrpcAPI.BlockListExtention(this); + int from_bitField0_ = bitField0_; + if (blockBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + block_ = java.util.Collections.unmodifiableList(block_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.block_ = block_; + } else { + result.block_ = blockBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.BlockListExtention) { + return mergeFrom((org.tron.api.GrpcAPI.BlockListExtention)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.BlockListExtention other) { + if (other == org.tron.api.GrpcAPI.BlockListExtention.getDefaultInstance()) return this; + if (blockBuilder_ == null) { + if (!other.block_.isEmpty()) { + if (block_.isEmpty()) { + block_ = other.block_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBlockIsMutable(); + block_.addAll(other.block_); + } + onChanged(); + } + } else { + if (!other.block_.isEmpty()) { + if (blockBuilder_.isEmpty()) { + blockBuilder_.dispose(); + blockBuilder_ = null; + block_ = other.block_; + bitField0_ = (bitField0_ & ~0x00000001); + blockBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getBlockFieldBuilder() : null; + } else { + blockBuilder_.addAllMessages(other.block_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.BlockListExtention parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.BlockListExtention) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List block_ = + java.util.Collections.emptyList(); + private void ensureBlockIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + block_ = new java.util.ArrayList(block_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.BlockExtention, org.tron.api.GrpcAPI.BlockExtention.Builder, org.tron.api.GrpcAPI.BlockExtentionOrBuilder> blockBuilder_; + + /** + * repeated .protocol.BlockExtention block = 1; + */ + public java.util.List getBlockList() { + if (blockBuilder_ == null) { + return java.util.Collections.unmodifiableList(block_); + } else { + return blockBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public int getBlockCount() { + if (blockBuilder_ == null) { + return block_.size(); + } else { + return blockBuilder_.getCount(); + } + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public org.tron.api.GrpcAPI.BlockExtention getBlock(int index) { + if (blockBuilder_ == null) { + return block_.get(index); + } else { + return blockBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder setBlock( + int index, org.tron.api.GrpcAPI.BlockExtention value) { + if (blockBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockIsMutable(); + block_.set(index, value); + onChanged(); + } else { + blockBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder setBlock( + int index, org.tron.api.GrpcAPI.BlockExtention.Builder builderForValue) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.set(index, builderForValue.build()); + onChanged(); + } else { + blockBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder addBlock(org.tron.api.GrpcAPI.BlockExtention value) { + if (blockBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockIsMutable(); + block_.add(value); + onChanged(); + } else { + blockBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder addBlock( + int index, org.tron.api.GrpcAPI.BlockExtention value) { + if (blockBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockIsMutable(); + block_.add(index, value); + onChanged(); + } else { + blockBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder addBlock( + org.tron.api.GrpcAPI.BlockExtention.Builder builderForValue) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.add(builderForValue.build()); + onChanged(); + } else { + blockBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder addBlock( + int index, org.tron.api.GrpcAPI.BlockExtention.Builder builderForValue) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.add(index, builderForValue.build()); + onChanged(); + } else { + blockBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder addAllBlock( + java.lang.Iterable values) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, block_); + onChanged(); + } else { + blockBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder clearBlock() { + if (blockBuilder_ == null) { + block_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + blockBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public Builder removeBlock(int index) { + if (blockBuilder_ == null) { + ensureBlockIsMutable(); + block_.remove(index); + onChanged(); + } else { + blockBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public org.tron.api.GrpcAPI.BlockExtention.Builder getBlockBuilder( + int index) { + return getBlockFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public org.tron.api.GrpcAPI.BlockExtentionOrBuilder getBlockOrBuilder( + int index) { + if (blockBuilder_ == null) { + return block_.get(index); } else { + return blockBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public java.util.List + getBlockOrBuilderList() { + if (blockBuilder_ != null) { + return blockBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(block_); + } + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public org.tron.api.GrpcAPI.BlockExtention.Builder addBlockBuilder() { + return getBlockFieldBuilder().addBuilder( + org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance()); + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public org.tron.api.GrpcAPI.BlockExtention.Builder addBlockBuilder( + int index) { + return getBlockFieldBuilder().addBuilder( + index, org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance()); + } + /** + * repeated .protocol.BlockExtention block = 1; + */ + public java.util.List + getBlockBuilderList() { + return getBlockFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.BlockExtention, org.tron.api.GrpcAPI.BlockExtention.Builder, org.tron.api.GrpcAPI.BlockExtentionOrBuilder> + getBlockFieldBuilder() { + if (blockBuilder_ == null) { + blockBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.BlockExtention, org.tron.api.GrpcAPI.BlockExtention.Builder, org.tron.api.GrpcAPI.BlockExtentionOrBuilder>( + block_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + block_ = null; + } + return blockBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockListExtention) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockListExtention) + private static final org.tron.api.GrpcAPI.BlockListExtention DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.BlockListExtention(); + } + + public static org.tron.api.GrpcAPI.BlockListExtention getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockListExtention parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockListExtention(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.BlockListExtention getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionListExtentionOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionListExtention) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + java.util.List + getTransactionList(); + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + org.tron.api.GrpcAPI.TransactionExtention getTransaction(int index); + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + int getTransactionCount(); + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + java.util.List + getTransactionOrBuilderList(); + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.TransactionListExtention} + */ + public static final class TransactionListExtention extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionListExtention) + TransactionListExtentionOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionListExtention.newBuilder() to construct. + private TransactionListExtention(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionListExtention() { + transaction_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionListExtention( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + transaction_.add( + input.readMessage(org.tron.api.GrpcAPI.TransactionExtention.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = java.util.Collections.unmodifiableList(transaction_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionListExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionListExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionListExtention.class, org.tron.api.GrpcAPI.TransactionListExtention.Builder.class); + } + + public static final int TRANSACTION_FIELD_NUMBER = 1; + private java.util.List transaction_; + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public java.util.List getTransactionList() { + return transaction_; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public java.util.List + getTransactionOrBuilderList() { + return transaction_; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public int getTransactionCount() { + return transaction_.size(); + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransaction(int index) { + return transaction_.get(index); + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder( + int index) { + return transaction_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < transaction_.size(); i++) { + output.writeMessage(1, transaction_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < transaction_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, transaction_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionListExtention)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionListExtention other = (org.tron.api.GrpcAPI.TransactionListExtention) obj; + + boolean result = true; + result = result && getTransactionList() + .equals(other.getTransactionList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTransactionCount() > 0) { + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransactionList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionListExtention parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionListExtention prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionListExtention} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionListExtention) + org.tron.api.GrpcAPI.TransactionListExtentionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionListExtention_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionListExtention_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionListExtention.class, org.tron.api.GrpcAPI.TransactionListExtention.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionListExtention.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTransactionFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (transactionBuilder_ == null) { + transaction_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + transactionBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionListExtention_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionListExtention getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionListExtention.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionListExtention build() { + org.tron.api.GrpcAPI.TransactionListExtention result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionListExtention buildPartial() { + org.tron.api.GrpcAPI.TransactionListExtention result = new org.tron.api.GrpcAPI.TransactionListExtention(this); + int from_bitField0_ = bitField0_; + if (transactionBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = java.util.Collections.unmodifiableList(transaction_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.transaction_ = transaction_; + } else { + result.transaction_ = transactionBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionListExtention) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionListExtention)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionListExtention other) { + if (other == org.tron.api.GrpcAPI.TransactionListExtention.getDefaultInstance()) return this; + if (transactionBuilder_ == null) { + if (!other.transaction_.isEmpty()) { + if (transaction_.isEmpty()) { + transaction_ = other.transaction_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTransactionIsMutable(); + transaction_.addAll(other.transaction_); + } + onChanged(); + } + } else { + if (!other.transaction_.isEmpty()) { + if (transactionBuilder_.isEmpty()) { + transactionBuilder_.dispose(); + transactionBuilder_ = null; + transaction_ = other.transaction_; + bitField0_ = (bitField0_ & ~0x00000001); + transactionBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTransactionFieldBuilder() : null; + } else { + transactionBuilder_.addAllMessages(other.transaction_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionListExtention parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionListExtention) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List transaction_ = + java.util.Collections.emptyList(); + private void ensureTransactionIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + transaction_ = new java.util.ArrayList(transaction_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> transactionBuilder_; + + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public java.util.List getTransactionList() { + if (transactionBuilder_ == null) { + return java.util.Collections.unmodifiableList(transaction_); + } else { + return transactionBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public int getTransactionCount() { + if (transactionBuilder_ == null) { + return transaction_.size(); + } else { + return transactionBuilder_.getCount(); + } + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransaction(int index) { + if (transactionBuilder_ == null) { + return transaction_.get(index); + } else { + return transactionBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder setTransaction( + int index, org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionIsMutable(); + transaction_.set(index, value); + onChanged(); + } else { + transactionBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder setTransaction( + int index, org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.set(index, builderForValue.build()); + onChanged(); + } else { + transactionBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder addTransaction(org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionIsMutable(); + transaction_.add(value); + onChanged(); + } else { + transactionBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder addTransaction( + int index, org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionIsMutable(); + transaction_.add(index, value); + onChanged(); + } else { + transactionBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder addTransaction( + org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.add(builderForValue.build()); + onChanged(); + } else { + transactionBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder addTransaction( + int index, org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.add(index, builderForValue.build()); + onChanged(); + } else { + transactionBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder addAllTransaction( + java.lang.Iterable values) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, transaction_); + onChanged(); + } else { + transactionBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder clearTransaction() { + if (transactionBuilder_ == null) { + transaction_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + transactionBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public Builder removeTransaction(int index) { + if (transactionBuilder_ == null) { + ensureTransactionIsMutable(); + transaction_.remove(index); + onChanged(); + } else { + transactionBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder getTransactionBuilder( + int index) { + return getTransactionFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder( + int index) { + if (transactionBuilder_ == null) { + return transaction_.get(index); } else { + return transactionBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public java.util.List + getTransactionOrBuilderList() { + if (transactionBuilder_ != null) { + return transactionBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transaction_); + } + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder addTransactionBuilder() { + return getTransactionFieldBuilder().addBuilder( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder addTransactionBuilder( + int index) { + return getTransactionFieldBuilder().addBuilder( + index, org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionExtention transaction = 1; + */ + public java.util.List + getTransactionBuilderList() { + return getTransactionFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> + getTransactionFieldBuilder() { + if (transactionBuilder_ == null) { + transactionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder>( + transaction_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + transaction_ = null; + } + return transactionBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionListExtention) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionListExtention) + private static final org.tron.api.GrpcAPI.TransactionListExtention DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionListExtention(); + } + + public static org.tron.api.GrpcAPI.TransactionListExtention getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionListExtention parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionListExtention(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionListExtention getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionSignWeightOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionSignWeight) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Permission permission = 1; + */ + boolean hasPermission(); + /** + * .protocol.Permission permission = 1; + */ + org.tron.protos.Protocol.Permission getPermission(); + /** + * .protocol.Permission permission = 1; + */ + org.tron.protos.Protocol.PermissionOrBuilder getPermissionOrBuilder(); + + /** + * repeated bytes approved_list = 2; + */ + java.util.List getApprovedListList(); + /** + * repeated bytes approved_list = 2; + */ + int getApprovedListCount(); + /** + * repeated bytes approved_list = 2; + */ + com.google.protobuf.ByteString getApprovedList(int index); + + /** + * int64 current_weight = 3; + */ + long getCurrentWeight(); + + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + boolean hasResult(); + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + org.tron.api.GrpcAPI.TransactionSignWeight.Result getResult(); + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + org.tron.api.GrpcAPI.TransactionSignWeight.ResultOrBuilder getResultOrBuilder(); + + /** + * .protocol.TransactionExtention transaction = 5; + */ + boolean hasTransaction(); + /** + * .protocol.TransactionExtention transaction = 5; + */ + org.tron.api.GrpcAPI.TransactionExtention getTransaction(); + /** + * .protocol.TransactionExtention transaction = 5; + */ + org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder(); + } + /** + * Protobuf type {@code protocol.TransactionSignWeight} + */ + public static final class TransactionSignWeight extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionSignWeight) + TransactionSignWeightOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionSignWeight.newBuilder() to construct. + private TransactionSignWeight(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionSignWeight() { + approvedList_ = java.util.Collections.emptyList(); + currentWeight_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionSignWeight( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.Permission.Builder subBuilder = null; + if (permission_ != null) { + subBuilder = permission_.toBuilder(); + } + permission_ = input.readMessage(org.tron.protos.Protocol.Permission.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(permission_); + permission_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + approvedList_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + approvedList_.add(input.readBytes()); + break; + } + case 24: { + + currentWeight_ = input.readInt64(); + break; + } + case 34: { + org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder subBuilder = null; + if (result_ != null) { + subBuilder = result_.toBuilder(); + } + result_ = input.readMessage(org.tron.api.GrpcAPI.TransactionSignWeight.Result.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(result_); + result_ = subBuilder.buildPartial(); + } + + break; + } + case 42: { + org.tron.api.GrpcAPI.TransactionExtention.Builder subBuilder = null; + if (transaction_ != null) { + subBuilder = transaction_.toBuilder(); + } + transaction_ = input.readMessage(org.tron.api.GrpcAPI.TransactionExtention.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(transaction_); + transaction_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + approvedList_ = java.util.Collections.unmodifiableList(approvedList_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionSignWeight.class, org.tron.api.GrpcAPI.TransactionSignWeight.Builder.class); + } + + public interface ResultOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionSignWeight.Result) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + int getCodeValue(); + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code getCode(); + + /** + * string message = 2; + */ + java.lang.String getMessage(); + /** + * string message = 2; + */ + com.google.protobuf.ByteString + getMessageBytes(); + } + /** + * Protobuf type {@code protocol.TransactionSignWeight.Result} + */ + public static final class Result extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionSignWeight.Result) + ResultOrBuilder { + private static final long serialVersionUID = 0L; + // Use Result.newBuilder() to construct. + private Result(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Result() { + code_ = 0; + message_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Result( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + code_ = rawValue; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_Result_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_Result_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionSignWeight.Result.class, org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder.class); + } + + /** + * Protobuf enum {@code protocol.TransactionSignWeight.Result.response_code} + */ + public enum response_code + implements com.google.protobuf.ProtocolMessageEnum { + /** + * ENOUGH_PERMISSION = 0; + */ + ENOUGH_PERMISSION(0), + /** + *
+         * error in
+         * 
+ * + * NOT_ENOUGH_PERMISSION = 1; + */ + NOT_ENOUGH_PERMISSION(1), + /** + * SIGNATURE_FORMAT_ERROR = 2; + */ + SIGNATURE_FORMAT_ERROR(2), + /** + * COMPUTE_ADDRESS_ERROR = 3; + */ + COMPUTE_ADDRESS_ERROR(3), + /** + *
+         *The key is not in permission
+         * 
+ * + * PERMISSION_ERROR = 4; + */ + PERMISSION_ERROR(4), + /** + * OTHER_ERROR = 20; + */ + OTHER_ERROR(20), + UNRECOGNIZED(-1), + ; + + /** + * ENOUGH_PERMISSION = 0; + */ + public static final int ENOUGH_PERMISSION_VALUE = 0; + /** + *
+         * error in
+         * 
+ * + * NOT_ENOUGH_PERMISSION = 1; + */ + public static final int NOT_ENOUGH_PERMISSION_VALUE = 1; + /** + * SIGNATURE_FORMAT_ERROR = 2; + */ + public static final int SIGNATURE_FORMAT_ERROR_VALUE = 2; + /** + * COMPUTE_ADDRESS_ERROR = 3; + */ + public static final int COMPUTE_ADDRESS_ERROR_VALUE = 3; + /** + *
+         *The key is not in permission
+         * 
+ * + * PERMISSION_ERROR = 4; + */ + public static final int PERMISSION_ERROR_VALUE = 4; + /** + * OTHER_ERROR = 20; + */ + public static final int OTHER_ERROR_VALUE = 20; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static response_code valueOf(int value) { + return forNumber(value); + } + + public static response_code forNumber(int value) { + switch (value) { + case 0: return ENOUGH_PERMISSION; + case 1: return NOT_ENOUGH_PERMISSION; + case 2: return SIGNATURE_FORMAT_ERROR; + case 3: return COMPUTE_ADDRESS_ERROR; + case 4: return PERMISSION_ERROR; + case 20: return OTHER_ERROR; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + response_code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public response_code findValueByNumber(int number) { + return response_code.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.api.GrpcAPI.TransactionSignWeight.Result.getDescriptor().getEnumTypes().get(0); + } + + private static final response_code[] VALUES = values(); + + public static response_code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private response_code(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.TransactionSignWeight.Result.response_code) + } + + public static final int CODE_FIELD_NUMBER = 1; + private int code_; + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + public int getCodeValue() { + return code_; + } + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + public org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code getCode() { + org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code result = org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.valueOf(code_); + return result == null ? org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.UNRECOGNIZED : result; + } + + public static final int MESSAGE_FIELD_NUMBER = 2; + private volatile java.lang.Object message_; + /** + * string message = 2; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * string message = 2; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (code_ != org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.ENOUGH_PERMISSION.getNumber()) { + output.writeEnum(1, code_); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, message_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (code_ != org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.ENOUGH_PERMISSION.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, code_); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, message_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionSignWeight.Result)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionSignWeight.Result other = (org.tron.api.GrpcAPI.TransactionSignWeight.Result) obj; + + boolean result = true; + result = result && code_ == other.code_; + result = result && getMessage() + .equals(other.getMessage()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + code_; + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionSignWeight.Result prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionSignWeight.Result} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionSignWeight.Result) + org.tron.api.GrpcAPI.TransactionSignWeight.ResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_Result_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_Result_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionSignWeight.Result.class, org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionSignWeight.Result.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + code_ = 0; + + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_Result_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionSignWeight.Result getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionSignWeight.Result.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionSignWeight.Result build() { + org.tron.api.GrpcAPI.TransactionSignWeight.Result result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionSignWeight.Result buildPartial() { + org.tron.api.GrpcAPI.TransactionSignWeight.Result result = new org.tron.api.GrpcAPI.TransactionSignWeight.Result(this); + result.code_ = code_; + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionSignWeight.Result) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionSignWeight.Result)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionSignWeight.Result other) { + if (other == org.tron.api.GrpcAPI.TransactionSignWeight.Result.getDefaultInstance()) return this; + if (other.code_ != 0) { + setCodeValue(other.getCodeValue()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionSignWeight.Result parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionSignWeight.Result) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int code_ = 0; + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + public int getCodeValue() { + return code_; + } + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + public Builder setCodeValue(int value) { + code_ = value; + onChanged(); + return this; + } + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + public org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code getCode() { + org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code result = org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.valueOf(code_); + return result == null ? org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.UNRECOGNIZED : result; + } + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + public Builder setCode(org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code value) { + if (value == null) { + throw new NullPointerException(); + } + + code_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.TransactionSignWeight.Result.response_code code = 1; + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private java.lang.Object message_ = ""; + /** + * string message = 2; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string message = 2; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string message = 2; + */ + public Builder setMessage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * string message = 2; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * string message = 2; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionSignWeight.Result) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionSignWeight.Result) + private static final org.tron.api.GrpcAPI.TransactionSignWeight.Result DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionSignWeight.Result(); + } + + public static org.tron.api.GrpcAPI.TransactionSignWeight.Result getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Result parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Result(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionSignWeight.Result getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int PERMISSION_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.Permission permission_; + /** + * .protocol.Permission permission = 1; + */ + public boolean hasPermission() { + return permission_ != null; + } + /** + * .protocol.Permission permission = 1; + */ + public org.tron.protos.Protocol.Permission getPermission() { + return permission_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : permission_; + } + /** + * .protocol.Permission permission = 1; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getPermissionOrBuilder() { + return getPermission(); + } + + public static final int APPROVED_LIST_FIELD_NUMBER = 2; + private java.util.List approvedList_; + /** + * repeated bytes approved_list = 2; + */ + public java.util.List + getApprovedListList() { + return approvedList_; + } + /** + * repeated bytes approved_list = 2; + */ + public int getApprovedListCount() { + return approvedList_.size(); + } + /** + * repeated bytes approved_list = 2; + */ + public com.google.protobuf.ByteString getApprovedList(int index) { + return approvedList_.get(index); + } + + public static final int CURRENT_WEIGHT_FIELD_NUMBER = 3; + private long currentWeight_; + /** + * int64 current_weight = 3; + */ + public long getCurrentWeight() { + return currentWeight_; + } + + public static final int RESULT_FIELD_NUMBER = 4; + private org.tron.api.GrpcAPI.TransactionSignWeight.Result result_; + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public boolean hasResult() { + return result_ != null; + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionSignWeight.Result getResult() { + return result_ == null ? org.tron.api.GrpcAPI.TransactionSignWeight.Result.getDefaultInstance() : result_; + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionSignWeight.ResultOrBuilder getResultOrBuilder() { + return getResult(); + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + private org.tron.api.GrpcAPI.TransactionExtention transaction_; + /** + * .protocol.TransactionExtention transaction = 5; + */ + public boolean hasTransaction() { + return transaction_ != null; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransaction() { + return transaction_ == null ? org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance() : transaction_; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder() { + return getTransaction(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (permission_ != null) { + output.writeMessage(1, getPermission()); + } + for (int i = 0; i < approvedList_.size(); i++) { + output.writeBytes(2, approvedList_.get(i)); + } + if (currentWeight_ != 0L) { + output.writeInt64(3, currentWeight_); + } + if (result_ != null) { + output.writeMessage(4, getResult()); + } + if (transaction_ != null) { + output.writeMessage(5, getTransaction()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (permission_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getPermission()); + } + { + int dataSize = 0; + for (int i = 0; i < approvedList_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(approvedList_.get(i)); + } + size += dataSize; + size += 1 * getApprovedListList().size(); + } + if (currentWeight_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, currentWeight_); + } + if (result_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getResult()); + } + if (transaction_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getTransaction()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionSignWeight)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionSignWeight other = (org.tron.api.GrpcAPI.TransactionSignWeight) obj; + + boolean result = true; + result = result && (hasPermission() == other.hasPermission()); + if (hasPermission()) { + result = result && getPermission() + .equals(other.getPermission()); + } + result = result && getApprovedListList() + .equals(other.getApprovedListList()); + result = result && (getCurrentWeight() + == other.getCurrentWeight()); + result = result && (hasResult() == other.hasResult()); + if (hasResult()) { + result = result && getResult() + .equals(other.getResult()); + } + result = result && (hasTransaction() == other.hasTransaction()); + if (hasTransaction()) { + result = result && getTransaction() + .equals(other.getTransaction()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasPermission()) { + hash = (37 * hash) + PERMISSION_FIELD_NUMBER; + hash = (53 * hash) + getPermission().hashCode(); + } + if (getApprovedListCount() > 0) { + hash = (37 * hash) + APPROVED_LIST_FIELD_NUMBER; + hash = (53 * hash) + getApprovedListList().hashCode(); + } + hash = (37 * hash) + CURRENT_WEIGHT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCurrentWeight()); + if (hasResult()) { + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + getResult().hashCode(); + } + if (hasTransaction()) { + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionSignWeight parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionSignWeight prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionSignWeight} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionSignWeight) + org.tron.api.GrpcAPI.TransactionSignWeightOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionSignWeight.class, org.tron.api.GrpcAPI.TransactionSignWeight.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionSignWeight.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (permissionBuilder_ == null) { + permission_ = null; + } else { + permission_ = null; + permissionBuilder_ = null; + } + approvedList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + currentWeight_ = 0L; + + if (resultBuilder_ == null) { + result_ = null; + } else { + result_ = null; + resultBuilder_ = null; + } + if (transactionBuilder_ == null) { + transaction_ = null; + } else { + transaction_ = null; + transactionBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionSignWeight_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionSignWeight getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionSignWeight.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionSignWeight build() { + org.tron.api.GrpcAPI.TransactionSignWeight result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionSignWeight buildPartial() { + org.tron.api.GrpcAPI.TransactionSignWeight result = new org.tron.api.GrpcAPI.TransactionSignWeight(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (permissionBuilder_ == null) { + result.permission_ = permission_; + } else { + result.permission_ = permissionBuilder_.build(); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + approvedList_ = java.util.Collections.unmodifiableList(approvedList_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.approvedList_ = approvedList_; + result.currentWeight_ = currentWeight_; + if (resultBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = resultBuilder_.build(); + } + if (transactionBuilder_ == null) { + result.transaction_ = transaction_; + } else { + result.transaction_ = transactionBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionSignWeight) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionSignWeight)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionSignWeight other) { + if (other == org.tron.api.GrpcAPI.TransactionSignWeight.getDefaultInstance()) return this; + if (other.hasPermission()) { + mergePermission(other.getPermission()); + } + if (!other.approvedList_.isEmpty()) { + if (approvedList_.isEmpty()) { + approvedList_ = other.approvedList_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureApprovedListIsMutable(); + approvedList_.addAll(other.approvedList_); + } + onChanged(); + } + if (other.getCurrentWeight() != 0L) { + setCurrentWeight(other.getCurrentWeight()); + } + if (other.hasResult()) { + mergeResult(other.getResult()); + } + if (other.hasTransaction()) { + mergeTransaction(other.getTransaction()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionSignWeight parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionSignWeight) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private org.tron.protos.Protocol.Permission permission_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> permissionBuilder_; + /** + * .protocol.Permission permission = 1; + */ + public boolean hasPermission() { + return permissionBuilder_ != null || permission_ != null; + } + /** + * .protocol.Permission permission = 1; + */ + public org.tron.protos.Protocol.Permission getPermission() { + if (permissionBuilder_ == null) { + return permission_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : permission_; + } else { + return permissionBuilder_.getMessage(); + } + } + /** + * .protocol.Permission permission = 1; + */ + public Builder setPermission(org.tron.protos.Protocol.Permission value) { + if (permissionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + permission_ = value; + onChanged(); + } else { + permissionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Permission permission = 1; + */ + public Builder setPermission( + org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (permissionBuilder_ == null) { + permission_ = builderForValue.build(); + onChanged(); + } else { + permissionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Permission permission = 1; + */ + public Builder mergePermission(org.tron.protos.Protocol.Permission value) { + if (permissionBuilder_ == null) { + if (permission_ != null) { + permission_ = + org.tron.protos.Protocol.Permission.newBuilder(permission_).mergeFrom(value).buildPartial(); + } else { + permission_ = value; + } + onChanged(); + } else { + permissionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Permission permission = 1; + */ + public Builder clearPermission() { + if (permissionBuilder_ == null) { + permission_ = null; + onChanged(); + } else { + permission_ = null; + permissionBuilder_ = null; + } + + return this; + } + /** + * .protocol.Permission permission = 1; + */ + public org.tron.protos.Protocol.Permission.Builder getPermissionBuilder() { + + onChanged(); + return getPermissionFieldBuilder().getBuilder(); + } + /** + * .protocol.Permission permission = 1; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getPermissionOrBuilder() { + if (permissionBuilder_ != null) { + return permissionBuilder_.getMessageOrBuilder(); + } else { + return permission_ == null ? + org.tron.protos.Protocol.Permission.getDefaultInstance() : permission_; + } + } + /** + * .protocol.Permission permission = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> + getPermissionFieldBuilder() { + if (permissionBuilder_ == null) { + permissionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder>( + getPermission(), + getParentForChildren(), + isClean()); + permission_ = null; + } + return permissionBuilder_; + } + + private java.util.List approvedList_ = java.util.Collections.emptyList(); + private void ensureApprovedListIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + approvedList_ = new java.util.ArrayList(approvedList_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes approved_list = 2; + */ + public java.util.List + getApprovedListList() { + return java.util.Collections.unmodifiableList(approvedList_); + } + /** + * repeated bytes approved_list = 2; + */ + public int getApprovedListCount() { + return approvedList_.size(); + } + /** + * repeated bytes approved_list = 2; + */ + public com.google.protobuf.ByteString getApprovedList(int index) { + return approvedList_.get(index); + } + /** + * repeated bytes approved_list = 2; + */ + public Builder setApprovedList( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureApprovedListIsMutable(); + approvedList_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes approved_list = 2; + */ + public Builder addApprovedList(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureApprovedListIsMutable(); + approvedList_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes approved_list = 2; + */ + public Builder addAllApprovedList( + java.lang.Iterable values) { + ensureApprovedListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, approvedList_); + onChanged(); + return this; + } + /** + * repeated bytes approved_list = 2; + */ + public Builder clearApprovedList() { + approvedList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private long currentWeight_ ; + /** + * int64 current_weight = 3; + */ + public long getCurrentWeight() { + return currentWeight_; + } + /** + * int64 current_weight = 3; + */ + public Builder setCurrentWeight(long value) { + + currentWeight_ = value; + onChanged(); + return this; + } + /** + * int64 current_weight = 3; + */ + public Builder clearCurrentWeight() { + + currentWeight_ = 0L; + onChanged(); + return this; + } + + private org.tron.api.GrpcAPI.TransactionSignWeight.Result result_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionSignWeight.Result, org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder, org.tron.api.GrpcAPI.TransactionSignWeight.ResultOrBuilder> resultBuilder_; + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public boolean hasResult() { + return resultBuilder_ != null || result_ != null; + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionSignWeight.Result getResult() { + if (resultBuilder_ == null) { + return result_ == null ? org.tron.api.GrpcAPI.TransactionSignWeight.Result.getDefaultInstance() : result_; + } else { + return resultBuilder_.getMessage(); + } + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public Builder setResult(org.tron.api.GrpcAPI.TransactionSignWeight.Result value) { + if (resultBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + resultBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public Builder setResult( + org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder builderForValue) { + if (resultBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + resultBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public Builder mergeResult(org.tron.api.GrpcAPI.TransactionSignWeight.Result value) { + if (resultBuilder_ == null) { + if (result_ != null) { + result_ = + org.tron.api.GrpcAPI.TransactionSignWeight.Result.newBuilder(result_).mergeFrom(value).buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + resultBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public Builder clearResult() { + if (resultBuilder_ == null) { + result_ = null; + onChanged(); + } else { + result_ = null; + resultBuilder_ = null; + } + + return this; + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder getResultBuilder() { + + onChanged(); + return getResultFieldBuilder().getBuilder(); + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionSignWeight.ResultOrBuilder getResultOrBuilder() { + if (resultBuilder_ != null) { + return resultBuilder_.getMessageOrBuilder(); + } else { + return result_ == null ? + org.tron.api.GrpcAPI.TransactionSignWeight.Result.getDefaultInstance() : result_; + } + } + /** + * .protocol.TransactionSignWeight.Result result = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionSignWeight.Result, org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder, org.tron.api.GrpcAPI.TransactionSignWeight.ResultOrBuilder> + getResultFieldBuilder() { + if (resultBuilder_ == null) { + resultBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionSignWeight.Result, org.tron.api.GrpcAPI.TransactionSignWeight.Result.Builder, org.tron.api.GrpcAPI.TransactionSignWeight.ResultOrBuilder>( + getResult(), + getParentForChildren(), + isClean()); + result_ = null; + } + return resultBuilder_; + } + + private org.tron.api.GrpcAPI.TransactionExtention transaction_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> transactionBuilder_; + /** + * .protocol.TransactionExtention transaction = 5; + */ + public boolean hasTransaction() { + return transactionBuilder_ != null || transaction_ != null; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransaction() { + if (transactionBuilder_ == null) { + return transaction_ == null ? org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance() : transaction_; + } else { + return transactionBuilder_.getMessage(); + } + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder setTransaction(org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + onChanged(); + } else { + transactionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder setTransaction( + org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionBuilder_ == null) { + transaction_ = builderForValue.build(); + onChanged(); + } else { + transactionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder mergeTransaction(org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionBuilder_ == null) { + if (transaction_ != null) { + transaction_ = + org.tron.api.GrpcAPI.TransactionExtention.newBuilder(transaction_).mergeFrom(value).buildPartial(); + } else { + transaction_ = value; + } + onChanged(); + } else { + transactionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder clearTransaction() { + if (transactionBuilder_ == null) { + transaction_ = null; + onChanged(); + } else { + transaction_ = null; + transactionBuilder_ = null; + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder getTransactionBuilder() { + + onChanged(); + return getTransactionFieldBuilder().getBuilder(); + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder() { + if (transactionBuilder_ != null) { + return transactionBuilder_.getMessageOrBuilder(); + } else { + return transaction_ == null ? + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance() : transaction_; + } + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> + getTransactionFieldBuilder() { + if (transactionBuilder_ == null) { + transactionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder>( + getTransaction(), + getParentForChildren(), + isClean()); + transaction_ = null; + } + return transactionBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionSignWeight) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionSignWeight) + private static final org.tron.api.GrpcAPI.TransactionSignWeight DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionSignWeight(); + } + + public static org.tron.api.GrpcAPI.TransactionSignWeight getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionSignWeight parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionSignWeight(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionSignWeight getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionApprovedListOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionApprovedList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated bytes approved_list = 2; + */ + java.util.List getApprovedListList(); + /** + * repeated bytes approved_list = 2; + */ + int getApprovedListCount(); + /** + * repeated bytes approved_list = 2; + */ + com.google.protobuf.ByteString getApprovedList(int index); + + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + boolean hasResult(); + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + org.tron.api.GrpcAPI.TransactionApprovedList.Result getResult(); + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + org.tron.api.GrpcAPI.TransactionApprovedList.ResultOrBuilder getResultOrBuilder(); + + /** + * .protocol.TransactionExtention transaction = 5; + */ + boolean hasTransaction(); + /** + * .protocol.TransactionExtention transaction = 5; + */ + org.tron.api.GrpcAPI.TransactionExtention getTransaction(); + /** + * .protocol.TransactionExtention transaction = 5; + */ + org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder(); + } + /** + * Protobuf type {@code protocol.TransactionApprovedList} + */ + public static final class TransactionApprovedList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionApprovedList) + TransactionApprovedListOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionApprovedList.newBuilder() to construct. + private TransactionApprovedList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionApprovedList() { + approvedList_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionApprovedList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + approvedList_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + approvedList_.add(input.readBytes()); + break; + } + case 34: { + org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder subBuilder = null; + if (result_ != null) { + subBuilder = result_.toBuilder(); + } + result_ = input.readMessage(org.tron.api.GrpcAPI.TransactionApprovedList.Result.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(result_); + result_ = subBuilder.buildPartial(); + } + + break; + } + case 42: { + org.tron.api.GrpcAPI.TransactionExtention.Builder subBuilder = null; + if (transaction_ != null) { + subBuilder = transaction_.toBuilder(); + } + transaction_ = input.readMessage(org.tron.api.GrpcAPI.TransactionExtention.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(transaction_); + transaction_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + approvedList_ = java.util.Collections.unmodifiableList(approvedList_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionApprovedList.class, org.tron.api.GrpcAPI.TransactionApprovedList.Builder.class); + } + + public interface ResultOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionApprovedList.Result) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + int getCodeValue(); + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code getCode(); + + /** + * string message = 2; + */ + java.lang.String getMessage(); + /** + * string message = 2; + */ + com.google.protobuf.ByteString + getMessageBytes(); + } + /** + * Protobuf type {@code protocol.TransactionApprovedList.Result} + */ + public static final class Result extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionApprovedList.Result) + ResultOrBuilder { + private static final long serialVersionUID = 0L; + // Use Result.newBuilder() to construct. + private Result(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Result() { + code_ = 0; + message_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Result( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + code_ = rawValue; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_Result_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_Result_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionApprovedList.Result.class, org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder.class); + } + + /** + * Protobuf enum {@code protocol.TransactionApprovedList.Result.response_code} + */ + public enum response_code + implements com.google.protobuf.ProtocolMessageEnum { + /** + * SUCCESS = 0; + */ + SUCCESS(0), + /** + * SIGNATURE_FORMAT_ERROR = 1; + */ + SIGNATURE_FORMAT_ERROR(1), + /** + * COMPUTE_ADDRESS_ERROR = 2; + */ + COMPUTE_ADDRESS_ERROR(2), + /** + * OTHER_ERROR = 20; + */ + OTHER_ERROR(20), + UNRECOGNIZED(-1), + ; + + /** + * SUCCESS = 0; + */ + public static final int SUCCESS_VALUE = 0; + /** + * SIGNATURE_FORMAT_ERROR = 1; + */ + public static final int SIGNATURE_FORMAT_ERROR_VALUE = 1; + /** + * COMPUTE_ADDRESS_ERROR = 2; + */ + public static final int COMPUTE_ADDRESS_ERROR_VALUE = 2; + /** + * OTHER_ERROR = 20; + */ + public static final int OTHER_ERROR_VALUE = 20; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static response_code valueOf(int value) { + return forNumber(value); + } + + public static response_code forNumber(int value) { + switch (value) { + case 0: return SUCCESS; + case 1: return SIGNATURE_FORMAT_ERROR; + case 2: return COMPUTE_ADDRESS_ERROR; + case 20: return OTHER_ERROR; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + response_code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public response_code findValueByNumber(int number) { + return response_code.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.api.GrpcAPI.TransactionApprovedList.Result.getDescriptor().getEnumTypes().get(0); + } + + private static final response_code[] VALUES = values(); + + public static response_code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private response_code(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.TransactionApprovedList.Result.response_code) + } + + public static final int CODE_FIELD_NUMBER = 1; + private int code_; + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + public int getCodeValue() { + return code_; + } + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + public org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code getCode() { + org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code result = org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code.valueOf(code_); + return result == null ? org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code.UNRECOGNIZED : result; + } + + public static final int MESSAGE_FIELD_NUMBER = 2; + private volatile java.lang.Object message_; + /** + * string message = 2; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * string message = 2; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (code_ != org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code.SUCCESS.getNumber()) { + output.writeEnum(1, code_); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, message_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (code_ != org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code.SUCCESS.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, code_); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, message_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionApprovedList.Result)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionApprovedList.Result other = (org.tron.api.GrpcAPI.TransactionApprovedList.Result) obj; + + boolean result = true; + result = result && code_ == other.code_; + result = result && getMessage() + .equals(other.getMessage()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + code_; + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionApprovedList.Result prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionApprovedList.Result} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionApprovedList.Result) + org.tron.api.GrpcAPI.TransactionApprovedList.ResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_Result_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_Result_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionApprovedList.Result.class, org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionApprovedList.Result.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + code_ = 0; + + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_Result_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionApprovedList.Result getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionApprovedList.Result.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionApprovedList.Result build() { + org.tron.api.GrpcAPI.TransactionApprovedList.Result result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionApprovedList.Result buildPartial() { + org.tron.api.GrpcAPI.TransactionApprovedList.Result result = new org.tron.api.GrpcAPI.TransactionApprovedList.Result(this); + result.code_ = code_; + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionApprovedList.Result) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionApprovedList.Result)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionApprovedList.Result other) { + if (other == org.tron.api.GrpcAPI.TransactionApprovedList.Result.getDefaultInstance()) return this; + if (other.code_ != 0) { + setCodeValue(other.getCodeValue()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionApprovedList.Result parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionApprovedList.Result) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int code_ = 0; + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + public int getCodeValue() { + return code_; + } + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + public Builder setCodeValue(int value) { + code_ = value; + onChanged(); + return this; + } + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + public org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code getCode() { + org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code result = org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code.valueOf(code_); + return result == null ? org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code.UNRECOGNIZED : result; + } + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + public Builder setCode(org.tron.api.GrpcAPI.TransactionApprovedList.Result.response_code value) { + if (value == null) { + throw new NullPointerException(); + } + + code_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.TransactionApprovedList.Result.response_code code = 1; + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private java.lang.Object message_ = ""; + /** + * string message = 2; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string message = 2; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string message = 2; + */ + public Builder setMessage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * string message = 2; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * string message = 2; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionApprovedList.Result) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionApprovedList.Result) + private static final org.tron.api.GrpcAPI.TransactionApprovedList.Result DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionApprovedList.Result(); + } + + public static org.tron.api.GrpcAPI.TransactionApprovedList.Result getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Result parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Result(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionApprovedList.Result getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int APPROVED_LIST_FIELD_NUMBER = 2; + private java.util.List approvedList_; + /** + * repeated bytes approved_list = 2; + */ + public java.util.List + getApprovedListList() { + return approvedList_; + } + /** + * repeated bytes approved_list = 2; + */ + public int getApprovedListCount() { + return approvedList_.size(); + } + /** + * repeated bytes approved_list = 2; + */ + public com.google.protobuf.ByteString getApprovedList(int index) { + return approvedList_.get(index); + } + + public static final int RESULT_FIELD_NUMBER = 4; + private org.tron.api.GrpcAPI.TransactionApprovedList.Result result_; + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public boolean hasResult() { + return result_ != null; + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionApprovedList.Result getResult() { + return result_ == null ? org.tron.api.GrpcAPI.TransactionApprovedList.Result.getDefaultInstance() : result_; + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionApprovedList.ResultOrBuilder getResultOrBuilder() { + return getResult(); + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + private org.tron.api.GrpcAPI.TransactionExtention transaction_; + /** + * .protocol.TransactionExtention transaction = 5; + */ + public boolean hasTransaction() { + return transaction_ != null; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransaction() { + return transaction_ == null ? org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance() : transaction_; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder() { + return getTransaction(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < approvedList_.size(); i++) { + output.writeBytes(2, approvedList_.get(i)); + } + if (result_ != null) { + output.writeMessage(4, getResult()); + } + if (transaction_ != null) { + output.writeMessage(5, getTransaction()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < approvedList_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(approvedList_.get(i)); + } + size += dataSize; + size += 1 * getApprovedListList().size(); + } + if (result_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getResult()); + } + if (transaction_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getTransaction()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.api.GrpcAPI.TransactionApprovedList)) { + return super.equals(obj); + } + org.tron.api.GrpcAPI.TransactionApprovedList other = (org.tron.api.GrpcAPI.TransactionApprovedList) obj; + + boolean result = true; + result = result && getApprovedListList() + .equals(other.getApprovedListList()); + result = result && (hasResult() == other.hasResult()); + if (hasResult()) { + result = result && getResult() + .equals(other.getResult()); + } + result = result && (hasTransaction() == other.hasTransaction()); + if (hasTransaction()) { + result = result && getTransaction() + .equals(other.getTransaction()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getApprovedListCount() > 0) { + hash = (37 * hash) + APPROVED_LIST_FIELD_NUMBER; + hash = (53 * hash) + getApprovedListList().hashCode(); + } + if (hasResult()) { + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + getResult().hashCode(); + } + if (hasTransaction()) { + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.api.GrpcAPI.TransactionApprovedList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.api.GrpcAPI.TransactionApprovedList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionApprovedList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionApprovedList) + org.tron.api.GrpcAPI.TransactionApprovedListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.api.GrpcAPI.TransactionApprovedList.class, org.tron.api.GrpcAPI.TransactionApprovedList.Builder.class); + } + + // Construct using org.tron.api.GrpcAPI.TransactionApprovedList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + approvedList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + if (resultBuilder_ == null) { + result_ = null; + } else { + result_ = null; + resultBuilder_ = null; + } + if (transactionBuilder_ == null) { + transaction_ = null; + } else { + transaction_ = null; + transactionBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.api.GrpcAPI.internal_static_protocol_TransactionApprovedList_descriptor; + } + + public org.tron.api.GrpcAPI.TransactionApprovedList getDefaultInstanceForType() { + return org.tron.api.GrpcAPI.TransactionApprovedList.getDefaultInstance(); + } + + public org.tron.api.GrpcAPI.TransactionApprovedList build() { + org.tron.api.GrpcAPI.TransactionApprovedList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.api.GrpcAPI.TransactionApprovedList buildPartial() { + org.tron.api.GrpcAPI.TransactionApprovedList result = new org.tron.api.GrpcAPI.TransactionApprovedList(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + approvedList_ = java.util.Collections.unmodifiableList(approvedList_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.approvedList_ = approvedList_; + if (resultBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = resultBuilder_.build(); + } + if (transactionBuilder_ == null) { + result.transaction_ = transaction_; + } else { + result.transaction_ = transactionBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.api.GrpcAPI.TransactionApprovedList) { + return mergeFrom((org.tron.api.GrpcAPI.TransactionApprovedList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.api.GrpcAPI.TransactionApprovedList other) { + if (other == org.tron.api.GrpcAPI.TransactionApprovedList.getDefaultInstance()) return this; + if (!other.approvedList_.isEmpty()) { + if (approvedList_.isEmpty()) { + approvedList_ = other.approvedList_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureApprovedListIsMutable(); + approvedList_.addAll(other.approvedList_); + } + onChanged(); + } + if (other.hasResult()) { + mergeResult(other.getResult()); + } + if (other.hasTransaction()) { + mergeTransaction(other.getTransaction()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.api.GrpcAPI.TransactionApprovedList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.api.GrpcAPI.TransactionApprovedList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List approvedList_ = java.util.Collections.emptyList(); + private void ensureApprovedListIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + approvedList_ = new java.util.ArrayList(approvedList_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated bytes approved_list = 2; + */ + public java.util.List + getApprovedListList() { + return java.util.Collections.unmodifiableList(approvedList_); + } + /** + * repeated bytes approved_list = 2; + */ + public int getApprovedListCount() { + return approvedList_.size(); + } + /** + * repeated bytes approved_list = 2; + */ + public com.google.protobuf.ByteString getApprovedList(int index) { + return approvedList_.get(index); + } + /** + * repeated bytes approved_list = 2; + */ + public Builder setApprovedList( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureApprovedListIsMutable(); + approvedList_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes approved_list = 2; + */ + public Builder addApprovedList(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureApprovedListIsMutable(); + approvedList_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes approved_list = 2; + */ + public Builder addAllApprovedList( + java.lang.Iterable values) { + ensureApprovedListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, approvedList_); + onChanged(); + return this; + } + /** + * repeated bytes approved_list = 2; + */ + public Builder clearApprovedList() { + approvedList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + private org.tron.api.GrpcAPI.TransactionApprovedList.Result result_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionApprovedList.Result, org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder, org.tron.api.GrpcAPI.TransactionApprovedList.ResultOrBuilder> resultBuilder_; + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public boolean hasResult() { + return resultBuilder_ != null || result_ != null; + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionApprovedList.Result getResult() { + if (resultBuilder_ == null) { + return result_ == null ? org.tron.api.GrpcAPI.TransactionApprovedList.Result.getDefaultInstance() : result_; + } else { + return resultBuilder_.getMessage(); + } + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public Builder setResult(org.tron.api.GrpcAPI.TransactionApprovedList.Result value) { + if (resultBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + resultBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public Builder setResult( + org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder builderForValue) { + if (resultBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + resultBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public Builder mergeResult(org.tron.api.GrpcAPI.TransactionApprovedList.Result value) { + if (resultBuilder_ == null) { + if (result_ != null) { + result_ = + org.tron.api.GrpcAPI.TransactionApprovedList.Result.newBuilder(result_).mergeFrom(value).buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + resultBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public Builder clearResult() { + if (resultBuilder_ == null) { + result_ = null; + onChanged(); + } else { + result_ = null; + resultBuilder_ = null; + } + + return this; + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder getResultBuilder() { + + onChanged(); + return getResultFieldBuilder().getBuilder(); + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + public org.tron.api.GrpcAPI.TransactionApprovedList.ResultOrBuilder getResultOrBuilder() { + if (resultBuilder_ != null) { + return resultBuilder_.getMessageOrBuilder(); + } else { + return result_ == null ? + org.tron.api.GrpcAPI.TransactionApprovedList.Result.getDefaultInstance() : result_; + } + } + /** + * .protocol.TransactionApprovedList.Result result = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionApprovedList.Result, org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder, org.tron.api.GrpcAPI.TransactionApprovedList.ResultOrBuilder> + getResultFieldBuilder() { + if (resultBuilder_ == null) { + resultBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionApprovedList.Result, org.tron.api.GrpcAPI.TransactionApprovedList.Result.Builder, org.tron.api.GrpcAPI.TransactionApprovedList.ResultOrBuilder>( + getResult(), + getParentForChildren(), + isClean()); + result_ = null; + } + return resultBuilder_; + } + + private org.tron.api.GrpcAPI.TransactionExtention transaction_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> transactionBuilder_; + /** + * .protocol.TransactionExtention transaction = 5; + */ + public boolean hasTransaction() { + return transactionBuilder_ != null || transaction_ != null; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtention getTransaction() { + if (transactionBuilder_ == null) { + return transaction_ == null ? org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance() : transaction_; + } else { + return transactionBuilder_.getMessage(); + } + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder setTransaction(org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + onChanged(); + } else { + transactionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder setTransaction( + org.tron.api.GrpcAPI.TransactionExtention.Builder builderForValue) { + if (transactionBuilder_ == null) { + transaction_ = builderForValue.build(); + onChanged(); + } else { + transactionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder mergeTransaction(org.tron.api.GrpcAPI.TransactionExtention value) { + if (transactionBuilder_ == null) { + if (transaction_ != null) { + transaction_ = + org.tron.api.GrpcAPI.TransactionExtention.newBuilder(transaction_).mergeFrom(value).buildPartial(); + } else { + transaction_ = value; + } + onChanged(); + } else { + transactionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public Builder clearTransaction() { + if (transactionBuilder_ == null) { + transaction_ = null; + onChanged(); + } else { + transaction_ = null; + transactionBuilder_ = null; + } + + return this; + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtention.Builder getTransactionBuilder() { + + onChanged(); + return getTransactionFieldBuilder().getBuilder(); + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + public org.tron.api.GrpcAPI.TransactionExtentionOrBuilder getTransactionOrBuilder() { + if (transactionBuilder_ != null) { + return transactionBuilder_.getMessageOrBuilder(); + } else { + return transaction_ == null ? + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance() : transaction_; + } + } + /** + * .protocol.TransactionExtention transaction = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder> + getTransactionFieldBuilder() { + if (transactionBuilder_ == null) { + transactionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.api.GrpcAPI.TransactionExtention, org.tron.api.GrpcAPI.TransactionExtention.Builder, org.tron.api.GrpcAPI.TransactionExtentionOrBuilder>( + getTransaction(), + getParentForChildren(), + isClean()); + transaction_ = null; + } + return transactionBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionApprovedList) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionApprovedList) + private static final org.tron.api.GrpcAPI.TransactionApprovedList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.api.GrpcAPI.TransactionApprovedList(); + } + + public static org.tron.api.GrpcAPI.TransactionApprovedList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionApprovedList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionApprovedList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.api.GrpcAPI.TransactionApprovedList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Return_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Return_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockReference_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockReference_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_WitnessList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_WitnessList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ProposalList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ProposalList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ExchangeList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ExchangeList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AssetIssueList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AssetIssueList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_DelegatedResourceMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_DelegatedResourceMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_DelegatedResourceList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_DelegatedResourceList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Node_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Node_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Address_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Address_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_EmptyMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_EmptyMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NumberMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NumberMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BytesMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BytesMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TimeMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TimeMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockLimit_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockLimit_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionLimit_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionLimit_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountPaginated_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountPaginated_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TimePaginatedMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TimePaginatedMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountNetMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountNetMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountNetMessage_AssetNetUsedEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountNetMessage_AssetNetUsedEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountNetMessage_AssetNetLimitEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountNetMessage_AssetNetLimitEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountResourceMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountResourceMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountResourceMessage_AssetNetUsedEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountResourceMessage_AssetNetUsedEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountResourceMessage_AssetNetLimitEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountResourceMessage_AssetNetLimitEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_PaginatedMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_PaginatedMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_EasyTransferMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_EasyTransferMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_EasyTransferAssetMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_EasyTransferAssetMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_EasyTransferByPrivateMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_EasyTransferByPrivateMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_EasyTransferAssetByPrivateMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_EasyTransferAssetByPrivateMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_EasyTransferResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_EasyTransferResponse_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AddressPrKeyPairMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AddressPrKeyPairMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionExtention_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionExtention_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockExtention_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockExtention_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockListExtention_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockListExtention_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionListExtention_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionListExtention_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionSignWeight_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionSignWeight_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionSignWeight_Result_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionSignWeight_Result_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionApprovedList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionApprovedList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionApprovedList_Result_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionApprovedList_Result_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\rapi/api.proto\022\010protocol\032\017core/Tron.pro" + + "to\032\023core/Contract.proto\032\034google/api/anno" + + "tations.proto\"\224\003\n\006Return\022\016\n\006result\030\001 \001(\010" + + "\022,\n\004code\030\002 \001(\0162\036.protocol.Return.respons" + + "e_code\022\017\n\007message\030\003 \001(\014\"\272\002\n\rresponse_cod" + + "e\022\013\n\007SUCCESS\020\000\022\014\n\010SIGERROR\020\001\022\033\n\027CONTRACT" + + "_VALIDATE_ERROR\020\002\022\026\n\022CONTRACT_EXE_ERROR\020" + + "\003\022\022\n\016BANDWITH_ERROR\020\004\022\031\n\025DUP_TRANSACTION" + + "_ERROR\020\005\022\017\n\013TAPOS_ERROR\020\006\022\035\n\031TOO_BIG_TRA" + + "NSACTION_ERROR\020\007\022 \n\034TRANSACTION_EXPIRATI" + + "ON_ERROR\020\010\022\017\n\013SERVER_BUSY\020\t\022\021\n\rNO_CONNEC" + + "TION\020\n\022#\n\037NOT_ENOUGH_EFFECTIVE_CONNECTIO" + + "N\020\013\022\017\n\013OTHER_ERROR\020\024\"7\n\016BlockReference\022\021" + + "\n\tblock_num\030\001 \001(\003\022\022\n\nblock_hash\030\002 \001(\014\"3\n" + + "\013WitnessList\022$\n\twitnesses\030\001 \003(\0132\021.protoc" + + "ol.Witness\"5\n\014ProposalList\022%\n\tproposals\030" + + "\001 \003(\0132\022.protocol.Proposal\"5\n\014ExchangeLis" + + "t\022%\n\texchanges\030\001 \003(\0132\022.protocol.Exchange" + + "\"B\n\016AssetIssueList\0220\n\nassetIssue\030\001 \003(\0132\034" + + ".protocol.AssetIssueContract\"+\n\tBlockLis" + + "t\022\036\n\005block\030\001 \003(\0132\017.protocol.Block\"=\n\017Tra" + + "nsactionList\022*\n\013transaction\030\001 \003(\0132\025.prot" + + "ocol.Transaction\"B\n\030DelegatedResourceMes" + + "sage\022\023\n\013fromAddress\030\001 \001(\014\022\021\n\ttoAddress\030\002" + + " \001(\014\"O\n\025DelegatedResourceList\0226\n\021delegat" + + "edResource\030\001 \003(\0132\033.protocol.DelegatedRes" + + "ource\")\n\010NodeList\022\035\n\005nodes\030\001 \003(\0132\016.proto" + + "col.Node\"*\n\004Node\022\"\n\007address\030\001 \001(\0132\021.prot" + + "ocol.Address\"%\n\007Address\022\014\n\004host\030\001 \001(\014\022\014\n" + + "\004port\030\002 \001(\005\"\016\n\014EmptyMessage\"\034\n\rNumberMes" + + "sage\022\013\n\003num\030\001 \001(\003\"\035\n\014BytesMessage\022\r\n\005val" + + "ue\030\001 \001(\014\"E\n\013TimeMessage\022\033\n\023beginInMillis" + + "econds\030\001 \001(\003\022\031\n\021endInMilliseconds\030\002 \001(\003\"" + + ".\n\nBlockLimit\022\020\n\010startNum\030\001 \001(\003\022\016\n\006endNu" + + "m\030\002 \001(\003\";\n\020TransactionLimit\022\025\n\rtransacti" + + "onId\030\001 \001(\014\022\020\n\010limitNum\030\002 \001(\003\"U\n\020AccountP" + + "aginated\022\"\n\007account\030\001 \001(\0132\021.protocol.Acc" + + "ount\022\016\n\006offset\030\002 \001(\003\022\r\n\005limit\030\003 \001(\003\"a\n\024T" + + "imePaginatedMessage\022*\n\013timeMessage\030\001 \001(\013" + + "2\025.protocol.TimeMessage\022\016\n\006offset\030\002 \001(\003\022" + + "\r\n\005limit\030\003 \001(\003\"\207\003\n\021AccountNetMessage\022\023\n\013" + + "freeNetUsed\030\001 \001(\003\022\024\n\014freeNetLimit\030\002 \001(\003\022" + + "\017\n\007NetUsed\030\003 \001(\003\022\020\n\010NetLimit\030\004 \001(\003\022C\n\014as" + + "setNetUsed\030\005 \003(\0132-.protocol.AccountNetMe" + + "ssage.AssetNetUsedEntry\022E\n\rassetNetLimit" + + "\030\006 \003(\0132..protocol.AccountNetMessage.Asse" + + "tNetLimitEntry\022\025\n\rTotalNetLimit\030\007 \001(\003\022\026\n" + + "\016TotalNetWeight\030\010 \001(\003\0323\n\021AssetNetUsedEnt" + + "ry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\003:\0028\001\0324\n\022As" + + "setNetLimitEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002" + + " \001(\003:\0028\001\"\237\004\n\026AccountResourceMessage\022\023\n\013f" + + "reeNetUsed\030\001 \001(\003\022\024\n\014freeNetLimit\030\002 \001(\003\022\017" + + "\n\007NetUsed\030\003 \001(\003\022\020\n\010NetLimit\030\004 \001(\003\022H\n\014ass" + + "etNetUsed\030\005 \003(\01322.protocol.AccountResour" + + "ceMessage.AssetNetUsedEntry\022J\n\rassetNetL" + + "imit\030\006 \003(\01323.protocol.AccountResourceMes" + + "sage.AssetNetLimitEntry\022\025\n\rTotalNetLimit" + + "\030\007 \001(\003\022\026\n\016TotalNetWeight\030\010 \001(\003\022\022\n\nEnergy" + + "Used\030\r \001(\003\022\023\n\013EnergyLimit\030\016 \001(\003\022\030\n\020Total" + + "EnergyLimit\030\017 \001(\003\022\031\n\021TotalEnergyWeight\030\020" + + " \001(\003\022\023\n\013storageUsed\030\025 \001(\003\022\024\n\014storageLimi" + + "t\030\026 \001(\003\0323\n\021AssetNetUsedEntry\022\013\n\003key\030\001 \001(" + + "\t\022\r\n\005value\030\002 \001(\003:\0028\001\0324\n\022AssetNetLimitEnt" + + "ry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\003:\0028\001\"1\n\020Pa" + + "ginatedMessage\022\016\n\006offset\030\001 \001(\003\022\r\n\005limit\030" + + "\002 \001(\003\"L\n\023EasyTransferMessage\022\022\n\npassPhra" + + "se\030\001 \001(\014\022\021\n\ttoAddress\030\002 \001(\014\022\016\n\006amount\030\003 " + + "\001(\003\"b\n\030EasyTransferAssetMessage\022\022\n\npassP" + + "hrase\030\001 \001(\014\022\021\n\ttoAddress\030\002 \001(\014\022\017\n\007assetI" + + "d\030\003 \001(\t\022\016\n\006amount\030\004 \001(\003\"U\n\034EasyTransferB" + + "yPrivateMessage\022\022\n\nprivateKey\030\001 \001(\014\022\021\n\tt" + + "oAddress\030\002 \001(\014\022\016\n\006amount\030\003 \001(\003\"k\n!EasyTr" + + "ansferAssetByPrivateMessage\022\022\n\nprivateKe" + + "y\030\001 \001(\014\022\021\n\ttoAddress\030\002 \001(\014\022\017\n\007assetId\030\003 " + + "\001(\t\022\016\n\006amount\030\004 \001(\003\"r\n\024EasyTransferRespo" + + "nse\022*\n\013transaction\030\001 \001(\0132\025.protocol.Tran" + + "saction\022 \n\006result\030\002 \001(\0132\020.protocol.Retur" + + "n\022\014\n\004txid\030\003 \001(\014\">\n\027AddressPrKeyPairMessa" + + "ge\022\017\n\007address\030\001 \001(\t\022\022\n\nprivateKey\030\002 \001(\t\"" + + "\213\001\n\024TransactionExtention\022*\n\013transaction\030" + + "\001 \001(\0132\025.protocol.Transaction\022\014\n\004txid\030\002 \001" + + "(\014\022\027\n\017constant_result\030\003 \003(\014\022 \n\006result\030\004 " + + "\001(\0132\020.protocol.Return\"\204\001\n\016BlockExtention" + + "\0224\n\014transactions\030\001 \003(\0132\036.protocol.Transa" + + "ctionExtention\022+\n\014block_header\030\002 \001(\0132\025.p" + + "rotocol.BlockHeader\022\017\n\007blockid\030\003 \001(\014\"=\n\022" + + "BlockListExtention\022\'\n\005block\030\001 \003(\0132\030.prot" + + "ocol.BlockExtention\"O\n\030TransactionListEx" + + "tention\0223\n\013transaction\030\001 \003(\0132\036.protocol." + + "TransactionExtention\"\337\003\n\025TransactionSign" + + "Weight\022(\n\npermission\030\001 \001(\0132\024.protocol.Pe" + + "rmission\022\025\n\rapproved_list\030\002 \003(\014\022\026\n\016curre" + + "nt_weight\030\003 \001(\003\0226\n\006result\030\004 \001(\0132&.protoc" + + "ol.TransactionSignWeight.Result\0223\n\013trans" + + "action\030\005 \001(\0132\036.protocol.TransactionExten" + + "tion\032\377\001\n\006Result\022B\n\004code\030\001 \001(\01624.protocol" + + ".TransactionSignWeight.Result.response_c" + + "ode\022\017\n\007message\030\002 \001(\t\"\237\001\n\rresponse_code\022\025" + + "\n\021ENOUGH_PERMISSION\020\000\022\031\n\025NOT_ENOUGH_PERM" + + "ISSION\020\001\022\032\n\026SIGNATURE_FORMAT_ERROR\020\002\022\031\n\025" + + "COMPUTE_ADDRESS_ERROR\020\003\022\024\n\020PERMISSION_ER" + + "ROR\020\004\022\017\n\013OTHER_ERROR\020\024\"\347\002\n\027TransactionAp" + + "provedList\022\025\n\rapproved_list\030\002 \003(\014\0228\n\006res" + + "ult\030\004 \001(\0132(.protocol.TransactionApproved" + + "List.Result\0223\n\013transaction\030\005 \001(\0132\036.proto" + + "col.TransactionExtention\032\305\001\n\006Result\022D\n\004c" + + "ode\030\001 \001(\01626.protocol.TransactionApproved" + + "List.Result.response_code\022\017\n\007message\030\002 \001" + + "(\t\"d\n\rresponse_code\022\013\n\007SUCCESS\020\000\022\032\n\026SIGN" + + "ATURE_FORMAT_ERROR\020\001\022\031\n\025COMPUTE_ADDRESS_" + + "ERROR\020\002\022\017\n\013OTHER_ERROR\020\0242\235R\n\006Wallet\022g\n\nG" + + "etAccount\022\021.protocol.Account\032\021.protocol." + + "Account\"3\202\323\344\223\002-\"\022/wallet/getaccount:\001*Z\024" + + "\022\022/wallet/getaccount\022s\n\016GetAccountById\022\021" + + ".protocol.Account\032\021.protocol.Account\";\202\323" + + "\344\223\0025\"\026/wallet/getaccountbyid:\001*Z\030\022\026/wall" + + "et/getaccountbyid\022\211\001\n\021CreateTransaction\022" + + "\032.protocol.TransferContract\032\025.protocol.T" + + "ransaction\"A\202\323\344\223\002;\"\031/wallet/createtransa" + + "ction:\001*Z\033\022\031/wallet/createtransaction\022R\n" + + "\022CreateTransaction2\022\032.protocol.TransferC" + + "ontract\032\036.protocol.TransactionExtention\"" + + "\000\022\210\001\n\024BroadcastTransaction\022\025.protocol.Tr" + + "ansaction\032\020.protocol.Return\"G\202\323\344\223\002A\"\034/wa" + + "llet/broadcasttransaction:\001*Z\036\022\034/wallet/" + + "broadcasttransaction\022\202\001\n\rUpdateAccount\022\037" + + ".protocol.AccountUpdateContract\032\025.protoc" + + "ol.Transaction\"9\202\323\344\223\0023\"\025/wallet/updateac" + + "count:\001*Z\027\022\025/wallet/updateaccount\022~\n\014Set" + + "AccountId\022\036.protocol.SetAccountIdContrac" + + "t\032\025.protocol.Transaction\"7\202\323\344\223\0021\"\024/walle" + + "t/setaccountid:\001*Z\026\022\024/wallet/setaccounti" + + "d\022S\n\016UpdateAccount2\022\037.protocol.AccountUp" + + "dateContract\032\036.protocol.TransactionExten" + + "tion\"\000\022\217\001\n\022VoteWitnessAccount\022\035.protocol" + + ".VoteWitnessContract\032\025.protocol.Transact" + + "ion\"C\202\323\344\223\002=\"\032/wallet/votewitnessaccount:" + + "\001*Z\034\022\032/wallet/votewitnessaccount\022R\n\rUpda" + + "teSetting\022\037.protocol.UpdateSettingContra" + + "ct\032\036.protocol.TransactionExtention\"\000\022Z\n\021" + + "UpdateEnergyLimit\022#.protocol.UpdateEnerg" + + "yLimitContract\032\036.protocol.TransactionExt" + + "ention\"\000\022V\n\023VoteWitnessAccount2\022\035.protoc" + + "ol.VoteWitnessContract\032\036.protocol.Transa" + + "ctionExtention\"\000\022\210\001\n\020CreateAssetIssue\022\034." + + "protocol.AssetIssueContract\032\025.protocol.T" + + "ransaction\"?\202\323\344\223\0029\"\030/wallet/createasseti" + + "ssue:\001*Z\032\022\030/wallet/createassetissue\022S\n\021C" + + "reateAssetIssue2\022\034.protocol.AssetIssueCo" + + "ntract\032\036.protocol.TransactionExtention\"\000" + + "\022\202\001\n\rUpdateWitness\022\037.protocol.WitnessUpd" + + "ateContract\032\025.protocol.Transaction\"9\202\323\344\223" + + "\0023\"\025/wallet/updatewitness:\001*Z\027\022\025/wallet/" + + "updatewitness\022S\n\016UpdateWitness2\022\037.protoc" + + "ol.WitnessUpdateContract\032\036.protocol.Tran" + + "sactionExtention\"\000\022\202\001\n\rCreateAccount\022\037.p" + + "rotocol.AccountCreateContract\032\025.protocol" + + ".Transaction\"9\202\323\344\223\0023\"\025/wallet/createacco" + + "unt:\001*Z\027\022\025/wallet/createaccount\022S\n\016Creat" + + "eAccount2\022\037.protocol.AccountCreateContra" + + "ct\032\036.protocol.TransactionExtention\"\000\022\202\001\n" + + "\rCreateWitness\022\037.protocol.WitnessCreateC" + + "ontract\032\025.protocol.Transaction\"9\202\323\344\223\0023\"\025" + + "/wallet/createwitness:\001*Z\027\022\025/wallet/crea" + + "tewitness\022S\n\016CreateWitness2\022\037.protocol.W" + + "itnessCreateContract\032\036.protocol.Transact" + + "ionExtention\"\000\022\202\001\n\rTransferAsset\022\037.proto" + + "col.TransferAssetContract\032\025.protocol.Tra" + + "nsaction\"9\202\323\344\223\0023\"\025/wallet/transferasset:" + + "\001*Z\027\022\025/wallet/transferasset\022S\n\016TransferA" + + "sset2\022\037.protocol.TransferAssetContract\032\036" + + ".protocol.TransactionExtention\"\000\022\242\001\n\025Par" + + "ticipateAssetIssue\022\'.protocol.Participat" + + "eAssetIssueContract\032\025.protocol.Transacti" + + "on\"I\202\323\344\223\002C\"\035/wallet/participateassetissu" + + "e:\001*Z\037\022\035/wallet/participateassetissue\022c\n" + + "\026ParticipateAssetIssue2\022\'.protocol.Parti" + + "cipateAssetIssueContract\032\036.protocol.Tran" + + "sactionExtention\"\000\022\202\001\n\rFreezeBalance\022\037.p" + + "rotocol.FreezeBalanceContract\032\025.protocol" + + ".Transaction\"9\202\323\344\223\0023\"\025/wallet/freezebala" + + "nce:\001*Z\027\022\025/wallet/freezebalance\022S\n\016Freez" + + "eBalance2\022\037.protocol.FreezeBalanceContra" + + "ct\032\036.protocol.TransactionExtention\"\000\022\212\001\n" + + "\017UnfreezeBalance\022!.protocol.UnfreezeBala" + + "nceContract\032\025.protocol.Transaction\"=\202\323\344\223" + + "\0027\"\027/wallet/unfreezebalance:\001*Z\031\022\027/walle" + + "t/unfreezebalance\022W\n\020UnfreezeBalance2\022!." + + "protocol.UnfreezeBalanceContract\032\036.proto" + + "col.TransactionExtention\"\000\022\202\001\n\rUnfreezeA" + + "sset\022\037.protocol.UnfreezeAssetContract\032\025." + + "protocol.Transaction\"9\202\323\344\223\0023\"\025/wallet/un" + + "freezeasset:\001*Z\027\022\025/wallet/unfreezeasset\022" + + "S\n\016UnfreezeAsset2\022\037.protocol.UnfreezeAss" + + "etContract\032\036.protocol.TransactionExtenti" + + "on\"\000\022\212\001\n\017WithdrawBalance\022!.protocol.With" + + "drawBalanceContract\032\025.protocol.Transacti" + + "on\"=\202\323\344\223\0027\"\027/wallet/withdrawbalance:\001*Z\031" + + "\022\027/wallet/withdrawbalance\022W\n\020WithdrawBal" + + "ance2\022!.protocol.WithdrawBalanceContract" + + "\032\036.protocol.TransactionExtention\"\000\022z\n\013Up" + + "dateAsset\022\035.protocol.UpdateAssetContract" + + "\032\025.protocol.Transaction\"5\202\323\344\223\002/\"\023/wallet" + + "/updateasset:\001*Z\025\022\023/wallet/updateasset\022O" + + "\n\014UpdateAsset2\022\035.protocol.UpdateAssetCon" + + "tract\032\036.protocol.TransactionExtention\"\000\022" + + "T\n\016ProposalCreate\022 .protocol.ProposalCre" + + "ateContract\032\036.protocol.TransactionExtent" + + "ion\"\000\022V\n\017ProposalApprove\022!.protocol.Prop" + + "osalApproveContract\032\036.protocol.Transacti" + + "onExtention\"\000\022T\n\016ProposalDelete\022 .protoc" + + "ol.ProposalDeleteContract\032\036.protocol.Tra" + + "nsactionExtention\"\000\022L\n\nBuyStorage\022\034.prot" + + "ocol.BuyStorageContract\032\036.protocol.Trans" + + "actionExtention\"\000\022V\n\017BuyStorageBytes\022!.p" + + "rotocol.BuyStorageBytesContract\032\036.protoc" + + "ol.TransactionExtention\"\000\022N\n\013SellStorage" + + "\022\035.protocol.SellStorageContract\032\036.protoc" + + "ol.TransactionExtention\"\000\022T\n\016ExchangeCre" + + "ate\022 .protocol.ExchangeCreateContract\032\036." + + "protocol.TransactionExtention\"\000\022T\n\016Excha" + + "ngeInject\022 .protocol.ExchangeInjectContr" + + "act\032\036.protocol.TransactionExtention\"\000\022X\n" + + "\020ExchangeWithdraw\022\".protocol.ExchangeWit" + + "hdrawContract\032\036.protocol.TransactionExte" + + "ntion\"\000\022^\n\023ExchangeTransaction\022%.protoco" + + "l.ExchangeTransactionContract\032\036.protocol" + + ".TransactionExtention\"\000\022j\n\tListNodes\022\026.p" + + "rotocol.EmptyMessage\032\022.protocol.NodeList" + + "\"1\202\323\344\223\002+\"\021/wallet/listnodes:\001*Z\023\022\021/walle" + + "t/listnodes\022\222\001\n\026GetAssetIssueByAccount\022\021" + + ".protocol.Account\032\030.protocol.AssetIssueL" + + "ist\"K\202\323\344\223\002E\"\036/wallet/getassetissuebyacco" + + "unt:\001*Z \022\036/wallet/getassetissuebyaccount" + + "\022z\n\rGetAccountNet\022\021.protocol.Account\032\033.p" + + "rotocol.AccountNetMessage\"9\202\323\344\223\0023\"\025/wall" + + "et/getaccountnet:\001*Z\027\022\025/wallet/getaccoun" + + "tnet\022K\n\022GetAccountResource\022\021.protocol.Ac" + + "count\032 .protocol.AccountResourceMessage\"" + + "\000\022\222\001\n\023GetAssetIssueByName\022\026.protocol.Byt" + + "esMessage\032\034.protocol.AssetIssueContract\"" + + "E\202\323\344\223\002?\"\033/wallet/getassetissuebyname:\001*Z" + + "\035\022\033/wallet/getassetissuebyname\022M\n\027GetAss" + + "etIssueListByName\022\026.protocol.BytesMessag" + + "e\032\030.protocol.AssetIssueList\"\000\022K\n\021GetAsse" + + "tIssueById\022\026.protocol.BytesMessage\032\034.pro" + + "tocol.AssetIssueContract\"\000\022m\n\013GetNowBloc" + + "k\022\026.protocol.EmptyMessage\032\017.protocol.Blo" + + "ck\"5\202\323\344\223\002/\"\023/wallet/getnowblock:\001*Z\025\022\023/w" + + "allet/getnowblock\022B\n\014GetNowBlock2\022\026.prot" + + "ocol.EmptyMessage\032\030.protocol.BlockExtent" + + "ion\"\000\022t\n\rGetBlockByNum\022\027.protocol.Number" + + "Message\032\017.protocol.Block\"9\202\323\344\223\0023\"\025/walle" + + "t/getblockbynum:\001*Z\027\022\025/wallet/getblockby" + + "num\022E\n\016GetBlockByNum2\022\027.protocol.NumberM" + + "essage\032\030.protocol.BlockExtention\"\000\022S\n\035Ge" + + "tTransactionCountByBlockNum\022\027.protocol.N" + + "umberMessage\032\027.protocol.NumberMessage\"\000\022" + + "p\n\014GetBlockById\022\026.protocol.BytesMessage\032" + + "\017.protocol.Block\"7\202\323\344\223\0021\"\024/wallet/getblo" + + "ckbyid:\001*Z\026\022\024/wallet/getblockbyid\022\207\001\n\023Ge" + + "tBlockByLimitNext\022\024.protocol.BlockLimit\032" + + "\023.protocol.BlockList\"E\202\323\344\223\002?\"\033/wallet/ge" + + "tblockbylimitnext:\001*Z\035\022\033/wallet/getblock" + + "bylimitnext\022L\n\024GetBlockByLimitNext2\022\024.pr" + + "otocol.BlockLimit\032\034.protocol.BlockListEx" + + "tention\"\000\022\212\001\n\023GetBlockByLatestNum\022\027.prot" + + "ocol.NumberMessage\032\023.protocol.BlockList\"" + + "E\202\323\344\223\002?\"\033/wallet/getblockbylatestnum:\001*Z" + + "\035\022\033/wallet/getblockbylatestnum\022O\n\024GetBlo" + + "ckByLatestNum2\022\027.protocol.NumberMessage\032" + + "\034.protocol.BlockListExtention\"\000\022\210\001\n\022GetT" + + "ransactionById\022\026.protocol.BytesMessage\032\025" + + ".protocol.Transaction\"C\202\323\344\223\002=\"\032/wallet/g" + + "ettransactionbyid:\001*Z\034\022\032/wallet/gettrans" + + "actionbyid\022Q\n\016DeployContract\022\035.protocol." + + "CreateSmartContract\032\036.protocol.Transacti" + + "onExtention\"\000\022@\n\013GetContract\022\026.protocol." + + "BytesMessage\032\027.protocol.SmartContract\"\000\022" + + "S\n\017TriggerContract\022\036.protocol.TriggerSma" + + "rtContract\032\036.protocol.TransactionExtenti" + + "on\"\000\022[\n\027TriggerConstantContract\022\036.protoc" + + "ol.TriggerSmartContract\032\036.protocol.Trans" + + "actionExtention\"\000\022P\n\020ClearContractABI\022\032." + + "protocol.ClearABIContract\032\036.protocol.Tra" + + "nsactionExtention\"\000\022y\n\rListWitnesses\022\026.p" + + "rotocol.EmptyMessage\032\025.protocol.WitnessL" + + "ist\"9\202\323\344\223\0023\"\025/wallet/listwitnesses:\001*Z\027\022" + + "\025/wallet/listwitnesses\022]\n\024GetDelegatedRe" + + "source\022\".protocol.DelegatedResourceMessa" + + "ge\032\037.protocol.DelegatedResourceList\"\000\022e\n" + + " GetDelegatedResourceAccountIndex\022\026.prot" + + "ocol.BytesMessage\032\'.protocol.DelegatedRe" + + "sourceAccountIndex\"\000\022z\n\rListProposals\022\026." + + "protocol.EmptyMessage\032\026.protocol.Proposa" + + "lList\"9\202\323\344\223\0023\"\025/wallet/listproposals:\001*Z" + + "\027\022\025/wallet/listproposals\022\237\001\n\030GetPaginate" + + "dProposalList\022\032.protocol.PaginatedMessag" + + "e\032\026.protocol.ProposalList\"O\202\323\344\223\002I\" /wall" + + "et/getpaginatedproposallist:\001*Z\"\022 /walle" + + "t/getpaginatedproposallist\022|\n\017GetProposa" + + "lById\022\026.protocol.BytesMessage\032\022.protocol" + + ".Proposal\"=\202\323\344\223\0027\"\027/wallet/getproposalby" + + "id:\001*Z\031\022\027/wallet/getproposalbyid\022z\n\rList" + + "Exchanges\022\026.protocol.EmptyMessage\032\026.prot" + + "ocol.ExchangeList\"9\202\323\344\223\0023\"\025/wallet/liste" + + "xchanges:\001*Z\027\022\025/wallet/listexchanges\022\237\001\n" + + "\030GetPaginatedExchangeList\022\032.protocol.Pag" + + "inatedMessage\032\026.protocol.ExchangeList\"O\202" + + "\323\344\223\002I\" /wallet/getpaginatedexchangelist:" + + "\001*Z\"\022 /wallet/getpaginatedexchangelist\022|" + + "\n\017GetExchangeById\022\026.protocol.BytesMessag" + + "e\032\022.protocol.Exchange\"=\202\323\344\223\0027\"\027/wallet/g" + + "etexchangebyid:\001*Z\031\022\027/wallet/getexchange" + + "byid\022\214\001\n\022GetChainParameters\022\026.protocol.E" + + "mptyMessage\032\031.protocol.ChainParameters\"C" + + "\202\323\344\223\002=\"\032/wallet/getchainparameters:\001*Z\034\022" + + "\032/wallet/getchainparameters\022\210\001\n\021GetAsset" + + "IssueList\022\026.protocol.EmptyMessage\032\030.prot" + + "ocol.AssetIssueList\"A\202\323\344\223\002;\"\031/wallet/get" + + "assetissuelist:\001*Z\033\022\031/wallet/getassetiss" + + "uelist\022\247\001\n\032GetPaginatedAssetIssueList\022\032." + + "protocol.PaginatedMessage\032\030.protocol.Ass" + + "etIssueList\"S\202\323\344\223\002M\"\"/wallet/getpaginate" + + "dassetissuelist:\001*Z$\022\"/wallet/getpaginat" + + "edassetissuelist\022\204\001\n\020TotalTransaction\022\026." + + "protocol.EmptyMessage\032\027.protocol.NumberM" + + "essage\"?\202\323\344\223\0029\"\030/wallet/totaltransaction" + + ":\001*Z\032\022\030/wallet/totaltransaction\022\226\001\n\026GetN" + + "extMaintenanceTime\022\026.protocol.EmptyMessa" + + "ge\032\027.protocol.NumberMessage\"K\202\323\344\223\002E\"\036/wa" + + "llet/getnextmaintenancetime:\001*Z \022\036/walle" + + "t/getnextmaintenancetime\022\213\001\n\022GetTransact" + + "ionSign\022\031.protocol.TransactionSign\032\025.pro" + + "tocol.Transaction\"C\202\323\344\223\002=\"\032/wallet/gettr" + + "ansactionsign:\001*Z\034\022\032/wallet/gettransacti" + + "onsign\022R\n\023GetTransactionSign2\022\031.protocol" + + ".TransactionSign\032\036.protocol.TransactionE" + + "xtention\"\000\022z\n\rCreateAddress\022\026.protocol.B" + + "ytesMessage\032\026.protocol.BytesMessage\"9\202\323\344" + + "\223\0023\"\025/wallet/createaddress:\001*Z\027\022\025/wallet" + + "/createaddress\022Y\n\021EasyTransferAsset\022\".pr" + + "otocol.EasyTransferAssetMessage\032\036.protoc" + + "ol.EasyTransferResponse\"\000\022k\n\032EasyTransfe" + + "rAssetByPrivate\022+.protocol.EasyTransferA" + + "ssetByPrivateMessage\032\036.protocol.EasyTran" + + "sferResponse\"\000\022\206\001\n\014EasyTransfer\022\035.protoc" + + "ol.EasyTransferMessage\032\036.protocol.EasyTr" + + "ansferResponse\"7\202\323\344\223\0021\"\024/wallet/easytran" + + "sfer:\001*Z\026\022\024/wallet/easytransfer\022\252\001\n\025Easy" + + "TransferByPrivate\022&.protocol.EasyTransfe" + + "rByPrivateMessage\032\036.protocol.EasyTransfe" + + "rResponse\"I\202\323\344\223\002C\"\035/wallet/easytransferb" + + "yprivate:\001*Z\037\022\035/wallet/easytransferbypri" + + "vate\022\213\001\n\017GenerateAddress\022\026.protocol.Empt" + + "yMessage\032!.protocol.AddressPrKeyPairMess" + + "age\"=\202\323\344\223\0027\"\027/wallet/generateaddress:\001*Z" + + "\031\022\027/wallet/generateaddress\022\230\001\n\026GetTransa" + + "ctionInfoById\022\026.protocol.BytesMessage\032\031." + + "protocol.TransactionInfo\"K\202\323\344\223\002E\"\036/walle" + + "t/gettransactioninfobyid:\001*Z \022\036/wallet/g" + + "ettransactioninfobyid\022\263\001\n\027AccountPermiss" + + "ionUpdate\022).protocol.AccountPermissionUp" + + "dateContract\032\036.protocol.TransactionExten" + + "tion\"M\202\323\344\223\002G\"\037/wallet/accountpermissionu" + + "pdate:\001*Z!\022\037/wallet/accountpermissionupd" + + "ate\022F\n\007AddSign\022\031.protocol.TransactionSig" + + "n\032\036.protocol.TransactionExtention\"\000\022T\n\030G" + + "etTransactionSignWeight\022\025.protocol.Trans" + + "action\032\037.protocol.TransactionSignWeight\"" + + "\000\022X\n\032GetTransactionApprovedList\022\025.protoc" + + "ol.Transaction\032!.protocol.TransactionApp" + + "rovedList\"\000\022;\n\013GetNodeInfo\022\026.protocol.Em" + + "ptyMessage\032\022.protocol.NodeInfo\"\0002\357\021\n\016Wal" + + "letSolidity\022w\n\nGetAccount\022\021.protocol.Acc" + + "ount\032\021.protocol.Account\"C\202\323\344\223\002=\"\032/wallet" + + "solidity/getaccount:\001*Z\034\022\032/walletsolidit" + + "y/getaccount\022\203\001\n\016GetAccountById\022\021.protoc" + + "ol.Account\032\021.protocol.Account\"K\202\323\344\223\002E\"\036/" + + "walletsolidity/getaccountbyid:\001*Z \022\036/wal" + + "letsolidity/getaccountbyid\022\211\001\n\rListWitne" + + "sses\022\026.protocol.EmptyMessage\032\025.protocol." + + "WitnessList\"I\202\323\344\223\002C\"\035/walletsolidity/lis" + + "twitnesses:\001*Z\037\022\035/walletsolidity/listwit" + + "nesses\022\230\001\n\021GetAssetIssueList\022\026.protocol." + + "EmptyMessage\032\030.protocol.AssetIssueList\"Q" + + "\202\323\344\223\002K\"!/walletsolidity/getassetissuelis" + + "t:\001*Z#\022!/walletsolidity/getassetissuelis" + + "t\022\267\001\n\032GetPaginatedAssetIssueList\022\032.proto" + + "col.PaginatedMessage\032\030.protocol.AssetIss" + + "ueList\"c\202\323\344\223\002]\"*/walletsolidity/getpagin" + + "atedassetissuelist:\001*Z,\022*/walletsolidity" + + "/getpaginatedassetissuelist\022M\n\023GetAssetI" + + "ssueByName\022\026.protocol.BytesMessage\032\034.pro" + + "tocol.AssetIssueContract\"\000\022M\n\027GetAssetIs" + + "sueListByName\022\026.protocol.BytesMessage\032\030." + + "protocol.AssetIssueList\"\000\022K\n\021GetAssetIss" + + "ueById\022\026.protocol.BytesMessage\032\034.protoco" + + "l.AssetIssueContract\"\000\022}\n\013GetNowBlock\022\026." + + "protocol.EmptyMessage\032\017.protocol.Block\"E", + "\202\323\344\223\002?\"\033/walletsolidity/getnowblock:\001*Z\035" + + "\022\033/walletsolidity/getnowblock\022B\n\014GetNowB" + + "lock2\022\026.protocol.EmptyMessage\032\030.protocol" + + ".BlockExtention\"\000\022\204\001\n\rGetBlockByNum\022\027.pr" + + "otocol.NumberMessage\032\017.protocol.Block\"I\202" + + "\323\344\223\002C\"\035/walletsolidity/getblockbynum:\001*Z" + + "\037\022\035/walletsolidity/getblockbynum\022E\n\016GetB" + + "lockByNum2\022\027.protocol.NumberMessage\032\030.pr" + + "otocol.BlockExtention\"\000\022S\n\035GetTransactio" + + "nCountByBlockNum\022\027.protocol.NumberMessag" + + "e\032\027.protocol.NumberMessage\"\000\022]\n\024GetDeleg" + + "atedResource\022\".protocol.DelegatedResourc" + + "eMessage\032\037.protocol.DelegatedResourceLis" + + "t\"\000\022e\n GetDelegatedResourceAccountIndex\022" + + "\026.protocol.BytesMessage\032\'.protocol.Deleg" + + "atedResourceAccountIndex\"\000\022?\n\017GetExchang" + + "eById\022\026.protocol.BytesMessage\032\022.protocol" + + ".Exchange\"\000\022A\n\rListExchanges\022\026.protocol." + + "EmptyMessage\032\026.protocol.ExchangeList\"\000\022\230" + + "\001\n\022GetTransactionById\022\026.protocol.BytesMe" + + "ssage\032\025.protocol.Transaction\"S\202\323\344\223\002M\"\"/w" + + "alletsolidity/gettransactionbyid:\001*Z$\022\"/" + + "walletsolidity/gettransactionbyid\022\250\001\n\026Ge" + + "tTransactionInfoById\022\026.protocol.BytesMes" + + "sage\032\031.protocol.TransactionInfo\"[\202\323\344\223\002U\"" + + "&/walletsolidity/gettransactioninfobyid:" + + "\001*Z(\022&/walletsolidity/gettransactioninfo" + + "byid\022\233\001\n\017GenerateAddress\022\026.protocol.Empt" + + "yMessage\032!.protocol.AddressPrKeyPairMess" + + "age\"M\202\323\344\223\002G\"\037/walletsolidity/generateadd" + + "ress:\001*Z!\022\037/walletsolidity/generateaddre" + + "ss2\255\004\n\017WalletExtension\022\261\001\n\027GetTransactio" + + "nsFromThis\022\032.protocol.AccountPaginated\032\031" + + ".protocol.TransactionList\"_\202\323\344\223\002Y\"(/wall" + + "etextension/gettransactionsfromthis:\001*Z*" + + "\022(/walletextension/gettransactionsfromth" + + "is\022\\\n\030GetTransactionsFromThis2\022\032.protoco" + + "l.AccountPaginated\032\".protocol.Transactio" + + "nListExtention\"\000\022\253\001\n\025GetTransactionsToTh" + + "is\022\032.protocol.AccountPaginated\032\031.protoco" + + "l.TransactionList\"[\202\323\344\223\002U\"&/walletextens" + + "ion/gettransactionstothis:\001*Z(\022&/wallete" + + "xtension/gettransactionstothis\022Z\n\026GetTra" + + "nsactionsToThis2\022\032.protocol.AccountPagin" + + "ated\032\".protocol.TransactionListExtention" + + "\"\0002\231\002\n\010Database\022G\n\021getBlockReference\022\026.p" + + "rotocol.EmptyMessage\032\030.protocol.BlockRef" + + "erence\"\000\022M\n\024GetDynamicProperties\022\026.proto" + + "col.EmptyMessage\032\033.protocol.DynamicPrope" + + "rties\"\000\0228\n\013GetNowBlock\022\026.protocol.EmptyM" + + "essage\032\017.protocol.Block\"\000\022;\n\rGetBlockByN" + + "um\022\027.protocol.NumberMessage\032\017.protocol.B" + + "lock\"\0002\t\n\007NetworkBA\n\014org.tron.apiB\007GrpcA" + + "PIZ(github.com/tronprotocol/grpc-gateway" + + "/apib\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + org.tron.protos.Protocol.getDescriptor(), + org.tron.protos.Contract.getDescriptor(), + com.google.api.AnnotationsProto.getDescriptor(), + }, assigner); + internal_static_protocol_Return_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_protocol_Return_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Return_descriptor, + new java.lang.String[] { "Result", "Code", "Message", }); + internal_static_protocol_BlockReference_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_protocol_BlockReference_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockReference_descriptor, + new java.lang.String[] { "BlockNum", "BlockHash", }); + internal_static_protocol_WitnessList_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_protocol_WitnessList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_WitnessList_descriptor, + new java.lang.String[] { "Witnesses", }); + internal_static_protocol_ProposalList_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_protocol_ProposalList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ProposalList_descriptor, + new java.lang.String[] { "Proposals", }); + internal_static_protocol_ExchangeList_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_protocol_ExchangeList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ExchangeList_descriptor, + new java.lang.String[] { "Exchanges", }); + internal_static_protocol_AssetIssueList_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_protocol_AssetIssueList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AssetIssueList_descriptor, + new java.lang.String[] { "AssetIssue", }); + internal_static_protocol_BlockList_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_protocol_BlockList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockList_descriptor, + new java.lang.String[] { "Block", }); + internal_static_protocol_TransactionList_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_protocol_TransactionList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionList_descriptor, + new java.lang.String[] { "Transaction", }); + internal_static_protocol_DelegatedResourceMessage_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_protocol_DelegatedResourceMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_DelegatedResourceMessage_descriptor, + new java.lang.String[] { "FromAddress", "ToAddress", }); + internal_static_protocol_DelegatedResourceList_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_protocol_DelegatedResourceList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_DelegatedResourceList_descriptor, + new java.lang.String[] { "DelegatedResource", }); + internal_static_protocol_NodeList_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_protocol_NodeList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeList_descriptor, + new java.lang.String[] { "Nodes", }); + internal_static_protocol_Node_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_protocol_Node_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Node_descriptor, + new java.lang.String[] { "Address", }); + internal_static_protocol_Address_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_protocol_Address_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Address_descriptor, + new java.lang.String[] { "Host", "Port", }); + internal_static_protocol_EmptyMessage_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_protocol_EmptyMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_EmptyMessage_descriptor, + new java.lang.String[] { }); + internal_static_protocol_NumberMessage_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_protocol_NumberMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NumberMessage_descriptor, + new java.lang.String[] { "Num", }); + internal_static_protocol_BytesMessage_descriptor = + getDescriptor().getMessageTypes().get(15); + internal_static_protocol_BytesMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BytesMessage_descriptor, + new java.lang.String[] { "Value", }); + internal_static_protocol_TimeMessage_descriptor = + getDescriptor().getMessageTypes().get(16); + internal_static_protocol_TimeMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TimeMessage_descriptor, + new java.lang.String[] { "BeginInMilliseconds", "EndInMilliseconds", }); + internal_static_protocol_BlockLimit_descriptor = + getDescriptor().getMessageTypes().get(17); + internal_static_protocol_BlockLimit_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockLimit_descriptor, + new java.lang.String[] { "StartNum", "EndNum", }); + internal_static_protocol_TransactionLimit_descriptor = + getDescriptor().getMessageTypes().get(18); + internal_static_protocol_TransactionLimit_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionLimit_descriptor, + new java.lang.String[] { "TransactionId", "LimitNum", }); + internal_static_protocol_AccountPaginated_descriptor = + getDescriptor().getMessageTypes().get(19); + internal_static_protocol_AccountPaginated_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountPaginated_descriptor, + new java.lang.String[] { "Account", "Offset", "Limit", }); + internal_static_protocol_TimePaginatedMessage_descriptor = + getDescriptor().getMessageTypes().get(20); + internal_static_protocol_TimePaginatedMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TimePaginatedMessage_descriptor, + new java.lang.String[] { "TimeMessage", "Offset", "Limit", }); + internal_static_protocol_AccountNetMessage_descriptor = + getDescriptor().getMessageTypes().get(21); + internal_static_protocol_AccountNetMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountNetMessage_descriptor, + new java.lang.String[] { "FreeNetUsed", "FreeNetLimit", "NetUsed", "NetLimit", "AssetNetUsed", "AssetNetLimit", "TotalNetLimit", "TotalNetWeight", }); + internal_static_protocol_AccountNetMessage_AssetNetUsedEntry_descriptor = + internal_static_protocol_AccountNetMessage_descriptor.getNestedTypes().get(0); + internal_static_protocol_AccountNetMessage_AssetNetUsedEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountNetMessage_AssetNetUsedEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_AccountNetMessage_AssetNetLimitEntry_descriptor = + internal_static_protocol_AccountNetMessage_descriptor.getNestedTypes().get(1); + internal_static_protocol_AccountNetMessage_AssetNetLimitEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountNetMessage_AssetNetLimitEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_AccountResourceMessage_descriptor = + getDescriptor().getMessageTypes().get(22); + internal_static_protocol_AccountResourceMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountResourceMessage_descriptor, + new java.lang.String[] { "FreeNetUsed", "FreeNetLimit", "NetUsed", "NetLimit", "AssetNetUsed", "AssetNetLimit", "TotalNetLimit", "TotalNetWeight", "EnergyUsed", "EnergyLimit", "TotalEnergyLimit", "TotalEnergyWeight", "StorageUsed", "StorageLimit", }); + internal_static_protocol_AccountResourceMessage_AssetNetUsedEntry_descriptor = + internal_static_protocol_AccountResourceMessage_descriptor.getNestedTypes().get(0); + internal_static_protocol_AccountResourceMessage_AssetNetUsedEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountResourceMessage_AssetNetUsedEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_AccountResourceMessage_AssetNetLimitEntry_descriptor = + internal_static_protocol_AccountResourceMessage_descriptor.getNestedTypes().get(1); + internal_static_protocol_AccountResourceMessage_AssetNetLimitEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountResourceMessage_AssetNetLimitEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_PaginatedMessage_descriptor = + getDescriptor().getMessageTypes().get(23); + internal_static_protocol_PaginatedMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_PaginatedMessage_descriptor, + new java.lang.String[] { "Offset", "Limit", }); + internal_static_protocol_EasyTransferMessage_descriptor = + getDescriptor().getMessageTypes().get(24); + internal_static_protocol_EasyTransferMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_EasyTransferMessage_descriptor, + new java.lang.String[] { "PassPhrase", "ToAddress", "Amount", }); + internal_static_protocol_EasyTransferAssetMessage_descriptor = + getDescriptor().getMessageTypes().get(25); + internal_static_protocol_EasyTransferAssetMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_EasyTransferAssetMessage_descriptor, + new java.lang.String[] { "PassPhrase", "ToAddress", "AssetId", "Amount", }); + internal_static_protocol_EasyTransferByPrivateMessage_descriptor = + getDescriptor().getMessageTypes().get(26); + internal_static_protocol_EasyTransferByPrivateMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_EasyTransferByPrivateMessage_descriptor, + new java.lang.String[] { "PrivateKey", "ToAddress", "Amount", }); + internal_static_protocol_EasyTransferAssetByPrivateMessage_descriptor = + getDescriptor().getMessageTypes().get(27); + internal_static_protocol_EasyTransferAssetByPrivateMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_EasyTransferAssetByPrivateMessage_descriptor, + new java.lang.String[] { "PrivateKey", "ToAddress", "AssetId", "Amount", }); + internal_static_protocol_EasyTransferResponse_descriptor = + getDescriptor().getMessageTypes().get(28); + internal_static_protocol_EasyTransferResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_EasyTransferResponse_descriptor, + new java.lang.String[] { "Transaction", "Result", "Txid", }); + internal_static_protocol_AddressPrKeyPairMessage_descriptor = + getDescriptor().getMessageTypes().get(29); + internal_static_protocol_AddressPrKeyPairMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AddressPrKeyPairMessage_descriptor, + new java.lang.String[] { "Address", "PrivateKey", }); + internal_static_protocol_TransactionExtention_descriptor = + getDescriptor().getMessageTypes().get(30); + internal_static_protocol_TransactionExtention_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionExtention_descriptor, + new java.lang.String[] { "Transaction", "Txid", "ConstantResult", "Result", }); + internal_static_protocol_BlockExtention_descriptor = + getDescriptor().getMessageTypes().get(31); + internal_static_protocol_BlockExtention_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockExtention_descriptor, + new java.lang.String[] { "Transactions", "BlockHeader", "Blockid", }); + internal_static_protocol_BlockListExtention_descriptor = + getDescriptor().getMessageTypes().get(32); + internal_static_protocol_BlockListExtention_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockListExtention_descriptor, + new java.lang.String[] { "Block", }); + internal_static_protocol_TransactionListExtention_descriptor = + getDescriptor().getMessageTypes().get(33); + internal_static_protocol_TransactionListExtention_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionListExtention_descriptor, + new java.lang.String[] { "Transaction", }); + internal_static_protocol_TransactionSignWeight_descriptor = + getDescriptor().getMessageTypes().get(34); + internal_static_protocol_TransactionSignWeight_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionSignWeight_descriptor, + new java.lang.String[] { "Permission", "ApprovedList", "CurrentWeight", "Result", "Transaction", }); + internal_static_protocol_TransactionSignWeight_Result_descriptor = + internal_static_protocol_TransactionSignWeight_descriptor.getNestedTypes().get(0); + internal_static_protocol_TransactionSignWeight_Result_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionSignWeight_Result_descriptor, + new java.lang.String[] { "Code", "Message", }); + internal_static_protocol_TransactionApprovedList_descriptor = + getDescriptor().getMessageTypes().get(35); + internal_static_protocol_TransactionApprovedList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionApprovedList_descriptor, + new java.lang.String[] { "ApprovedList", "Result", "Transaction", }); + internal_static_protocol_TransactionApprovedList_Result_descriptor = + internal_static_protocol_TransactionApprovedList_descriptor.getNestedTypes().get(0); + internal_static_protocol_TransactionApprovedList_Result_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionApprovedList_Result_descriptor, + new java.lang.String[] { "Code", "Message", }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.AnnotationsProto.http); + com.google.protobuf.Descriptors.FileDescriptor + .internalUpdateFileDescriptor(descriptor, registry); + org.tron.protos.Protocol.getDescriptor(); + org.tron.protos.Contract.getDescriptor(); + com.google.api.AnnotationsProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/framework/src/main/gen/org/tron/api/NetworkGrpc.java b/framework/src/main/gen/org/tron/api/NetworkGrpc.java new file mode 100644 index 00000000000..c29b7a8105a --- /dev/null +++ b/framework/src/main/gen/org/tron/api/NetworkGrpc.java @@ -0,0 +1,221 @@ +package org.tron.api; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + *
+ * the api of tron's network such as node list.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.9.0)", + comments = "Source: api/api.proto") +public final class NetworkGrpc { + + private NetworkGrpc() {} + + public static final String SERVICE_NAME = "protocol.Network"; + + // Static method descriptors that strictly reflect the proto. + + /** + * Creates a new async stub that supports all call types for the service + */ + public static NetworkStub newStub(io.grpc.Channel channel) { + return new NetworkStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static NetworkBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new NetworkBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static NetworkFutureStub newFutureStub( + io.grpc.Channel channel) { + return new NetworkFutureStub(channel); + } + + /** + *
+   * the api of tron's network such as node list.
+   * 
+ */ + public static abstract class NetworkImplBase implements io.grpc.BindableService { + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .build(); + } + } + + /** + *
+   * the api of tron's network such as node list.
+   * 
+ */ + public static final class NetworkStub extends io.grpc.stub.AbstractStub { + private NetworkStub(io.grpc.Channel channel) { + super(channel); + } + + private NetworkStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected NetworkStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new NetworkStub(channel, callOptions); + } + } + + /** + *
+   * the api of tron's network such as node list.
+   * 
+ */ + public static final class NetworkBlockingStub extends io.grpc.stub.AbstractStub { + private NetworkBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private NetworkBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected NetworkBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new NetworkBlockingStub(channel, callOptions); + } + } + + /** + *
+   * the api of tron's network such as node list.
+   * 
+ */ + public static final class NetworkFutureStub extends io.grpc.stub.AbstractStub { + private NetworkFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private NetworkFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected NetworkFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new NetworkFutureStub(channel, callOptions); + } + } + + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final NetworkImplBase serviceImpl; + private final int methodId; + + MethodHandlers(NetworkImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class NetworkBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + NetworkBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.tron.api.GrpcAPI.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("Network"); + } + } + + private static final class NetworkFileDescriptorSupplier + extends NetworkBaseDescriptorSupplier { + NetworkFileDescriptorSupplier() {} + } + + private static final class NetworkMethodDescriptorSupplier + extends NetworkBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + NetworkMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (NetworkGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new NetworkFileDescriptorSupplier()) + .build(); + } + } + } + return result; + } +} diff --git a/framework/src/main/gen/org/tron/api/WalletExtensionGrpc.java b/framework/src/main/gen/org/tron/api/WalletExtensionGrpc.java new file mode 100644 index 00000000000..e7af67cdb50 --- /dev/null +++ b/framework/src/main/gen/org/tron/api/WalletExtensionGrpc.java @@ -0,0 +1,554 @@ +package org.tron.api; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.9.0)", + comments = "Source: api/api.proto") +public final class WalletExtensionGrpc { + + private WalletExtensionGrpc() {} + + public static final String SERVICE_NAME = "protocol.WalletExtension"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionsFromThisMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTIONS_FROM_THIS = getGetTransactionsFromThisMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionsFromThisMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionsFromThisMethod() { + io.grpc.MethodDescriptor getGetTransactionsFromThisMethod; + if ((getGetTransactionsFromThisMethod = WalletExtensionGrpc.getGetTransactionsFromThisMethod) == null) { + synchronized (WalletExtensionGrpc.class) { + if ((getGetTransactionsFromThisMethod = WalletExtensionGrpc.getGetTransactionsFromThisMethod) == null) { + WalletExtensionGrpc.getGetTransactionsFromThisMethod = getGetTransactionsFromThisMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletExtension", "GetTransactionsFromThis")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AccountPaginated.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionList.getDefaultInstance())) + .setSchemaDescriptor(new WalletExtensionMethodDescriptorSupplier("GetTransactionsFromThis")) + .build(); + } + } + } + return getGetTransactionsFromThisMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionsFromThis2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTIONS_FROM_THIS2 = getGetTransactionsFromThis2Method(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionsFromThis2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionsFromThis2Method() { + io.grpc.MethodDescriptor getGetTransactionsFromThis2Method; + if ((getGetTransactionsFromThis2Method = WalletExtensionGrpc.getGetTransactionsFromThis2Method) == null) { + synchronized (WalletExtensionGrpc.class) { + if ((getGetTransactionsFromThis2Method = WalletExtensionGrpc.getGetTransactionsFromThis2Method) == null) { + WalletExtensionGrpc.getGetTransactionsFromThis2Method = getGetTransactionsFromThis2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletExtension", "GetTransactionsFromThis2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AccountPaginated.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionListExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletExtensionMethodDescriptorSupplier("GetTransactionsFromThis2")) + .build(); + } + } + } + return getGetTransactionsFromThis2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionsToThisMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTIONS_TO_THIS = getGetTransactionsToThisMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionsToThisMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionsToThisMethod() { + io.grpc.MethodDescriptor getGetTransactionsToThisMethod; + if ((getGetTransactionsToThisMethod = WalletExtensionGrpc.getGetTransactionsToThisMethod) == null) { + synchronized (WalletExtensionGrpc.class) { + if ((getGetTransactionsToThisMethod = WalletExtensionGrpc.getGetTransactionsToThisMethod) == null) { + WalletExtensionGrpc.getGetTransactionsToThisMethod = getGetTransactionsToThisMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletExtension", "GetTransactionsToThis")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AccountPaginated.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionList.getDefaultInstance())) + .setSchemaDescriptor(new WalletExtensionMethodDescriptorSupplier("GetTransactionsToThis")) + .build(); + } + } + } + return getGetTransactionsToThisMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionsToThis2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTIONS_TO_THIS2 = getGetTransactionsToThis2Method(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionsToThis2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionsToThis2Method() { + io.grpc.MethodDescriptor getGetTransactionsToThis2Method; + if ((getGetTransactionsToThis2Method = WalletExtensionGrpc.getGetTransactionsToThis2Method) == null) { + synchronized (WalletExtensionGrpc.class) { + if ((getGetTransactionsToThis2Method = WalletExtensionGrpc.getGetTransactionsToThis2Method) == null) { + WalletExtensionGrpc.getGetTransactionsToThis2Method = getGetTransactionsToThis2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletExtension", "GetTransactionsToThis2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AccountPaginated.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionListExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletExtensionMethodDescriptorSupplier("GetTransactionsToThis2")) + .build(); + } + } + } + return getGetTransactionsToThis2Method; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static WalletExtensionStub newStub(io.grpc.Channel channel) { + return new WalletExtensionStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static WalletExtensionBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new WalletExtensionBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static WalletExtensionFutureStub newFutureStub( + io.grpc.Channel channel) { + return new WalletExtensionFutureStub(channel); + } + + /** + */ + public static abstract class WalletExtensionImplBase implements io.grpc.BindableService { + + /** + *
+     *Please use GetTransactionsFromThis2 instead of this function.
+     * 
+ */ + public void getTransactionsFromThis(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionsFromThisMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetTransactionsFromThis.
+     * 
+ */ + public void getTransactionsFromThis2(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionsFromThis2Method(), responseObserver); + } + + /** + *
+     *Please use GetTransactionsToThis2 instead of this function.
+     * 
+ */ + public void getTransactionsToThis(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionsToThisMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetTransactionsToThis.
+     * 
+ */ + public void getTransactionsToThis2(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionsToThis2Method(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getGetTransactionsFromThisMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.AccountPaginated, + org.tron.api.GrpcAPI.TransactionList>( + this, METHODID_GET_TRANSACTIONS_FROM_THIS))) + .addMethod( + getGetTransactionsFromThis2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.AccountPaginated, + org.tron.api.GrpcAPI.TransactionListExtention>( + this, METHODID_GET_TRANSACTIONS_FROM_THIS2))) + .addMethod( + getGetTransactionsToThisMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.AccountPaginated, + org.tron.api.GrpcAPI.TransactionList>( + this, METHODID_GET_TRANSACTIONS_TO_THIS))) + .addMethod( + getGetTransactionsToThis2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.AccountPaginated, + org.tron.api.GrpcAPI.TransactionListExtention>( + this, METHODID_GET_TRANSACTIONS_TO_THIS2))) + .build(); + } + } + + /** + */ + public static final class WalletExtensionStub extends io.grpc.stub.AbstractStub { + private WalletExtensionStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletExtensionStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletExtensionStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletExtensionStub(channel, callOptions); + } + + /** + *
+     *Please use GetTransactionsFromThis2 instead of this function.
+     * 
+ */ + public void getTransactionsFromThis(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionsFromThisMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetTransactionsFromThis.
+     * 
+ */ + public void getTransactionsFromThis2(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionsFromThis2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use GetTransactionsToThis2 instead of this function.
+     * 
+ */ + public void getTransactionsToThis(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionsToThisMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetTransactionsToThis.
+     * 
+ */ + public void getTransactionsToThis2(org.tron.api.GrpcAPI.AccountPaginated request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionsToThis2Method(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class WalletExtensionBlockingStub extends io.grpc.stub.AbstractStub { + private WalletExtensionBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletExtensionBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletExtensionBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletExtensionBlockingStub(channel, callOptions); + } + + /** + *
+     *Please use GetTransactionsFromThis2 instead of this function.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionList getTransactionsFromThis(org.tron.api.GrpcAPI.AccountPaginated request) { + return blockingUnaryCall( + getChannel(), getGetTransactionsFromThisMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetTransactionsFromThis.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionListExtention getTransactionsFromThis2(org.tron.api.GrpcAPI.AccountPaginated request) { + return blockingUnaryCall( + getChannel(), getGetTransactionsFromThis2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use GetTransactionsToThis2 instead of this function.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionList getTransactionsToThis(org.tron.api.GrpcAPI.AccountPaginated request) { + return blockingUnaryCall( + getChannel(), getGetTransactionsToThisMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetTransactionsToThis.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionListExtention getTransactionsToThis2(org.tron.api.GrpcAPI.AccountPaginated request) { + return blockingUnaryCall( + getChannel(), getGetTransactionsToThis2Method(), getCallOptions(), request); + } + } + + /** + */ + public static final class WalletExtensionFutureStub extends io.grpc.stub.AbstractStub { + private WalletExtensionFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletExtensionFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletExtensionFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletExtensionFutureStub(channel, callOptions); + } + + /** + *
+     *Please use GetTransactionsFromThis2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getTransactionsFromThis( + org.tron.api.GrpcAPI.AccountPaginated request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionsFromThisMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetTransactionsFromThis.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getTransactionsFromThis2( + org.tron.api.GrpcAPI.AccountPaginated request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionsFromThis2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use GetTransactionsToThis2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getTransactionsToThis( + org.tron.api.GrpcAPI.AccountPaginated request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionsToThisMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetTransactionsToThis.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getTransactionsToThis2( + org.tron.api.GrpcAPI.AccountPaginated request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionsToThis2Method(), getCallOptions()), request); + } + } + + private static final int METHODID_GET_TRANSACTIONS_FROM_THIS = 0; + private static final int METHODID_GET_TRANSACTIONS_FROM_THIS2 = 1; + private static final int METHODID_GET_TRANSACTIONS_TO_THIS = 2; + private static final int METHODID_GET_TRANSACTIONS_TO_THIS2 = 3; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final WalletExtensionImplBase serviceImpl; + private final int methodId; + + MethodHandlers(WalletExtensionImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_GET_TRANSACTIONS_FROM_THIS: + serviceImpl.getTransactionsFromThis((org.tron.api.GrpcAPI.AccountPaginated) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTIONS_FROM_THIS2: + serviceImpl.getTransactionsFromThis2((org.tron.api.GrpcAPI.AccountPaginated) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTIONS_TO_THIS: + serviceImpl.getTransactionsToThis((org.tron.api.GrpcAPI.AccountPaginated) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTIONS_TO_THIS2: + serviceImpl.getTransactionsToThis2((org.tron.api.GrpcAPI.AccountPaginated) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class WalletExtensionBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + WalletExtensionBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.tron.api.GrpcAPI.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("WalletExtension"); + } + } + + private static final class WalletExtensionFileDescriptorSupplier + extends WalletExtensionBaseDescriptorSupplier { + WalletExtensionFileDescriptorSupplier() {} + } + + private static final class WalletExtensionMethodDescriptorSupplier + extends WalletExtensionBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + WalletExtensionMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (WalletExtensionGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new WalletExtensionFileDescriptorSupplier()) + .addMethod(getGetTransactionsFromThisMethod()) + .addMethod(getGetTransactionsFromThis2Method()) + .addMethod(getGetTransactionsToThisMethod()) + .addMethod(getGetTransactionsToThis2Method()) + .build(); + } + } + } + return result; + } +} diff --git a/framework/src/main/gen/org/tron/api/WalletGrpc.java b/framework/src/main/gen/org/tron/api/WalletGrpc.java new file mode 100644 index 00000000000..956643112f9 --- /dev/null +++ b/framework/src/main/gen/org/tron/api/WalletGrpc.java @@ -0,0 +1,7891 @@ +package org.tron.api; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.9.0)", + comments = "Source: api/api.proto") +public final class WalletGrpc { + + private WalletGrpc() {} + + public static final String SERVICE_NAME = "protocol.Wallet"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAccountMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ACCOUNT = getGetAccountMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAccountMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAccountMethod() { + io.grpc.MethodDescriptor getGetAccountMethod; + if ((getGetAccountMethod = WalletGrpc.getGetAccountMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAccountMethod = WalletGrpc.getGetAccountMethod) == null) { + WalletGrpc.getGetAccountMethod = getGetAccountMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAccount")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAccount")) + .build(); + } + } + } + return getGetAccountMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAccountByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ACCOUNT_BY_ID = getGetAccountByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAccountByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAccountByIdMethod() { + io.grpc.MethodDescriptor getGetAccountByIdMethod; + if ((getGetAccountByIdMethod = WalletGrpc.getGetAccountByIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAccountByIdMethod = WalletGrpc.getGetAccountByIdMethod) == null) { + WalletGrpc.getGetAccountByIdMethod = getGetAccountByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAccountById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAccountById")) + .build(); + } + } + } + return getGetAccountByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateTransactionMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_TRANSACTION = getCreateTransactionMethod(); + + private static volatile io.grpc.MethodDescriptor getCreateTransactionMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateTransactionMethod() { + io.grpc.MethodDescriptor getCreateTransactionMethod; + if ((getCreateTransactionMethod = WalletGrpc.getCreateTransactionMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateTransactionMethod = WalletGrpc.getCreateTransactionMethod) == null) { + WalletGrpc.getCreateTransactionMethod = getCreateTransactionMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateTransaction")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.TransferContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateTransaction")) + .build(); + } + } + } + return getCreateTransactionMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateTransaction2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_TRANSACTION2 = getCreateTransaction2Method(); + + private static volatile io.grpc.MethodDescriptor getCreateTransaction2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateTransaction2Method() { + io.grpc.MethodDescriptor getCreateTransaction2Method; + if ((getCreateTransaction2Method = WalletGrpc.getCreateTransaction2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateTransaction2Method = WalletGrpc.getCreateTransaction2Method) == null) { + WalletGrpc.getCreateTransaction2Method = getCreateTransaction2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateTransaction2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.TransferContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateTransaction2")) + .build(); + } + } + } + return getCreateTransaction2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getBroadcastTransactionMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_BROADCAST_TRANSACTION = getBroadcastTransactionMethod(); + + private static volatile io.grpc.MethodDescriptor getBroadcastTransactionMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getBroadcastTransactionMethod() { + io.grpc.MethodDescriptor getBroadcastTransactionMethod; + if ((getBroadcastTransactionMethod = WalletGrpc.getBroadcastTransactionMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getBroadcastTransactionMethod = WalletGrpc.getBroadcastTransactionMethod) == null) { + WalletGrpc.getBroadcastTransactionMethod = getBroadcastTransactionMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "BroadcastTransaction")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.Return.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("BroadcastTransaction")) + .build(); + } + } + } + return getBroadcastTransactionMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateAccountMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_ACCOUNT = getUpdateAccountMethod(); + + private static volatile io.grpc.MethodDescriptor getUpdateAccountMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateAccountMethod() { + io.grpc.MethodDescriptor getUpdateAccountMethod; + if ((getUpdateAccountMethod = WalletGrpc.getUpdateAccountMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateAccountMethod = WalletGrpc.getUpdateAccountMethod) == null) { + WalletGrpc.getUpdateAccountMethod = getUpdateAccountMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateAccount")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AccountUpdateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateAccount")) + .build(); + } + } + } + return getUpdateAccountMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getSetAccountIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_SET_ACCOUNT_ID = getSetAccountIdMethod(); + + private static volatile io.grpc.MethodDescriptor getSetAccountIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getSetAccountIdMethod() { + io.grpc.MethodDescriptor getSetAccountIdMethod; + if ((getSetAccountIdMethod = WalletGrpc.getSetAccountIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getSetAccountIdMethod = WalletGrpc.getSetAccountIdMethod) == null) { + WalletGrpc.getSetAccountIdMethod = getSetAccountIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "SetAccountId")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.SetAccountIdContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("SetAccountId")) + .build(); + } + } + } + return getSetAccountIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateAccount2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_ACCOUNT2 = getUpdateAccount2Method(); + + private static volatile io.grpc.MethodDescriptor getUpdateAccount2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateAccount2Method() { + io.grpc.MethodDescriptor getUpdateAccount2Method; + if ((getUpdateAccount2Method = WalletGrpc.getUpdateAccount2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateAccount2Method = WalletGrpc.getUpdateAccount2Method) == null) { + WalletGrpc.getUpdateAccount2Method = getUpdateAccount2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateAccount2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AccountUpdateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateAccount2")) + .build(); + } + } + } + return getUpdateAccount2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getVoteWitnessAccountMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_VOTE_WITNESS_ACCOUNT = getVoteWitnessAccountMethod(); + + private static volatile io.grpc.MethodDescriptor getVoteWitnessAccountMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getVoteWitnessAccountMethod() { + io.grpc.MethodDescriptor getVoteWitnessAccountMethod; + if ((getVoteWitnessAccountMethod = WalletGrpc.getVoteWitnessAccountMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getVoteWitnessAccountMethod = WalletGrpc.getVoteWitnessAccountMethod) == null) { + WalletGrpc.getVoteWitnessAccountMethod = getVoteWitnessAccountMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "VoteWitnessAccount")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.VoteWitnessContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("VoteWitnessAccount")) + .build(); + } + } + } + return getVoteWitnessAccountMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateSettingMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_SETTING = getUpdateSettingMethod(); + + private static volatile io.grpc.MethodDescriptor getUpdateSettingMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateSettingMethod() { + io.grpc.MethodDescriptor getUpdateSettingMethod; + if ((getUpdateSettingMethod = WalletGrpc.getUpdateSettingMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateSettingMethod = WalletGrpc.getUpdateSettingMethod) == null) { + WalletGrpc.getUpdateSettingMethod = getUpdateSettingMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateSetting")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UpdateSettingContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateSetting")) + .build(); + } + } + } + return getUpdateSettingMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateEnergyLimitMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_ENERGY_LIMIT = getUpdateEnergyLimitMethod(); + + private static volatile io.grpc.MethodDescriptor getUpdateEnergyLimitMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateEnergyLimitMethod() { + io.grpc.MethodDescriptor getUpdateEnergyLimitMethod; + if ((getUpdateEnergyLimitMethod = WalletGrpc.getUpdateEnergyLimitMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateEnergyLimitMethod = WalletGrpc.getUpdateEnergyLimitMethod) == null) { + WalletGrpc.getUpdateEnergyLimitMethod = getUpdateEnergyLimitMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateEnergyLimit")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UpdateEnergyLimitContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateEnergyLimit")) + .build(); + } + } + } + return getUpdateEnergyLimitMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getVoteWitnessAccount2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_VOTE_WITNESS_ACCOUNT2 = getVoteWitnessAccount2Method(); + + private static volatile io.grpc.MethodDescriptor getVoteWitnessAccount2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getVoteWitnessAccount2Method() { + io.grpc.MethodDescriptor getVoteWitnessAccount2Method; + if ((getVoteWitnessAccount2Method = WalletGrpc.getVoteWitnessAccount2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getVoteWitnessAccount2Method = WalletGrpc.getVoteWitnessAccount2Method) == null) { + WalletGrpc.getVoteWitnessAccount2Method = getVoteWitnessAccount2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "VoteWitnessAccount2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.VoteWitnessContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("VoteWitnessAccount2")) + .build(); + } + } + } + return getVoteWitnessAccount2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateAssetIssueMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_ASSET_ISSUE = getCreateAssetIssueMethod(); + + private static volatile io.grpc.MethodDescriptor getCreateAssetIssueMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateAssetIssueMethod() { + io.grpc.MethodDescriptor getCreateAssetIssueMethod; + if ((getCreateAssetIssueMethod = WalletGrpc.getCreateAssetIssueMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateAssetIssueMethod = WalletGrpc.getCreateAssetIssueMethod) == null) { + WalletGrpc.getCreateAssetIssueMethod = getCreateAssetIssueMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateAssetIssue")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AssetIssueContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateAssetIssue")) + .build(); + } + } + } + return getCreateAssetIssueMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateAssetIssue2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_ASSET_ISSUE2 = getCreateAssetIssue2Method(); + + private static volatile io.grpc.MethodDescriptor getCreateAssetIssue2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateAssetIssue2Method() { + io.grpc.MethodDescriptor getCreateAssetIssue2Method; + if ((getCreateAssetIssue2Method = WalletGrpc.getCreateAssetIssue2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateAssetIssue2Method = WalletGrpc.getCreateAssetIssue2Method) == null) { + WalletGrpc.getCreateAssetIssue2Method = getCreateAssetIssue2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateAssetIssue2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AssetIssueContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateAssetIssue2")) + .build(); + } + } + } + return getCreateAssetIssue2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateWitnessMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_WITNESS = getUpdateWitnessMethod(); + + private static volatile io.grpc.MethodDescriptor getUpdateWitnessMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateWitnessMethod() { + io.grpc.MethodDescriptor getUpdateWitnessMethod; + if ((getUpdateWitnessMethod = WalletGrpc.getUpdateWitnessMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateWitnessMethod = WalletGrpc.getUpdateWitnessMethod) == null) { + WalletGrpc.getUpdateWitnessMethod = getUpdateWitnessMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateWitness")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.WitnessUpdateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateWitness")) + .build(); + } + } + } + return getUpdateWitnessMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateWitness2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_WITNESS2 = getUpdateWitness2Method(); + + private static volatile io.grpc.MethodDescriptor getUpdateWitness2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateWitness2Method() { + io.grpc.MethodDescriptor getUpdateWitness2Method; + if ((getUpdateWitness2Method = WalletGrpc.getUpdateWitness2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateWitness2Method = WalletGrpc.getUpdateWitness2Method) == null) { + WalletGrpc.getUpdateWitness2Method = getUpdateWitness2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateWitness2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.WitnessUpdateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateWitness2")) + .build(); + } + } + } + return getUpdateWitness2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateAccountMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_ACCOUNT = getCreateAccountMethod(); + + private static volatile io.grpc.MethodDescriptor getCreateAccountMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateAccountMethod() { + io.grpc.MethodDescriptor getCreateAccountMethod; + if ((getCreateAccountMethod = WalletGrpc.getCreateAccountMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateAccountMethod = WalletGrpc.getCreateAccountMethod) == null) { + WalletGrpc.getCreateAccountMethod = getCreateAccountMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateAccount")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AccountCreateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateAccount")) + .build(); + } + } + } + return getCreateAccountMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateAccount2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_ACCOUNT2 = getCreateAccount2Method(); + + private static volatile io.grpc.MethodDescriptor getCreateAccount2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateAccount2Method() { + io.grpc.MethodDescriptor getCreateAccount2Method; + if ((getCreateAccount2Method = WalletGrpc.getCreateAccount2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateAccount2Method = WalletGrpc.getCreateAccount2Method) == null) { + WalletGrpc.getCreateAccount2Method = getCreateAccount2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateAccount2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AccountCreateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateAccount2")) + .build(); + } + } + } + return getCreateAccount2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateWitnessMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_WITNESS = getCreateWitnessMethod(); + + private static volatile io.grpc.MethodDescriptor getCreateWitnessMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateWitnessMethod() { + io.grpc.MethodDescriptor getCreateWitnessMethod; + if ((getCreateWitnessMethod = WalletGrpc.getCreateWitnessMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateWitnessMethod = WalletGrpc.getCreateWitnessMethod) == null) { + WalletGrpc.getCreateWitnessMethod = getCreateWitnessMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateWitness")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.WitnessCreateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateWitness")) + .build(); + } + } + } + return getCreateWitnessMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateWitness2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_WITNESS2 = getCreateWitness2Method(); + + private static volatile io.grpc.MethodDescriptor getCreateWitness2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateWitness2Method() { + io.grpc.MethodDescriptor getCreateWitness2Method; + if ((getCreateWitness2Method = WalletGrpc.getCreateWitness2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateWitness2Method = WalletGrpc.getCreateWitness2Method) == null) { + WalletGrpc.getCreateWitness2Method = getCreateWitness2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateWitness2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.WitnessCreateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateWitness2")) + .build(); + } + } + } + return getCreateWitness2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getTransferAssetMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_TRANSFER_ASSET = getTransferAssetMethod(); + + private static volatile io.grpc.MethodDescriptor getTransferAssetMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getTransferAssetMethod() { + io.grpc.MethodDescriptor getTransferAssetMethod; + if ((getTransferAssetMethod = WalletGrpc.getTransferAssetMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getTransferAssetMethod = WalletGrpc.getTransferAssetMethod) == null) { + WalletGrpc.getTransferAssetMethod = getTransferAssetMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "TransferAsset")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.TransferAssetContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("TransferAsset")) + .build(); + } + } + } + return getTransferAssetMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getTransferAsset2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_TRANSFER_ASSET2 = getTransferAsset2Method(); + + private static volatile io.grpc.MethodDescriptor getTransferAsset2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getTransferAsset2Method() { + io.grpc.MethodDescriptor getTransferAsset2Method; + if ((getTransferAsset2Method = WalletGrpc.getTransferAsset2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getTransferAsset2Method = WalletGrpc.getTransferAsset2Method) == null) { + WalletGrpc.getTransferAsset2Method = getTransferAsset2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "TransferAsset2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.TransferAssetContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("TransferAsset2")) + .build(); + } + } + } + return getTransferAsset2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getParticipateAssetIssueMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_PARTICIPATE_ASSET_ISSUE = getParticipateAssetIssueMethod(); + + private static volatile io.grpc.MethodDescriptor getParticipateAssetIssueMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getParticipateAssetIssueMethod() { + io.grpc.MethodDescriptor getParticipateAssetIssueMethod; + if ((getParticipateAssetIssueMethod = WalletGrpc.getParticipateAssetIssueMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getParticipateAssetIssueMethod = WalletGrpc.getParticipateAssetIssueMethod) == null) { + WalletGrpc.getParticipateAssetIssueMethod = getParticipateAssetIssueMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ParticipateAssetIssue")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ParticipateAssetIssueContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ParticipateAssetIssue")) + .build(); + } + } + } + return getParticipateAssetIssueMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getParticipateAssetIssue2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_PARTICIPATE_ASSET_ISSUE2 = getParticipateAssetIssue2Method(); + + private static volatile io.grpc.MethodDescriptor getParticipateAssetIssue2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getParticipateAssetIssue2Method() { + io.grpc.MethodDescriptor getParticipateAssetIssue2Method; + if ((getParticipateAssetIssue2Method = WalletGrpc.getParticipateAssetIssue2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getParticipateAssetIssue2Method = WalletGrpc.getParticipateAssetIssue2Method) == null) { + WalletGrpc.getParticipateAssetIssue2Method = getParticipateAssetIssue2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ParticipateAssetIssue2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ParticipateAssetIssueContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ParticipateAssetIssue2")) + .build(); + } + } + } + return getParticipateAssetIssue2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getFreezeBalanceMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_FREEZE_BALANCE = getFreezeBalanceMethod(); + + private static volatile io.grpc.MethodDescriptor getFreezeBalanceMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getFreezeBalanceMethod() { + io.grpc.MethodDescriptor getFreezeBalanceMethod; + if ((getFreezeBalanceMethod = WalletGrpc.getFreezeBalanceMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getFreezeBalanceMethod = WalletGrpc.getFreezeBalanceMethod) == null) { + WalletGrpc.getFreezeBalanceMethod = getFreezeBalanceMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "FreezeBalance")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.FreezeBalanceContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("FreezeBalance")) + .build(); + } + } + } + return getFreezeBalanceMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getFreezeBalance2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_FREEZE_BALANCE2 = getFreezeBalance2Method(); + + private static volatile io.grpc.MethodDescriptor getFreezeBalance2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getFreezeBalance2Method() { + io.grpc.MethodDescriptor getFreezeBalance2Method; + if ((getFreezeBalance2Method = WalletGrpc.getFreezeBalance2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getFreezeBalance2Method = WalletGrpc.getFreezeBalance2Method) == null) { + WalletGrpc.getFreezeBalance2Method = getFreezeBalance2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "FreezeBalance2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.FreezeBalanceContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("FreezeBalance2")) + .build(); + } + } + } + return getFreezeBalance2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUnfreezeBalanceMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_UNFREEZE_BALANCE = getUnfreezeBalanceMethod(); + + private static volatile io.grpc.MethodDescriptor getUnfreezeBalanceMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUnfreezeBalanceMethod() { + io.grpc.MethodDescriptor getUnfreezeBalanceMethod; + if ((getUnfreezeBalanceMethod = WalletGrpc.getUnfreezeBalanceMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getUnfreezeBalanceMethod = WalletGrpc.getUnfreezeBalanceMethod) == null) { + WalletGrpc.getUnfreezeBalanceMethod = getUnfreezeBalanceMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UnfreezeBalance")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UnfreezeBalanceContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UnfreezeBalance")) + .build(); + } + } + } + return getUnfreezeBalanceMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUnfreezeBalance2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_UNFREEZE_BALANCE2 = getUnfreezeBalance2Method(); + + private static volatile io.grpc.MethodDescriptor getUnfreezeBalance2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUnfreezeBalance2Method() { + io.grpc.MethodDescriptor getUnfreezeBalance2Method; + if ((getUnfreezeBalance2Method = WalletGrpc.getUnfreezeBalance2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getUnfreezeBalance2Method = WalletGrpc.getUnfreezeBalance2Method) == null) { + WalletGrpc.getUnfreezeBalance2Method = getUnfreezeBalance2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UnfreezeBalance2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UnfreezeBalanceContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UnfreezeBalance2")) + .build(); + } + } + } + return getUnfreezeBalance2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUnfreezeAssetMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_UNFREEZE_ASSET = getUnfreezeAssetMethod(); + + private static volatile io.grpc.MethodDescriptor getUnfreezeAssetMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUnfreezeAssetMethod() { + io.grpc.MethodDescriptor getUnfreezeAssetMethod; + if ((getUnfreezeAssetMethod = WalletGrpc.getUnfreezeAssetMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getUnfreezeAssetMethod = WalletGrpc.getUnfreezeAssetMethod) == null) { + WalletGrpc.getUnfreezeAssetMethod = getUnfreezeAssetMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UnfreezeAsset")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UnfreezeAssetContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UnfreezeAsset")) + .build(); + } + } + } + return getUnfreezeAssetMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUnfreezeAsset2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_UNFREEZE_ASSET2 = getUnfreezeAsset2Method(); + + private static volatile io.grpc.MethodDescriptor getUnfreezeAsset2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUnfreezeAsset2Method() { + io.grpc.MethodDescriptor getUnfreezeAsset2Method; + if ((getUnfreezeAsset2Method = WalletGrpc.getUnfreezeAsset2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getUnfreezeAsset2Method = WalletGrpc.getUnfreezeAsset2Method) == null) { + WalletGrpc.getUnfreezeAsset2Method = getUnfreezeAsset2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UnfreezeAsset2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UnfreezeAssetContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UnfreezeAsset2")) + .build(); + } + } + } + return getUnfreezeAsset2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getWithdrawBalanceMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_WITHDRAW_BALANCE = getWithdrawBalanceMethod(); + + private static volatile io.grpc.MethodDescriptor getWithdrawBalanceMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getWithdrawBalanceMethod() { + io.grpc.MethodDescriptor getWithdrawBalanceMethod; + if ((getWithdrawBalanceMethod = WalletGrpc.getWithdrawBalanceMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getWithdrawBalanceMethod = WalletGrpc.getWithdrawBalanceMethod) == null) { + WalletGrpc.getWithdrawBalanceMethod = getWithdrawBalanceMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "WithdrawBalance")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.WithdrawBalanceContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("WithdrawBalance")) + .build(); + } + } + } + return getWithdrawBalanceMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getWithdrawBalance2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_WITHDRAW_BALANCE2 = getWithdrawBalance2Method(); + + private static volatile io.grpc.MethodDescriptor getWithdrawBalance2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getWithdrawBalance2Method() { + io.grpc.MethodDescriptor getWithdrawBalance2Method; + if ((getWithdrawBalance2Method = WalletGrpc.getWithdrawBalance2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getWithdrawBalance2Method = WalletGrpc.getWithdrawBalance2Method) == null) { + WalletGrpc.getWithdrawBalance2Method = getWithdrawBalance2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "WithdrawBalance2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.WithdrawBalanceContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("WithdrawBalance2")) + .build(); + } + } + } + return getWithdrawBalance2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateAssetMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_ASSET = getUpdateAssetMethod(); + + private static volatile io.grpc.MethodDescriptor getUpdateAssetMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateAssetMethod() { + io.grpc.MethodDescriptor getUpdateAssetMethod; + if ((getUpdateAssetMethod = WalletGrpc.getUpdateAssetMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateAssetMethod = WalletGrpc.getUpdateAssetMethod) == null) { + WalletGrpc.getUpdateAssetMethod = getUpdateAssetMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateAsset")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UpdateAssetContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateAsset")) + .build(); + } + } + } + return getUpdateAssetMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getUpdateAsset2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_UPDATE_ASSET2 = getUpdateAsset2Method(); + + private static volatile io.grpc.MethodDescriptor getUpdateAsset2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getUpdateAsset2Method() { + io.grpc.MethodDescriptor getUpdateAsset2Method; + if ((getUpdateAsset2Method = WalletGrpc.getUpdateAsset2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getUpdateAsset2Method = WalletGrpc.getUpdateAsset2Method) == null) { + WalletGrpc.getUpdateAsset2Method = getUpdateAsset2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "UpdateAsset2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.UpdateAssetContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("UpdateAsset2")) + .build(); + } + } + } + return getUpdateAsset2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getProposalCreateMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_PROPOSAL_CREATE = getProposalCreateMethod(); + + private static volatile io.grpc.MethodDescriptor getProposalCreateMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getProposalCreateMethod() { + io.grpc.MethodDescriptor getProposalCreateMethod; + if ((getProposalCreateMethod = WalletGrpc.getProposalCreateMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getProposalCreateMethod = WalletGrpc.getProposalCreateMethod) == null) { + WalletGrpc.getProposalCreateMethod = getProposalCreateMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ProposalCreate")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ProposalCreateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ProposalCreate")) + .build(); + } + } + } + return getProposalCreateMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getProposalApproveMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_PROPOSAL_APPROVE = getProposalApproveMethod(); + + private static volatile io.grpc.MethodDescriptor getProposalApproveMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getProposalApproveMethod() { + io.grpc.MethodDescriptor getProposalApproveMethod; + if ((getProposalApproveMethod = WalletGrpc.getProposalApproveMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getProposalApproveMethod = WalletGrpc.getProposalApproveMethod) == null) { + WalletGrpc.getProposalApproveMethod = getProposalApproveMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ProposalApprove")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ProposalApproveContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ProposalApprove")) + .build(); + } + } + } + return getProposalApproveMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getProposalDeleteMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_PROPOSAL_DELETE = getProposalDeleteMethod(); + + private static volatile io.grpc.MethodDescriptor getProposalDeleteMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getProposalDeleteMethod() { + io.grpc.MethodDescriptor getProposalDeleteMethod; + if ((getProposalDeleteMethod = WalletGrpc.getProposalDeleteMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getProposalDeleteMethod = WalletGrpc.getProposalDeleteMethod) == null) { + WalletGrpc.getProposalDeleteMethod = getProposalDeleteMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ProposalDelete")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ProposalDeleteContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ProposalDelete")) + .build(); + } + } + } + return getProposalDeleteMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getBuyStorageMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_BUY_STORAGE = getBuyStorageMethod(); + + private static volatile io.grpc.MethodDescriptor getBuyStorageMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getBuyStorageMethod() { + io.grpc.MethodDescriptor getBuyStorageMethod; + if ((getBuyStorageMethod = WalletGrpc.getBuyStorageMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getBuyStorageMethod = WalletGrpc.getBuyStorageMethod) == null) { + WalletGrpc.getBuyStorageMethod = getBuyStorageMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "BuyStorage")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.BuyStorageContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("BuyStorage")) + .build(); + } + } + } + return getBuyStorageMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getBuyStorageBytesMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_BUY_STORAGE_BYTES = getBuyStorageBytesMethod(); + + private static volatile io.grpc.MethodDescriptor getBuyStorageBytesMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getBuyStorageBytesMethod() { + io.grpc.MethodDescriptor getBuyStorageBytesMethod; + if ((getBuyStorageBytesMethod = WalletGrpc.getBuyStorageBytesMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getBuyStorageBytesMethod = WalletGrpc.getBuyStorageBytesMethod) == null) { + WalletGrpc.getBuyStorageBytesMethod = getBuyStorageBytesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "BuyStorageBytes")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.BuyStorageBytesContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("BuyStorageBytes")) + .build(); + } + } + } + return getBuyStorageBytesMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getSellStorageMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_SELL_STORAGE = getSellStorageMethod(); + + private static volatile io.grpc.MethodDescriptor getSellStorageMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getSellStorageMethod() { + io.grpc.MethodDescriptor getSellStorageMethod; + if ((getSellStorageMethod = WalletGrpc.getSellStorageMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getSellStorageMethod = WalletGrpc.getSellStorageMethod) == null) { + WalletGrpc.getSellStorageMethod = getSellStorageMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "SellStorage")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.SellStorageContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("SellStorage")) + .build(); + } + } + } + return getSellStorageMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getExchangeCreateMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EXCHANGE_CREATE = getExchangeCreateMethod(); + + private static volatile io.grpc.MethodDescriptor getExchangeCreateMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getExchangeCreateMethod() { + io.grpc.MethodDescriptor getExchangeCreateMethod; + if ((getExchangeCreateMethod = WalletGrpc.getExchangeCreateMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getExchangeCreateMethod = WalletGrpc.getExchangeCreateMethod) == null) { + WalletGrpc.getExchangeCreateMethod = getExchangeCreateMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ExchangeCreate")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ExchangeCreateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ExchangeCreate")) + .build(); + } + } + } + return getExchangeCreateMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getExchangeInjectMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EXCHANGE_INJECT = getExchangeInjectMethod(); + + private static volatile io.grpc.MethodDescriptor getExchangeInjectMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getExchangeInjectMethod() { + io.grpc.MethodDescriptor getExchangeInjectMethod; + if ((getExchangeInjectMethod = WalletGrpc.getExchangeInjectMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getExchangeInjectMethod = WalletGrpc.getExchangeInjectMethod) == null) { + WalletGrpc.getExchangeInjectMethod = getExchangeInjectMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ExchangeInject")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ExchangeInjectContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ExchangeInject")) + .build(); + } + } + } + return getExchangeInjectMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getExchangeWithdrawMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EXCHANGE_WITHDRAW = getExchangeWithdrawMethod(); + + private static volatile io.grpc.MethodDescriptor getExchangeWithdrawMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getExchangeWithdrawMethod() { + io.grpc.MethodDescriptor getExchangeWithdrawMethod; + if ((getExchangeWithdrawMethod = WalletGrpc.getExchangeWithdrawMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getExchangeWithdrawMethod = WalletGrpc.getExchangeWithdrawMethod) == null) { + WalletGrpc.getExchangeWithdrawMethod = getExchangeWithdrawMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ExchangeWithdraw")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ExchangeWithdrawContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ExchangeWithdraw")) + .build(); + } + } + } + return getExchangeWithdrawMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getExchangeTransactionMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EXCHANGE_TRANSACTION = getExchangeTransactionMethod(); + + private static volatile io.grpc.MethodDescriptor getExchangeTransactionMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getExchangeTransactionMethod() { + io.grpc.MethodDescriptor getExchangeTransactionMethod; + if ((getExchangeTransactionMethod = WalletGrpc.getExchangeTransactionMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getExchangeTransactionMethod = WalletGrpc.getExchangeTransactionMethod) == null) { + WalletGrpc.getExchangeTransactionMethod = getExchangeTransactionMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ExchangeTransaction")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ExchangeTransactionContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ExchangeTransaction")) + .build(); + } + } + } + return getExchangeTransactionMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getListNodesMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_LIST_NODES = getListNodesMethod(); + + private static volatile io.grpc.MethodDescriptor getListNodesMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getListNodesMethod() { + io.grpc.MethodDescriptor getListNodesMethod; + if ((getListNodesMethod = WalletGrpc.getListNodesMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getListNodesMethod = WalletGrpc.getListNodesMethod) == null) { + WalletGrpc.getListNodesMethod = getListNodesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ListNodes")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NodeList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ListNodes")) + .build(); + } + } + } + return getListNodesMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueByAccountMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_BY_ACCOUNT = getGetAssetIssueByAccountMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueByAccountMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueByAccountMethod() { + io.grpc.MethodDescriptor getGetAssetIssueByAccountMethod; + if ((getGetAssetIssueByAccountMethod = WalletGrpc.getGetAssetIssueByAccountMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAssetIssueByAccountMethod = WalletGrpc.getGetAssetIssueByAccountMethod) == null) { + WalletGrpc.getGetAssetIssueByAccountMethod = getGetAssetIssueByAccountMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAssetIssueByAccount")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAssetIssueByAccount")) + .build(); + } + } + } + return getGetAssetIssueByAccountMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAccountNetMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ACCOUNT_NET = getGetAccountNetMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAccountNetMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAccountNetMethod() { + io.grpc.MethodDescriptor getGetAccountNetMethod; + if ((getGetAccountNetMethod = WalletGrpc.getGetAccountNetMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAccountNetMethod = WalletGrpc.getGetAccountNetMethod) == null) { + WalletGrpc.getGetAccountNetMethod = getGetAccountNetMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAccountNet")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AccountNetMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAccountNet")) + .build(); + } + } + } + return getGetAccountNetMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAccountResourceMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ACCOUNT_RESOURCE = getGetAccountResourceMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAccountResourceMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAccountResourceMethod() { + io.grpc.MethodDescriptor getGetAccountResourceMethod; + if ((getGetAccountResourceMethod = WalletGrpc.getGetAccountResourceMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAccountResourceMethod = WalletGrpc.getGetAccountResourceMethod) == null) { + WalletGrpc.getGetAccountResourceMethod = getGetAccountResourceMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAccountResource")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AccountResourceMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAccountResource")) + .build(); + } + } + } + return getGetAccountResourceMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueByNameMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_BY_NAME = getGetAssetIssueByNameMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueByNameMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueByNameMethod() { + io.grpc.MethodDescriptor getGetAssetIssueByNameMethod; + if ((getGetAssetIssueByNameMethod = WalletGrpc.getGetAssetIssueByNameMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAssetIssueByNameMethod = WalletGrpc.getGetAssetIssueByNameMethod) == null) { + WalletGrpc.getGetAssetIssueByNameMethod = getGetAssetIssueByNameMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAssetIssueByName")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AssetIssueContract.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAssetIssueByName")) + .build(); + } + } + } + return getGetAssetIssueByNameMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueListByNameMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_LIST_BY_NAME = getGetAssetIssueListByNameMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueListByNameMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueListByNameMethod() { + io.grpc.MethodDescriptor getGetAssetIssueListByNameMethod; + if ((getGetAssetIssueListByNameMethod = WalletGrpc.getGetAssetIssueListByNameMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAssetIssueListByNameMethod = WalletGrpc.getGetAssetIssueListByNameMethod) == null) { + WalletGrpc.getGetAssetIssueListByNameMethod = getGetAssetIssueListByNameMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAssetIssueListByName")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAssetIssueListByName")) + .build(); + } + } + } + return getGetAssetIssueListByNameMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_BY_ID = getGetAssetIssueByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueByIdMethod() { + io.grpc.MethodDescriptor getGetAssetIssueByIdMethod; + if ((getGetAssetIssueByIdMethod = WalletGrpc.getGetAssetIssueByIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAssetIssueByIdMethod = WalletGrpc.getGetAssetIssueByIdMethod) == null) { + WalletGrpc.getGetAssetIssueByIdMethod = getGetAssetIssueByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAssetIssueById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AssetIssueContract.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAssetIssueById")) + .build(); + } + } + } + return getGetAssetIssueByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetNowBlockMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_NOW_BLOCK = getGetNowBlockMethod(); + + private static volatile io.grpc.MethodDescriptor getGetNowBlockMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetNowBlockMethod() { + io.grpc.MethodDescriptor getGetNowBlockMethod; + if ((getGetNowBlockMethod = WalletGrpc.getGetNowBlockMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetNowBlockMethod = WalletGrpc.getGetNowBlockMethod) == null) { + WalletGrpc.getGetNowBlockMethod = getGetNowBlockMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetNowBlock")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Block.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetNowBlock")) + .build(); + } + } + } + return getGetNowBlockMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetNowBlock2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_NOW_BLOCK2 = getGetNowBlock2Method(); + + private static volatile io.grpc.MethodDescriptor getGetNowBlock2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetNowBlock2Method() { + io.grpc.MethodDescriptor getGetNowBlock2Method; + if ((getGetNowBlock2Method = WalletGrpc.getGetNowBlock2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getGetNowBlock2Method = WalletGrpc.getGetNowBlock2Method) == null) { + WalletGrpc.getGetNowBlock2Method = getGetNowBlock2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetNowBlock2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetNowBlock2")) + .build(); + } + } + } + return getGetNowBlock2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByNumMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_NUM = getGetBlockByNumMethod(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByNumMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByNumMethod() { + io.grpc.MethodDescriptor getGetBlockByNumMethod; + if ((getGetBlockByNumMethod = WalletGrpc.getGetBlockByNumMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetBlockByNumMethod = WalletGrpc.getGetBlockByNumMethod) == null) { + WalletGrpc.getGetBlockByNumMethod = getGetBlockByNumMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetBlockByNum")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Block.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetBlockByNum")) + .build(); + } + } + } + return getGetBlockByNumMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByNum2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_NUM2 = getGetBlockByNum2Method(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByNum2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByNum2Method() { + io.grpc.MethodDescriptor getGetBlockByNum2Method; + if ((getGetBlockByNum2Method = WalletGrpc.getGetBlockByNum2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getGetBlockByNum2Method = WalletGrpc.getGetBlockByNum2Method) == null) { + WalletGrpc.getGetBlockByNum2Method = getGetBlockByNum2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetBlockByNum2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetBlockByNum2")) + .build(); + } + } + } + return getGetBlockByNum2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionCountByBlockNumMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_COUNT_BY_BLOCK_NUM = getGetTransactionCountByBlockNumMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionCountByBlockNumMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionCountByBlockNumMethod() { + io.grpc.MethodDescriptor getGetTransactionCountByBlockNumMethod; + if ((getGetTransactionCountByBlockNumMethod = WalletGrpc.getGetTransactionCountByBlockNumMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetTransactionCountByBlockNumMethod = WalletGrpc.getGetTransactionCountByBlockNumMethod) == null) { + WalletGrpc.getGetTransactionCountByBlockNumMethod = getGetTransactionCountByBlockNumMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetTransactionCountByBlockNum")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetTransactionCountByBlockNum")) + .build(); + } + } + } + return getGetTransactionCountByBlockNumMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_ID = getGetBlockByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByIdMethod() { + io.grpc.MethodDescriptor getGetBlockByIdMethod; + if ((getGetBlockByIdMethod = WalletGrpc.getGetBlockByIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetBlockByIdMethod = WalletGrpc.getGetBlockByIdMethod) == null) { + WalletGrpc.getGetBlockByIdMethod = getGetBlockByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetBlockById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Block.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetBlockById")) + .build(); + } + } + } + return getGetBlockByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByLimitNextMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_LIMIT_NEXT = getGetBlockByLimitNextMethod(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByLimitNextMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByLimitNextMethod() { + io.grpc.MethodDescriptor getGetBlockByLimitNextMethod; + if ((getGetBlockByLimitNextMethod = WalletGrpc.getGetBlockByLimitNextMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetBlockByLimitNextMethod = WalletGrpc.getGetBlockByLimitNextMethod) == null) { + WalletGrpc.getGetBlockByLimitNextMethod = getGetBlockByLimitNextMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetBlockByLimitNext")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockLimit.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetBlockByLimitNext")) + .build(); + } + } + } + return getGetBlockByLimitNextMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByLimitNext2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_LIMIT_NEXT2 = getGetBlockByLimitNext2Method(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByLimitNext2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByLimitNext2Method() { + io.grpc.MethodDescriptor getGetBlockByLimitNext2Method; + if ((getGetBlockByLimitNext2Method = WalletGrpc.getGetBlockByLimitNext2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getGetBlockByLimitNext2Method = WalletGrpc.getGetBlockByLimitNext2Method) == null) { + WalletGrpc.getGetBlockByLimitNext2Method = getGetBlockByLimitNext2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetBlockByLimitNext2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockLimit.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockListExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetBlockByLimitNext2")) + .build(); + } + } + } + return getGetBlockByLimitNext2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByLatestNumMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_LATEST_NUM = getGetBlockByLatestNumMethod(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByLatestNumMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByLatestNumMethod() { + io.grpc.MethodDescriptor getGetBlockByLatestNumMethod; + if ((getGetBlockByLatestNumMethod = WalletGrpc.getGetBlockByLatestNumMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetBlockByLatestNumMethod = WalletGrpc.getGetBlockByLatestNumMethod) == null) { + WalletGrpc.getGetBlockByLatestNumMethod = getGetBlockByLatestNumMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetBlockByLatestNum")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetBlockByLatestNum")) + .build(); + } + } + } + return getGetBlockByLatestNumMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByLatestNum2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_LATEST_NUM2 = getGetBlockByLatestNum2Method(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByLatestNum2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByLatestNum2Method() { + io.grpc.MethodDescriptor getGetBlockByLatestNum2Method; + if ((getGetBlockByLatestNum2Method = WalletGrpc.getGetBlockByLatestNum2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getGetBlockByLatestNum2Method = WalletGrpc.getGetBlockByLatestNum2Method) == null) { + WalletGrpc.getGetBlockByLatestNum2Method = getGetBlockByLatestNum2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetBlockByLatestNum2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockListExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetBlockByLatestNum2")) + .build(); + } + } + } + return getGetBlockByLatestNum2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_BY_ID = getGetTransactionByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionByIdMethod() { + io.grpc.MethodDescriptor getGetTransactionByIdMethod; + if ((getGetTransactionByIdMethod = WalletGrpc.getGetTransactionByIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetTransactionByIdMethod = WalletGrpc.getGetTransactionByIdMethod) == null) { + WalletGrpc.getGetTransactionByIdMethod = getGetTransactionByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetTransactionById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetTransactionById")) + .build(); + } + } + } + return getGetTransactionByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getDeployContractMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_DEPLOY_CONTRACT = getDeployContractMethod(); + + private static volatile io.grpc.MethodDescriptor getDeployContractMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getDeployContractMethod() { + io.grpc.MethodDescriptor getDeployContractMethod; + if ((getDeployContractMethod = WalletGrpc.getDeployContractMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getDeployContractMethod = WalletGrpc.getDeployContractMethod) == null) { + WalletGrpc.getDeployContractMethod = getDeployContractMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "DeployContract")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.CreateSmartContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("DeployContract")) + .build(); + } + } + } + return getDeployContractMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetContractMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_CONTRACT = getGetContractMethod(); + + private static volatile io.grpc.MethodDescriptor getGetContractMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetContractMethod() { + io.grpc.MethodDescriptor getGetContractMethod; + if ((getGetContractMethod = WalletGrpc.getGetContractMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetContractMethod = WalletGrpc.getGetContractMethod) == null) { + WalletGrpc.getGetContractMethod = getGetContractMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetContract")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.SmartContract.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetContract")) + .build(); + } + } + } + return getGetContractMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getTriggerContractMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_TRIGGER_CONTRACT = getTriggerContractMethod(); + + private static volatile io.grpc.MethodDescriptor getTriggerContractMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getTriggerContractMethod() { + io.grpc.MethodDescriptor getTriggerContractMethod; + if ((getTriggerContractMethod = WalletGrpc.getTriggerContractMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getTriggerContractMethod = WalletGrpc.getTriggerContractMethod) == null) { + WalletGrpc.getTriggerContractMethod = getTriggerContractMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "TriggerContract")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.TriggerSmartContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("TriggerContract")) + .build(); + } + } + } + return getTriggerContractMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getTriggerConstantContractMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_TRIGGER_CONSTANT_CONTRACT = getTriggerConstantContractMethod(); + + private static volatile io.grpc.MethodDescriptor getTriggerConstantContractMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getTriggerConstantContractMethod() { + io.grpc.MethodDescriptor getTriggerConstantContractMethod; + if ((getTriggerConstantContractMethod = WalletGrpc.getTriggerConstantContractMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getTriggerConstantContractMethod = WalletGrpc.getTriggerConstantContractMethod) == null) { + WalletGrpc.getTriggerConstantContractMethod = getTriggerConstantContractMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "TriggerConstantContract")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.TriggerSmartContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("TriggerConstantContract")) + .build(); + } + } + } + return getTriggerConstantContractMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getClearContractABIMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_CLEAR_CONTRACT_ABI = getClearContractABIMethod(); + + private static volatile io.grpc.MethodDescriptor getClearContractABIMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getClearContractABIMethod() { + io.grpc.MethodDescriptor getClearContractABIMethod; + if ((getClearContractABIMethod = WalletGrpc.getClearContractABIMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getClearContractABIMethod = WalletGrpc.getClearContractABIMethod) == null) { + WalletGrpc.getClearContractABIMethod = getClearContractABIMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ClearContractABI")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.ClearABIContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ClearContractABI")) + .build(); + } + } + } + return getClearContractABIMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getListWitnessesMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_LIST_WITNESSES = getListWitnessesMethod(); + + private static volatile io.grpc.MethodDescriptor getListWitnessesMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getListWitnessesMethod() { + io.grpc.MethodDescriptor getListWitnessesMethod; + if ((getListWitnessesMethod = WalletGrpc.getListWitnessesMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getListWitnessesMethod = WalletGrpc.getListWitnessesMethod) == null) { + WalletGrpc.getListWitnessesMethod = getListWitnessesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ListWitnesses")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.WitnessList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ListWitnesses")) + .build(); + } + } + } + return getListWitnessesMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetDelegatedResourceMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_DELEGATED_RESOURCE = getGetDelegatedResourceMethod(); + + private static volatile io.grpc.MethodDescriptor getGetDelegatedResourceMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetDelegatedResourceMethod() { + io.grpc.MethodDescriptor getGetDelegatedResourceMethod; + if ((getGetDelegatedResourceMethod = WalletGrpc.getGetDelegatedResourceMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetDelegatedResourceMethod = WalletGrpc.getGetDelegatedResourceMethod) == null) { + WalletGrpc.getGetDelegatedResourceMethod = getGetDelegatedResourceMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetDelegatedResource")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.DelegatedResourceMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.DelegatedResourceList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetDelegatedResource")) + .build(); + } + } + } + return getGetDelegatedResourceMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetDelegatedResourceAccountIndexMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX = getGetDelegatedResourceAccountIndexMethod(); + + private static volatile io.grpc.MethodDescriptor getGetDelegatedResourceAccountIndexMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetDelegatedResourceAccountIndexMethod() { + io.grpc.MethodDescriptor getGetDelegatedResourceAccountIndexMethod; + if ((getGetDelegatedResourceAccountIndexMethod = WalletGrpc.getGetDelegatedResourceAccountIndexMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetDelegatedResourceAccountIndexMethod = WalletGrpc.getGetDelegatedResourceAccountIndexMethod) == null) { + WalletGrpc.getGetDelegatedResourceAccountIndexMethod = getGetDelegatedResourceAccountIndexMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetDelegatedResourceAccountIndex")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.DelegatedResourceAccountIndex.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetDelegatedResourceAccountIndex")) + .build(); + } + } + } + return getGetDelegatedResourceAccountIndexMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getListProposalsMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_LIST_PROPOSALS = getListProposalsMethod(); + + private static volatile io.grpc.MethodDescriptor getListProposalsMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getListProposalsMethod() { + io.grpc.MethodDescriptor getListProposalsMethod; + if ((getListProposalsMethod = WalletGrpc.getListProposalsMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getListProposalsMethod = WalletGrpc.getListProposalsMethod) == null) { + WalletGrpc.getListProposalsMethod = getListProposalsMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ListProposals")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.ProposalList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ListProposals")) + .build(); + } + } + } + return getListProposalsMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetPaginatedProposalListMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_PAGINATED_PROPOSAL_LIST = getGetPaginatedProposalListMethod(); + + private static volatile io.grpc.MethodDescriptor getGetPaginatedProposalListMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetPaginatedProposalListMethod() { + io.grpc.MethodDescriptor getGetPaginatedProposalListMethod; + if ((getGetPaginatedProposalListMethod = WalletGrpc.getGetPaginatedProposalListMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetPaginatedProposalListMethod = WalletGrpc.getGetPaginatedProposalListMethod) == null) { + WalletGrpc.getGetPaginatedProposalListMethod = getGetPaginatedProposalListMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetPaginatedProposalList")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.PaginatedMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.ProposalList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetPaginatedProposalList")) + .build(); + } + } + } + return getGetPaginatedProposalListMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetProposalByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_PROPOSAL_BY_ID = getGetProposalByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetProposalByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetProposalByIdMethod() { + io.grpc.MethodDescriptor getGetProposalByIdMethod; + if ((getGetProposalByIdMethod = WalletGrpc.getGetProposalByIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetProposalByIdMethod = WalletGrpc.getGetProposalByIdMethod) == null) { + WalletGrpc.getGetProposalByIdMethod = getGetProposalByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetProposalById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Proposal.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetProposalById")) + .build(); + } + } + } + return getGetProposalByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getListExchangesMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_LIST_EXCHANGES = getListExchangesMethod(); + + private static volatile io.grpc.MethodDescriptor getListExchangesMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getListExchangesMethod() { + io.grpc.MethodDescriptor getListExchangesMethod; + if ((getListExchangesMethod = WalletGrpc.getListExchangesMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getListExchangesMethod = WalletGrpc.getListExchangesMethod) == null) { + WalletGrpc.getListExchangesMethod = getListExchangesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "ListExchanges")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.ExchangeList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("ListExchanges")) + .build(); + } + } + } + return getListExchangesMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetPaginatedExchangeListMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_PAGINATED_EXCHANGE_LIST = getGetPaginatedExchangeListMethod(); + + private static volatile io.grpc.MethodDescriptor getGetPaginatedExchangeListMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetPaginatedExchangeListMethod() { + io.grpc.MethodDescriptor getGetPaginatedExchangeListMethod; + if ((getGetPaginatedExchangeListMethod = WalletGrpc.getGetPaginatedExchangeListMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetPaginatedExchangeListMethod = WalletGrpc.getGetPaginatedExchangeListMethod) == null) { + WalletGrpc.getGetPaginatedExchangeListMethod = getGetPaginatedExchangeListMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetPaginatedExchangeList")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.PaginatedMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.ExchangeList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetPaginatedExchangeList")) + .build(); + } + } + } + return getGetPaginatedExchangeListMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetExchangeByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_EXCHANGE_BY_ID = getGetExchangeByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetExchangeByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetExchangeByIdMethod() { + io.grpc.MethodDescriptor getGetExchangeByIdMethod; + if ((getGetExchangeByIdMethod = WalletGrpc.getGetExchangeByIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetExchangeByIdMethod = WalletGrpc.getGetExchangeByIdMethod) == null) { + WalletGrpc.getGetExchangeByIdMethod = getGetExchangeByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetExchangeById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Exchange.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetExchangeById")) + .build(); + } + } + } + return getGetExchangeByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetChainParametersMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_CHAIN_PARAMETERS = getGetChainParametersMethod(); + + private static volatile io.grpc.MethodDescriptor getGetChainParametersMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetChainParametersMethod() { + io.grpc.MethodDescriptor getGetChainParametersMethod; + if ((getGetChainParametersMethod = WalletGrpc.getGetChainParametersMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetChainParametersMethod = WalletGrpc.getGetChainParametersMethod) == null) { + WalletGrpc.getGetChainParametersMethod = getGetChainParametersMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetChainParameters")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.ChainParameters.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetChainParameters")) + .build(); + } + } + } + return getGetChainParametersMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueListMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_LIST = getGetAssetIssueListMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueListMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueListMethod() { + io.grpc.MethodDescriptor getGetAssetIssueListMethod; + if ((getGetAssetIssueListMethod = WalletGrpc.getGetAssetIssueListMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetAssetIssueListMethod = WalletGrpc.getGetAssetIssueListMethod) == null) { + WalletGrpc.getGetAssetIssueListMethod = getGetAssetIssueListMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetAssetIssueList")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetAssetIssueList")) + .build(); + } + } + } + return getGetAssetIssueListMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetPaginatedAssetIssueListMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_PAGINATED_ASSET_ISSUE_LIST = getGetPaginatedAssetIssueListMethod(); + + private static volatile io.grpc.MethodDescriptor getGetPaginatedAssetIssueListMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetPaginatedAssetIssueListMethod() { + io.grpc.MethodDescriptor getGetPaginatedAssetIssueListMethod; + if ((getGetPaginatedAssetIssueListMethod = WalletGrpc.getGetPaginatedAssetIssueListMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetPaginatedAssetIssueListMethod = WalletGrpc.getGetPaginatedAssetIssueListMethod) == null) { + WalletGrpc.getGetPaginatedAssetIssueListMethod = getGetPaginatedAssetIssueListMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetPaginatedAssetIssueList")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.PaginatedMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetPaginatedAssetIssueList")) + .build(); + } + } + } + return getGetPaginatedAssetIssueListMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getTotalTransactionMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_TOTAL_TRANSACTION = getTotalTransactionMethod(); + + private static volatile io.grpc.MethodDescriptor getTotalTransactionMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getTotalTransactionMethod() { + io.grpc.MethodDescriptor getTotalTransactionMethod; + if ((getTotalTransactionMethod = WalletGrpc.getTotalTransactionMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getTotalTransactionMethod = WalletGrpc.getTotalTransactionMethod) == null) { + WalletGrpc.getTotalTransactionMethod = getTotalTransactionMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "TotalTransaction")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("TotalTransaction")) + .build(); + } + } + } + return getTotalTransactionMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetNextMaintenanceTimeMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_NEXT_MAINTENANCE_TIME = getGetNextMaintenanceTimeMethod(); + + private static volatile io.grpc.MethodDescriptor getGetNextMaintenanceTimeMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetNextMaintenanceTimeMethod() { + io.grpc.MethodDescriptor getGetNextMaintenanceTimeMethod; + if ((getGetNextMaintenanceTimeMethod = WalletGrpc.getGetNextMaintenanceTimeMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetNextMaintenanceTimeMethod = WalletGrpc.getGetNextMaintenanceTimeMethod) == null) { + WalletGrpc.getGetNextMaintenanceTimeMethod = getGetNextMaintenanceTimeMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetNextMaintenanceTime")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetNextMaintenanceTime")) + .build(); + } + } + } + return getGetNextMaintenanceTimeMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionSignMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_SIGN = getGetTransactionSignMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionSignMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionSignMethod() { + io.grpc.MethodDescriptor getGetTransactionSignMethod; + if ((getGetTransactionSignMethod = WalletGrpc.getGetTransactionSignMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetTransactionSignMethod = WalletGrpc.getGetTransactionSignMethod) == null) { + WalletGrpc.getGetTransactionSignMethod = getGetTransactionSignMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetTransactionSign")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.TransactionSign.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetTransactionSign")) + .build(); + } + } + } + return getGetTransactionSignMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionSign2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_SIGN2 = getGetTransactionSign2Method(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionSign2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionSign2Method() { + io.grpc.MethodDescriptor getGetTransactionSign2Method; + if ((getGetTransactionSign2Method = WalletGrpc.getGetTransactionSign2Method) == null) { + synchronized (WalletGrpc.class) { + if ((getGetTransactionSign2Method = WalletGrpc.getGetTransactionSign2Method) == null) { + WalletGrpc.getGetTransactionSign2Method = getGetTransactionSign2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetTransactionSign2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.TransactionSign.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetTransactionSign2")) + .build(); + } + } + } + return getGetTransactionSign2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getCreateAddressMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_CREATE_ADDRESS = getCreateAddressMethod(); + + private static volatile io.grpc.MethodDescriptor getCreateAddressMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getCreateAddressMethod() { + io.grpc.MethodDescriptor getCreateAddressMethod; + if ((getCreateAddressMethod = WalletGrpc.getCreateAddressMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getCreateAddressMethod = WalletGrpc.getCreateAddressMethod) == null) { + WalletGrpc.getCreateAddressMethod = getCreateAddressMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "CreateAddress")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("CreateAddress")) + .build(); + } + } + } + return getCreateAddressMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getEasyTransferAssetMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EASY_TRANSFER_ASSET = getEasyTransferAssetMethod(); + + private static volatile io.grpc.MethodDescriptor getEasyTransferAssetMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getEasyTransferAssetMethod() { + io.grpc.MethodDescriptor getEasyTransferAssetMethod; + if ((getEasyTransferAssetMethod = WalletGrpc.getEasyTransferAssetMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getEasyTransferAssetMethod = WalletGrpc.getEasyTransferAssetMethod) == null) { + WalletGrpc.getEasyTransferAssetMethod = getEasyTransferAssetMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "EasyTransferAsset")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferAssetMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferResponse.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("EasyTransferAsset")) + .build(); + } + } + } + return getEasyTransferAssetMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getEasyTransferAssetByPrivateMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EASY_TRANSFER_ASSET_BY_PRIVATE = getEasyTransferAssetByPrivateMethod(); + + private static volatile io.grpc.MethodDescriptor getEasyTransferAssetByPrivateMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getEasyTransferAssetByPrivateMethod() { + io.grpc.MethodDescriptor getEasyTransferAssetByPrivateMethod; + if ((getEasyTransferAssetByPrivateMethod = WalletGrpc.getEasyTransferAssetByPrivateMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getEasyTransferAssetByPrivateMethod = WalletGrpc.getEasyTransferAssetByPrivateMethod) == null) { + WalletGrpc.getEasyTransferAssetByPrivateMethod = getEasyTransferAssetByPrivateMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "EasyTransferAssetByPrivate")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferResponse.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("EasyTransferAssetByPrivate")) + .build(); + } + } + } + return getEasyTransferAssetByPrivateMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getEasyTransferMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EASY_TRANSFER = getEasyTransferMethod(); + + private static volatile io.grpc.MethodDescriptor getEasyTransferMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getEasyTransferMethod() { + io.grpc.MethodDescriptor getEasyTransferMethod; + if ((getEasyTransferMethod = WalletGrpc.getEasyTransferMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getEasyTransferMethod = WalletGrpc.getEasyTransferMethod) == null) { + WalletGrpc.getEasyTransferMethod = getEasyTransferMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "EasyTransfer")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferResponse.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("EasyTransfer")) + .build(); + } + } + } + return getEasyTransferMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getEasyTransferByPrivateMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_EASY_TRANSFER_BY_PRIVATE = getEasyTransferByPrivateMethod(); + + private static volatile io.grpc.MethodDescriptor getEasyTransferByPrivateMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getEasyTransferByPrivateMethod() { + io.grpc.MethodDescriptor getEasyTransferByPrivateMethod; + if ((getEasyTransferByPrivateMethod = WalletGrpc.getEasyTransferByPrivateMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getEasyTransferByPrivateMethod = WalletGrpc.getEasyTransferByPrivateMethod) == null) { + WalletGrpc.getEasyTransferByPrivateMethod = getEasyTransferByPrivateMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "EasyTransferByPrivate")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EasyTransferResponse.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("EasyTransferByPrivate")) + .build(); + } + } + } + return getEasyTransferByPrivateMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGenerateAddressMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GENERATE_ADDRESS = getGenerateAddressMethod(); + + private static volatile io.grpc.MethodDescriptor getGenerateAddressMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGenerateAddressMethod() { + io.grpc.MethodDescriptor getGenerateAddressMethod; + if ((getGenerateAddressMethod = WalletGrpc.getGenerateAddressMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGenerateAddressMethod = WalletGrpc.getGenerateAddressMethod) == null) { + WalletGrpc.getGenerateAddressMethod = getGenerateAddressMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GenerateAddress")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AddressPrKeyPairMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GenerateAddress")) + .build(); + } + } + } + return getGenerateAddressMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionInfoByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_INFO_BY_ID = getGetTransactionInfoByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionInfoByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionInfoByIdMethod() { + io.grpc.MethodDescriptor getGetTransactionInfoByIdMethod; + if ((getGetTransactionInfoByIdMethod = WalletGrpc.getGetTransactionInfoByIdMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetTransactionInfoByIdMethod = WalletGrpc.getGetTransactionInfoByIdMethod) == null) { + WalletGrpc.getGetTransactionInfoByIdMethod = getGetTransactionInfoByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetTransactionInfoById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.TransactionInfo.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetTransactionInfoById")) + .build(); + } + } + } + return getGetTransactionInfoByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getAccountPermissionUpdateMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_ACCOUNT_PERMISSION_UPDATE = getAccountPermissionUpdateMethod(); + + private static volatile io.grpc.MethodDescriptor getAccountPermissionUpdateMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getAccountPermissionUpdateMethod() { + io.grpc.MethodDescriptor getAccountPermissionUpdateMethod; + if ((getAccountPermissionUpdateMethod = WalletGrpc.getAccountPermissionUpdateMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getAccountPermissionUpdateMethod = WalletGrpc.getAccountPermissionUpdateMethod) == null) { + WalletGrpc.getAccountPermissionUpdateMethod = getAccountPermissionUpdateMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "AccountPermissionUpdate")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AccountPermissionUpdateContract.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("AccountPermissionUpdate")) + .build(); + } + } + } + return getAccountPermissionUpdateMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getAddSignMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_ADD_SIGN = getAddSignMethod(); + + private static volatile io.grpc.MethodDescriptor getAddSignMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getAddSignMethod() { + io.grpc.MethodDescriptor getAddSignMethod; + if ((getAddSignMethod = WalletGrpc.getAddSignMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getAddSignMethod = WalletGrpc.getAddSignMethod) == null) { + WalletGrpc.getAddSignMethod = getAddSignMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "AddSign")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.TransactionSign.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("AddSign")) + .build(); + } + } + } + return getAddSignMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionSignWeightMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_SIGN_WEIGHT = getGetTransactionSignWeightMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionSignWeightMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionSignWeightMethod() { + io.grpc.MethodDescriptor getGetTransactionSignWeightMethod; + if ((getGetTransactionSignWeightMethod = WalletGrpc.getGetTransactionSignWeightMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetTransactionSignWeightMethod = WalletGrpc.getGetTransactionSignWeightMethod) == null) { + WalletGrpc.getGetTransactionSignWeightMethod = getGetTransactionSignWeightMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetTransactionSignWeight")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionSignWeight.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetTransactionSignWeight")) + .build(); + } + } + } + return getGetTransactionSignWeightMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionApprovedListMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_APPROVED_LIST = getGetTransactionApprovedListMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionApprovedListMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionApprovedListMethod() { + io.grpc.MethodDescriptor getGetTransactionApprovedListMethod; + if ((getGetTransactionApprovedListMethod = WalletGrpc.getGetTransactionApprovedListMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetTransactionApprovedListMethod = WalletGrpc.getGetTransactionApprovedListMethod) == null) { + WalletGrpc.getGetTransactionApprovedListMethod = getGetTransactionApprovedListMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetTransactionApprovedList")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.TransactionApprovedList.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetTransactionApprovedList")) + .build(); + } + } + } + return getGetTransactionApprovedListMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetNodeInfoMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_NODE_INFO = getGetNodeInfoMethod(); + + private static volatile io.grpc.MethodDescriptor getGetNodeInfoMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetNodeInfoMethod() { + io.grpc.MethodDescriptor getGetNodeInfoMethod; + if ((getGetNodeInfoMethod = WalletGrpc.getGetNodeInfoMethod) == null) { + synchronized (WalletGrpc.class) { + if ((getGetNodeInfoMethod = WalletGrpc.getGetNodeInfoMethod) == null) { + WalletGrpc.getGetNodeInfoMethod = getGetNodeInfoMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.Wallet", "GetNodeInfo")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.NodeInfo.getDefaultInstance())) + .setSchemaDescriptor(new WalletMethodDescriptorSupplier("GetNodeInfo")) + .build(); + } + } + } + return getGetNodeInfoMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static WalletStub newStub(io.grpc.Channel channel) { + return new WalletStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static WalletBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new WalletBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static WalletFutureStub newFutureStub( + io.grpc.Channel channel) { + return new WalletFutureStub(channel); + } + + /** + */ + public static abstract class WalletImplBase implements io.grpc.BindableService { + + /** + */ + public void getAccount(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAccountMethod(), responseObserver); + } + + /** + */ + public void getAccountById(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAccountByIdMethod(), responseObserver); + } + + /** + *
+     *Please use CreateTransaction2 instead of this function.
+     * 
+ */ + public void createTransaction(org.tron.protos.Contract.TransferContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateTransactionMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of CreateTransaction.
+     * 
+ */ + public void createTransaction2(org.tron.protos.Contract.TransferContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateTransaction2Method(), responseObserver); + } + + /** + */ + public void broadcastTransaction(org.tron.protos.Protocol.Transaction request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getBroadcastTransactionMethod(), responseObserver); + } + + /** + *
+     *Please use UpdateAccount2 instead of this function.
+     * 
+ */ + public void updateAccount(org.tron.protos.Contract.AccountUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateAccountMethod(), responseObserver); + } + + /** + */ + public void setAccountId(org.tron.protos.Contract.SetAccountIdContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSetAccountIdMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of UpdateAccount.
+     * 
+ */ + public void updateAccount2(org.tron.protos.Contract.AccountUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateAccount2Method(), responseObserver); + } + + /** + *
+     *Please use VoteWitnessAccount2 instead of this function.
+     * 
+ */ + public void voteWitnessAccount(org.tron.protos.Contract.VoteWitnessContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getVoteWitnessAccountMethod(), responseObserver); + } + + /** + *
+     *modify the consume_user_resource_percent
+     * 
+ */ + public void updateSetting(org.tron.protos.Contract.UpdateSettingContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateSettingMethod(), responseObserver); + } + + /** + *
+     *modify the energy_limit
+     * 
+ */ + public void updateEnergyLimit(org.tron.protos.Contract.UpdateEnergyLimitContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateEnergyLimitMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of VoteWitnessAccount.
+     * 
+ */ + public void voteWitnessAccount2(org.tron.protos.Contract.VoteWitnessContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getVoteWitnessAccount2Method(), responseObserver); + } + + /** + *
+     *Please use CreateAssetIssue2 instead of this function.
+     * 
+ */ + public void createAssetIssue(org.tron.protos.Contract.AssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateAssetIssueMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of CreateAssetIssue.
+     * 
+ */ + public void createAssetIssue2(org.tron.protos.Contract.AssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateAssetIssue2Method(), responseObserver); + } + + /** + *
+     *Please use UpdateWitness2 instead of this function.
+     * 
+ */ + public void updateWitness(org.tron.protos.Contract.WitnessUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateWitnessMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of UpdateWitness.
+     * 
+ */ + public void updateWitness2(org.tron.protos.Contract.WitnessUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateWitness2Method(), responseObserver); + } + + /** + *
+     *Please use CreateAccount2 instead of this function.
+     * 
+ */ + public void createAccount(org.tron.protos.Contract.AccountCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateAccountMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of CreateAccount.
+     * 
+ */ + public void createAccount2(org.tron.protos.Contract.AccountCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateAccount2Method(), responseObserver); + } + + /** + *
+     *Please use CreateWitness2 instead of this function.
+     * 
+ */ + public void createWitness(org.tron.protos.Contract.WitnessCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateWitnessMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of CreateWitness.
+     * 
+ */ + public void createWitness2(org.tron.protos.Contract.WitnessCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateWitness2Method(), responseObserver); + } + + /** + *
+     *Please use TransferAsset2 instead of this function.
+     * 
+ */ + public void transferAsset(org.tron.protos.Contract.TransferAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getTransferAssetMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of TransferAsset.
+     * 
+ */ + public void transferAsset2(org.tron.protos.Contract.TransferAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getTransferAsset2Method(), responseObserver); + } + + /** + *
+     *Please use ParticipateAssetIssue2 instead of this function.
+     * 
+ */ + public void participateAssetIssue(org.tron.protos.Contract.ParticipateAssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getParticipateAssetIssueMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of ParticipateAssetIssue.
+     * 
+ */ + public void participateAssetIssue2(org.tron.protos.Contract.ParticipateAssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getParticipateAssetIssue2Method(), responseObserver); + } + + /** + *
+     *Please use FreezeBalance2 instead of this function.
+     * 
+ */ + public void freezeBalance(org.tron.protos.Contract.FreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getFreezeBalanceMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of FreezeBalance.
+     * 
+ */ + public void freezeBalance2(org.tron.protos.Contract.FreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getFreezeBalance2Method(), responseObserver); + } + + /** + *
+     *Please use UnfreezeBalance2 instead of this function.
+     * 
+ */ + public void unfreezeBalance(org.tron.protos.Contract.UnfreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUnfreezeBalanceMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of UnfreezeBalance.
+     * 
+ */ + public void unfreezeBalance2(org.tron.protos.Contract.UnfreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUnfreezeBalance2Method(), responseObserver); + } + + /** + *
+     *Please use UnfreezeAsset2 instead of this function.
+     * 
+ */ + public void unfreezeAsset(org.tron.protos.Contract.UnfreezeAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUnfreezeAssetMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of UnfreezeAsset.
+     * 
+ */ + public void unfreezeAsset2(org.tron.protos.Contract.UnfreezeAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUnfreezeAsset2Method(), responseObserver); + } + + /** + *
+     *Please use WithdrawBalance2 instead of this function.
+     * 
+ */ + public void withdrawBalance(org.tron.protos.Contract.WithdrawBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getWithdrawBalanceMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of WithdrawBalance.
+     * 
+ */ + public void withdrawBalance2(org.tron.protos.Contract.WithdrawBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getWithdrawBalance2Method(), responseObserver); + } + + /** + *
+     *Please use UpdateAsset2 instead of this function.
+     * 
+ */ + public void updateAsset(org.tron.protos.Contract.UpdateAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateAssetMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of UpdateAsset.
+     * 
+ */ + public void updateAsset2(org.tron.protos.Contract.UpdateAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdateAsset2Method(), responseObserver); + } + + /** + */ + public void proposalCreate(org.tron.protos.Contract.ProposalCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getProposalCreateMethod(), responseObserver); + } + + /** + */ + public void proposalApprove(org.tron.protos.Contract.ProposalApproveContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getProposalApproveMethod(), responseObserver); + } + + /** + */ + public void proposalDelete(org.tron.protos.Contract.ProposalDeleteContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getProposalDeleteMethod(), responseObserver); + } + + /** + */ + public void buyStorage(org.tron.protos.Contract.BuyStorageContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getBuyStorageMethod(), responseObserver); + } + + /** + */ + public void buyStorageBytes(org.tron.protos.Contract.BuyStorageBytesContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getBuyStorageBytesMethod(), responseObserver); + } + + /** + */ + public void sellStorage(org.tron.protos.Contract.SellStorageContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getSellStorageMethod(), responseObserver); + } + + /** + */ + public void exchangeCreate(org.tron.protos.Contract.ExchangeCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getExchangeCreateMethod(), responseObserver); + } + + /** + */ + public void exchangeInject(org.tron.protos.Contract.ExchangeInjectContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getExchangeInjectMethod(), responseObserver); + } + + /** + */ + public void exchangeWithdraw(org.tron.protos.Contract.ExchangeWithdrawContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getExchangeWithdrawMethod(), responseObserver); + } + + /** + */ + public void exchangeTransaction(org.tron.protos.Contract.ExchangeTransactionContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getExchangeTransactionMethod(), responseObserver); + } + + /** + */ + public void listNodes(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getListNodesMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueByAccount(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueByAccountMethod(), responseObserver); + } + + /** + */ + public void getAccountNet(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAccountNetMethod(), responseObserver); + } + + /** + */ + public void getAccountResource(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAccountResourceMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueByNameMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueListByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueListByNameMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueByIdMethod(), responseObserver); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public void getNowBlock(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetNowBlockMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public void getNowBlock2(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetNowBlock2Method(), responseObserver); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public void getBlockByNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByNumMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public void getBlockByNum2(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByNum2Method(), responseObserver); + } + + /** + */ + public void getTransactionCountByBlockNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionCountByBlockNumMethod(), responseObserver); + } + + /** + */ + public void getBlockById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByIdMethod(), responseObserver); + } + + /** + *
+     *Please use GetBlockByLimitNext2 instead of this function.
+     * 
+ */ + public void getBlockByLimitNext(org.tron.api.GrpcAPI.BlockLimit request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByLimitNextMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByLimitNext.
+     * 
+ */ + public void getBlockByLimitNext2(org.tron.api.GrpcAPI.BlockLimit request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByLimitNext2Method(), responseObserver); + } + + /** + *
+     *Please use GetBlockByLatestNum2 instead of this function.
+     * 
+ */ + public void getBlockByLatestNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByLatestNumMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByLatestNum.
+     * 
+ */ + public void getBlockByLatestNum2(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByLatestNum2Method(), responseObserver); + } + + /** + */ + public void getTransactionById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionByIdMethod(), responseObserver); + } + + /** + */ + public void deployContract(org.tron.protos.Contract.CreateSmartContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getDeployContractMethod(), responseObserver); + } + + /** + */ + public void getContract(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetContractMethod(), responseObserver); + } + + /** + */ + public void triggerContract(org.tron.protos.Contract.TriggerSmartContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getTriggerContractMethod(), responseObserver); + } + + /** + */ + public void triggerConstantContract(org.tron.protos.Contract.TriggerSmartContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getTriggerConstantContractMethod(), responseObserver); + } + + /** + */ + public void clearContractABI(org.tron.protos.Contract.ClearABIContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getClearContractABIMethod(), responseObserver); + } + + /** + */ + public void listWitnesses(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getListWitnessesMethod(), responseObserver); + } + + /** + */ + public void getDelegatedResource(org.tron.api.GrpcAPI.DelegatedResourceMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetDelegatedResourceMethod(), responseObserver); + } + + /** + */ + public void getDelegatedResourceAccountIndex(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetDelegatedResourceAccountIndexMethod(), responseObserver); + } + + /** + */ + public void listProposals(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getListProposalsMethod(), responseObserver); + } + + /** + */ + public void getPaginatedProposalList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetPaginatedProposalListMethod(), responseObserver); + } + + /** + */ + public void getProposalById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetProposalByIdMethod(), responseObserver); + } + + /** + */ + public void listExchanges(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getListExchangesMethod(), responseObserver); + } + + /** + */ + public void getPaginatedExchangeList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetPaginatedExchangeListMethod(), responseObserver); + } + + /** + */ + public void getExchangeById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetExchangeByIdMethod(), responseObserver); + } + + /** + */ + public void getChainParameters(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetChainParametersMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueList(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueListMethod(), responseObserver); + } + + /** + */ + public void getPaginatedAssetIssueList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetPaginatedAssetIssueListMethod(), responseObserver); + } + + /** + */ + public void totalTransaction(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getTotalTransactionMethod(), responseObserver); + } + + /** + */ + public void getNextMaintenanceTime(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetNextMaintenanceTimeMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Please use GetTransactionSign2 instead of this function.
+     * 
+ */ + public void getTransactionSign(org.tron.protos.Protocol.TransactionSign request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionSignMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Use this function instead of GetTransactionSign.
+     * 
+ */ + public void getTransactionSign2(org.tron.protos.Protocol.TransactionSign request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionSign2Method(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void createAddress(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreateAddressMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransferAsset(org.tron.api.GrpcAPI.EasyTransferAssetMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getEasyTransferAssetMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransferAssetByPrivate(org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getEasyTransferAssetByPrivateMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransfer(org.tron.api.GrpcAPI.EasyTransferMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getEasyTransferMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransferByPrivate(org.tron.api.GrpcAPI.EasyTransferByPrivateMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getEasyTransferByPrivateMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void generateAddress(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGenerateAddressMethod(), responseObserver); + } + + /** + */ + public void getTransactionInfoById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionInfoByIdMethod(), responseObserver); + } + + /** + */ + public void accountPermissionUpdate(org.tron.protos.Contract.AccountPermissionUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getAccountPermissionUpdateMethod(), responseObserver); + } + + /** + */ + public void addSign(org.tron.protos.Protocol.TransactionSign request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getAddSignMethod(), responseObserver); + } + + /** + */ + public void getTransactionSignWeight(org.tron.protos.Protocol.Transaction request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionSignWeightMethod(), responseObserver); + } + + /** + */ + public void getTransactionApprovedList(org.tron.protos.Protocol.Transaction request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionApprovedListMethod(), responseObserver); + } + + /** + */ + public void getNodeInfo(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetNodeInfoMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getGetAccountMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Account, + org.tron.protos.Protocol.Account>( + this, METHODID_GET_ACCOUNT))) + .addMethod( + getGetAccountByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Account, + org.tron.protos.Protocol.Account>( + this, METHODID_GET_ACCOUNT_BY_ID))) + .addMethod( + getCreateTransactionMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.TransferContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_CREATE_TRANSACTION))) + .addMethod( + getCreateTransaction2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.TransferContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_CREATE_TRANSACTION2))) + .addMethod( + getBroadcastTransactionMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Transaction, + org.tron.api.GrpcAPI.Return>( + this, METHODID_BROADCAST_TRANSACTION))) + .addMethod( + getUpdateAccountMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.AccountUpdateContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_UPDATE_ACCOUNT))) + .addMethod( + getSetAccountIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.SetAccountIdContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_SET_ACCOUNT_ID))) + .addMethod( + getUpdateAccount2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.AccountUpdateContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_UPDATE_ACCOUNT2))) + .addMethod( + getVoteWitnessAccountMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.VoteWitnessContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_VOTE_WITNESS_ACCOUNT))) + .addMethod( + getUpdateSettingMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UpdateSettingContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_UPDATE_SETTING))) + .addMethod( + getUpdateEnergyLimitMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UpdateEnergyLimitContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_UPDATE_ENERGY_LIMIT))) + .addMethod( + getVoteWitnessAccount2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.VoteWitnessContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_VOTE_WITNESS_ACCOUNT2))) + .addMethod( + getCreateAssetIssueMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.AssetIssueContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_CREATE_ASSET_ISSUE))) + .addMethod( + getCreateAssetIssue2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.AssetIssueContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_CREATE_ASSET_ISSUE2))) + .addMethod( + getUpdateWitnessMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.WitnessUpdateContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_UPDATE_WITNESS))) + .addMethod( + getUpdateWitness2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.WitnessUpdateContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_UPDATE_WITNESS2))) + .addMethod( + getCreateAccountMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.AccountCreateContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_CREATE_ACCOUNT))) + .addMethod( + getCreateAccount2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.AccountCreateContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_CREATE_ACCOUNT2))) + .addMethod( + getCreateWitnessMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.WitnessCreateContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_CREATE_WITNESS))) + .addMethod( + getCreateWitness2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.WitnessCreateContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_CREATE_WITNESS2))) + .addMethod( + getTransferAssetMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.TransferAssetContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_TRANSFER_ASSET))) + .addMethod( + getTransferAsset2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.TransferAssetContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_TRANSFER_ASSET2))) + .addMethod( + getParticipateAssetIssueMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ParticipateAssetIssueContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_PARTICIPATE_ASSET_ISSUE))) + .addMethod( + getParticipateAssetIssue2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ParticipateAssetIssueContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_PARTICIPATE_ASSET_ISSUE2))) + .addMethod( + getFreezeBalanceMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.FreezeBalanceContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_FREEZE_BALANCE))) + .addMethod( + getFreezeBalance2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.FreezeBalanceContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_FREEZE_BALANCE2))) + .addMethod( + getUnfreezeBalanceMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UnfreezeBalanceContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_UNFREEZE_BALANCE))) + .addMethod( + getUnfreezeBalance2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UnfreezeBalanceContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_UNFREEZE_BALANCE2))) + .addMethod( + getUnfreezeAssetMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UnfreezeAssetContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_UNFREEZE_ASSET))) + .addMethod( + getUnfreezeAsset2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UnfreezeAssetContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_UNFREEZE_ASSET2))) + .addMethod( + getWithdrawBalanceMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.WithdrawBalanceContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_WITHDRAW_BALANCE))) + .addMethod( + getWithdrawBalance2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.WithdrawBalanceContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_WITHDRAW_BALANCE2))) + .addMethod( + getUpdateAssetMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UpdateAssetContract, + org.tron.protos.Protocol.Transaction>( + this, METHODID_UPDATE_ASSET))) + .addMethod( + getUpdateAsset2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.UpdateAssetContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_UPDATE_ASSET2))) + .addMethod( + getProposalCreateMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ProposalCreateContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_PROPOSAL_CREATE))) + .addMethod( + getProposalApproveMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ProposalApproveContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_PROPOSAL_APPROVE))) + .addMethod( + getProposalDeleteMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ProposalDeleteContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_PROPOSAL_DELETE))) + .addMethod( + getBuyStorageMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.BuyStorageContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_BUY_STORAGE))) + .addMethod( + getBuyStorageBytesMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.BuyStorageBytesContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_BUY_STORAGE_BYTES))) + .addMethod( + getSellStorageMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.SellStorageContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_SELL_STORAGE))) + .addMethod( + getExchangeCreateMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ExchangeCreateContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_EXCHANGE_CREATE))) + .addMethod( + getExchangeInjectMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ExchangeInjectContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_EXCHANGE_INJECT))) + .addMethod( + getExchangeWithdrawMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ExchangeWithdrawContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_EXCHANGE_WITHDRAW))) + .addMethod( + getExchangeTransactionMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ExchangeTransactionContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_EXCHANGE_TRANSACTION))) + .addMethod( + getListNodesMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.NodeList>( + this, METHODID_LIST_NODES))) + .addMethod( + getGetAssetIssueByAccountMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Account, + org.tron.api.GrpcAPI.AssetIssueList>( + this, METHODID_GET_ASSET_ISSUE_BY_ACCOUNT))) + .addMethod( + getGetAccountNetMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Account, + org.tron.api.GrpcAPI.AccountNetMessage>( + this, METHODID_GET_ACCOUNT_NET))) + .addMethod( + getGetAccountResourceMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Account, + org.tron.api.GrpcAPI.AccountResourceMessage>( + this, METHODID_GET_ACCOUNT_RESOURCE))) + .addMethod( + getGetAssetIssueByNameMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Contract.AssetIssueContract>( + this, METHODID_GET_ASSET_ISSUE_BY_NAME))) + .addMethod( + getGetAssetIssueListByNameMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.api.GrpcAPI.AssetIssueList>( + this, METHODID_GET_ASSET_ISSUE_LIST_BY_NAME))) + .addMethod( + getGetAssetIssueByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Contract.AssetIssueContract>( + this, METHODID_GET_ASSET_ISSUE_BY_ID))) + .addMethod( + getGetNowBlockMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.protos.Protocol.Block>( + this, METHODID_GET_NOW_BLOCK))) + .addMethod( + getGetNowBlock2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.BlockExtention>( + this, METHODID_GET_NOW_BLOCK2))) + .addMethod( + getGetBlockByNumMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.protos.Protocol.Block>( + this, METHODID_GET_BLOCK_BY_NUM))) + .addMethod( + getGetBlockByNum2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.api.GrpcAPI.BlockExtention>( + this, METHODID_GET_BLOCK_BY_NUM2))) + .addMethod( + getGetTransactionCountByBlockNumMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.api.GrpcAPI.NumberMessage>( + this, METHODID_GET_TRANSACTION_COUNT_BY_BLOCK_NUM))) + .addMethod( + getGetBlockByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.Block>( + this, METHODID_GET_BLOCK_BY_ID))) + .addMethod( + getGetBlockByLimitNextMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BlockLimit, + org.tron.api.GrpcAPI.BlockList>( + this, METHODID_GET_BLOCK_BY_LIMIT_NEXT))) + .addMethod( + getGetBlockByLimitNext2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BlockLimit, + org.tron.api.GrpcAPI.BlockListExtention>( + this, METHODID_GET_BLOCK_BY_LIMIT_NEXT2))) + .addMethod( + getGetBlockByLatestNumMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.api.GrpcAPI.BlockList>( + this, METHODID_GET_BLOCK_BY_LATEST_NUM))) + .addMethod( + getGetBlockByLatestNum2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.api.GrpcAPI.BlockListExtention>( + this, METHODID_GET_BLOCK_BY_LATEST_NUM2))) + .addMethod( + getGetTransactionByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.Transaction>( + this, METHODID_GET_TRANSACTION_BY_ID))) + .addMethod( + getDeployContractMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.CreateSmartContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_DEPLOY_CONTRACT))) + .addMethod( + getGetContractMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.SmartContract>( + this, METHODID_GET_CONTRACT))) + .addMethod( + getTriggerContractMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.TriggerSmartContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_TRIGGER_CONTRACT))) + .addMethod( + getTriggerConstantContractMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.TriggerSmartContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_TRIGGER_CONSTANT_CONTRACT))) + .addMethod( + getClearContractABIMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.ClearABIContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_CLEAR_CONTRACT_ABI))) + .addMethod( + getListWitnessesMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.WitnessList>( + this, METHODID_LIST_WITNESSES))) + .addMethod( + getGetDelegatedResourceMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.DelegatedResourceMessage, + org.tron.api.GrpcAPI.DelegatedResourceList>( + this, METHODID_GET_DELEGATED_RESOURCE))) + .addMethod( + getGetDelegatedResourceAccountIndexMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.DelegatedResourceAccountIndex>( + this, METHODID_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX))) + .addMethod( + getListProposalsMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.ProposalList>( + this, METHODID_LIST_PROPOSALS))) + .addMethod( + getGetPaginatedProposalListMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.PaginatedMessage, + org.tron.api.GrpcAPI.ProposalList>( + this, METHODID_GET_PAGINATED_PROPOSAL_LIST))) + .addMethod( + getGetProposalByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.Proposal>( + this, METHODID_GET_PROPOSAL_BY_ID))) + .addMethod( + getListExchangesMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.ExchangeList>( + this, METHODID_LIST_EXCHANGES))) + .addMethod( + getGetPaginatedExchangeListMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.PaginatedMessage, + org.tron.api.GrpcAPI.ExchangeList>( + this, METHODID_GET_PAGINATED_EXCHANGE_LIST))) + .addMethod( + getGetExchangeByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.Exchange>( + this, METHODID_GET_EXCHANGE_BY_ID))) + .addMethod( + getGetChainParametersMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.protos.Protocol.ChainParameters>( + this, METHODID_GET_CHAIN_PARAMETERS))) + .addMethod( + getGetAssetIssueListMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.AssetIssueList>( + this, METHODID_GET_ASSET_ISSUE_LIST))) + .addMethod( + getGetPaginatedAssetIssueListMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.PaginatedMessage, + org.tron.api.GrpcAPI.AssetIssueList>( + this, METHODID_GET_PAGINATED_ASSET_ISSUE_LIST))) + .addMethod( + getTotalTransactionMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.NumberMessage>( + this, METHODID_TOTAL_TRANSACTION))) + .addMethod( + getGetNextMaintenanceTimeMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.NumberMessage>( + this, METHODID_GET_NEXT_MAINTENANCE_TIME))) + .addMethod( + getGetTransactionSignMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.TransactionSign, + org.tron.protos.Protocol.Transaction>( + this, METHODID_GET_TRANSACTION_SIGN))) + .addMethod( + getGetTransactionSign2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.TransactionSign, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_GET_TRANSACTION_SIGN2))) + .addMethod( + getCreateAddressMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.api.GrpcAPI.BytesMessage>( + this, METHODID_CREATE_ADDRESS))) + .addMethod( + getEasyTransferAssetMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EasyTransferAssetMessage, + org.tron.api.GrpcAPI.EasyTransferResponse>( + this, METHODID_EASY_TRANSFER_ASSET))) + .addMethod( + getEasyTransferAssetByPrivateMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage, + org.tron.api.GrpcAPI.EasyTransferResponse>( + this, METHODID_EASY_TRANSFER_ASSET_BY_PRIVATE))) + .addMethod( + getEasyTransferMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EasyTransferMessage, + org.tron.api.GrpcAPI.EasyTransferResponse>( + this, METHODID_EASY_TRANSFER))) + .addMethod( + getEasyTransferByPrivateMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage, + org.tron.api.GrpcAPI.EasyTransferResponse>( + this, METHODID_EASY_TRANSFER_BY_PRIVATE))) + .addMethod( + getGenerateAddressMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.AddressPrKeyPairMessage>( + this, METHODID_GENERATE_ADDRESS))) + .addMethod( + getGetTransactionInfoByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.TransactionInfo>( + this, METHODID_GET_TRANSACTION_INFO_BY_ID))) + .addMethod( + getAccountPermissionUpdateMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Contract.AccountPermissionUpdateContract, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_ACCOUNT_PERMISSION_UPDATE))) + .addMethod( + getAddSignMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.TransactionSign, + org.tron.api.GrpcAPI.TransactionExtention>( + this, METHODID_ADD_SIGN))) + .addMethod( + getGetTransactionSignWeightMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Transaction, + org.tron.api.GrpcAPI.TransactionSignWeight>( + this, METHODID_GET_TRANSACTION_SIGN_WEIGHT))) + .addMethod( + getGetTransactionApprovedListMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Transaction, + org.tron.api.GrpcAPI.TransactionApprovedList>( + this, METHODID_GET_TRANSACTION_APPROVED_LIST))) + .addMethod( + getGetNodeInfoMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.protos.Protocol.NodeInfo>( + this, METHODID_GET_NODE_INFO))) + .build(); + } + } + + /** + */ + public static final class WalletStub extends io.grpc.stub.AbstractStub { + private WalletStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletStub(channel, callOptions); + } + + /** + */ + public void getAccount(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAccountMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAccountById(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAccountByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use CreateTransaction2 instead of this function.
+     * 
+ */ + public void createTransaction(org.tron.protos.Contract.TransferContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateTransactionMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of CreateTransaction.
+     * 
+ */ + public void createTransaction2(org.tron.protos.Contract.TransferContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateTransaction2Method(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void broadcastTransaction(org.tron.protos.Protocol.Transaction request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getBroadcastTransactionMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use UpdateAccount2 instead of this function.
+     * 
+ */ + public void updateAccount(org.tron.protos.Contract.AccountUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateAccountMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void setAccountId(org.tron.protos.Contract.SetAccountIdContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getSetAccountIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of UpdateAccount.
+     * 
+ */ + public void updateAccount2(org.tron.protos.Contract.AccountUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateAccount2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use VoteWitnessAccount2 instead of this function.
+     * 
+ */ + public void voteWitnessAccount(org.tron.protos.Contract.VoteWitnessContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getVoteWitnessAccountMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *modify the consume_user_resource_percent
+     * 
+ */ + public void updateSetting(org.tron.protos.Contract.UpdateSettingContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateSettingMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *modify the energy_limit
+     * 
+ */ + public void updateEnergyLimit(org.tron.protos.Contract.UpdateEnergyLimitContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateEnergyLimitMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of VoteWitnessAccount.
+     * 
+ */ + public void voteWitnessAccount2(org.tron.protos.Contract.VoteWitnessContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getVoteWitnessAccount2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use CreateAssetIssue2 instead of this function.
+     * 
+ */ + public void createAssetIssue(org.tron.protos.Contract.AssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateAssetIssueMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of CreateAssetIssue.
+     * 
+ */ + public void createAssetIssue2(org.tron.protos.Contract.AssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateAssetIssue2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use UpdateWitness2 instead of this function.
+     * 
+ */ + public void updateWitness(org.tron.protos.Contract.WitnessUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateWitnessMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of UpdateWitness.
+     * 
+ */ + public void updateWitness2(org.tron.protos.Contract.WitnessUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateWitness2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use CreateAccount2 instead of this function.
+     * 
+ */ + public void createAccount(org.tron.protos.Contract.AccountCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateAccountMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of CreateAccount.
+     * 
+ */ + public void createAccount2(org.tron.protos.Contract.AccountCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateAccount2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use CreateWitness2 instead of this function.
+     * 
+ */ + public void createWitness(org.tron.protos.Contract.WitnessCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateWitnessMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of CreateWitness.
+     * 
+ */ + public void createWitness2(org.tron.protos.Contract.WitnessCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateWitness2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use TransferAsset2 instead of this function.
+     * 
+ */ + public void transferAsset(org.tron.protos.Contract.TransferAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getTransferAssetMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of TransferAsset.
+     * 
+ */ + public void transferAsset2(org.tron.protos.Contract.TransferAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getTransferAsset2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use ParticipateAssetIssue2 instead of this function.
+     * 
+ */ + public void participateAssetIssue(org.tron.protos.Contract.ParticipateAssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getParticipateAssetIssueMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of ParticipateAssetIssue.
+     * 
+ */ + public void participateAssetIssue2(org.tron.protos.Contract.ParticipateAssetIssueContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getParticipateAssetIssue2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use FreezeBalance2 instead of this function.
+     * 
+ */ + public void freezeBalance(org.tron.protos.Contract.FreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getFreezeBalanceMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of FreezeBalance.
+     * 
+ */ + public void freezeBalance2(org.tron.protos.Contract.FreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getFreezeBalance2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use UnfreezeBalance2 instead of this function.
+     * 
+ */ + public void unfreezeBalance(org.tron.protos.Contract.UnfreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUnfreezeBalanceMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of UnfreezeBalance.
+     * 
+ */ + public void unfreezeBalance2(org.tron.protos.Contract.UnfreezeBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUnfreezeBalance2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use UnfreezeAsset2 instead of this function.
+     * 
+ */ + public void unfreezeAsset(org.tron.protos.Contract.UnfreezeAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUnfreezeAssetMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of UnfreezeAsset.
+     * 
+ */ + public void unfreezeAsset2(org.tron.protos.Contract.UnfreezeAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUnfreezeAsset2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use WithdrawBalance2 instead of this function.
+     * 
+ */ + public void withdrawBalance(org.tron.protos.Contract.WithdrawBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getWithdrawBalanceMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of WithdrawBalance.
+     * 
+ */ + public void withdrawBalance2(org.tron.protos.Contract.WithdrawBalanceContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getWithdrawBalance2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use UpdateAsset2 instead of this function.
+     * 
+ */ + public void updateAsset(org.tron.protos.Contract.UpdateAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateAssetMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of UpdateAsset.
+     * 
+ */ + public void updateAsset2(org.tron.protos.Contract.UpdateAssetContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdateAsset2Method(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void proposalCreate(org.tron.protos.Contract.ProposalCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getProposalCreateMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void proposalApprove(org.tron.protos.Contract.ProposalApproveContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getProposalApproveMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void proposalDelete(org.tron.protos.Contract.ProposalDeleteContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getProposalDeleteMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void buyStorage(org.tron.protos.Contract.BuyStorageContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getBuyStorageMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void buyStorageBytes(org.tron.protos.Contract.BuyStorageBytesContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getBuyStorageBytesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void sellStorage(org.tron.protos.Contract.SellStorageContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getSellStorageMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void exchangeCreate(org.tron.protos.Contract.ExchangeCreateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getExchangeCreateMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void exchangeInject(org.tron.protos.Contract.ExchangeInjectContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getExchangeInjectMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void exchangeWithdraw(org.tron.protos.Contract.ExchangeWithdrawContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getExchangeWithdrawMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void exchangeTransaction(org.tron.protos.Contract.ExchangeTransactionContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getExchangeTransactionMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listNodes(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListNodesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueByAccount(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueByAccountMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAccountNet(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAccountNetMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAccountResource(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAccountResourceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueByNameMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueListByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueListByNameMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public void getNowBlock(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetNowBlockMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public void getNowBlock2(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetNowBlock2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public void getBlockByNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByNumMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public void getBlockByNum2(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByNum2Method(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionCountByBlockNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionCountByBlockNumMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getBlockById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use GetBlockByLimitNext2 instead of this function.
+     * 
+ */ + public void getBlockByLimitNext(org.tron.api.GrpcAPI.BlockLimit request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByLimitNextMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByLimitNext.
+     * 
+ */ + public void getBlockByLimitNext2(org.tron.api.GrpcAPI.BlockLimit request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByLimitNext2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use GetBlockByLatestNum2 instead of this function.
+     * 
+ */ + public void getBlockByLatestNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByLatestNumMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByLatestNum.
+     * 
+ */ + public void getBlockByLatestNum2(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByLatestNum2Method(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void deployContract(org.tron.protos.Contract.CreateSmartContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getDeployContractMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getContract(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetContractMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void triggerContract(org.tron.protos.Contract.TriggerSmartContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getTriggerContractMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void triggerConstantContract(org.tron.protos.Contract.TriggerSmartContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getTriggerConstantContractMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void clearContractABI(org.tron.protos.Contract.ClearABIContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getClearContractABIMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listWitnesses(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListWitnessesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getDelegatedResource(org.tron.api.GrpcAPI.DelegatedResourceMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetDelegatedResourceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getDelegatedResourceAccountIndex(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetDelegatedResourceAccountIndexMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listProposals(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListProposalsMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getPaginatedProposalList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetPaginatedProposalListMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getProposalById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetProposalByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listExchanges(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListExchangesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getPaginatedExchangeList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetPaginatedExchangeListMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getExchangeById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetExchangeByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getChainParameters(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetChainParametersMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueList(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueListMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getPaginatedAssetIssueList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetPaginatedAssetIssueListMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void totalTransaction(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getTotalTransactionMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getNextMaintenanceTime(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetNextMaintenanceTimeMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Please use GetTransactionSign2 instead of this function.
+     * 
+ */ + public void getTransactionSign(org.tron.protos.Protocol.TransactionSign request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionSignMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Use this function instead of GetTransactionSign.
+     * 
+ */ + public void getTransactionSign2(org.tron.protos.Protocol.TransactionSign request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionSign2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void createAddress(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreateAddressMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransferAsset(org.tron.api.GrpcAPI.EasyTransferAssetMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getEasyTransferAssetMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransferAssetByPrivate(org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getEasyTransferAssetByPrivateMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransfer(org.tron.api.GrpcAPI.EasyTransferMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getEasyTransferMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void easyTransferByPrivate(org.tron.api.GrpcAPI.EasyTransferByPrivateMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getEasyTransferByPrivateMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void generateAddress(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGenerateAddressMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionInfoById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionInfoByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void accountPermissionUpdate(org.tron.protos.Contract.AccountPermissionUpdateContract request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getAccountPermissionUpdateMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void addSign(org.tron.protos.Protocol.TransactionSign request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getAddSignMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionSignWeight(org.tron.protos.Protocol.Transaction request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionSignWeightMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionApprovedList(org.tron.protos.Protocol.Transaction request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionApprovedListMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getNodeInfo(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetNodeInfoMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class WalletBlockingStub extends io.grpc.stub.AbstractStub { + private WalletBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletBlockingStub(channel, callOptions); + } + + /** + */ + public org.tron.protos.Protocol.Account getAccount(org.tron.protos.Protocol.Account request) { + return blockingUnaryCall( + getChannel(), getGetAccountMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Account getAccountById(org.tron.protos.Protocol.Account request) { + return blockingUnaryCall( + getChannel(), getGetAccountByIdMethod(), getCallOptions(), request); + } + + /** + *
+     *Please use CreateTransaction2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction createTransaction(org.tron.protos.Contract.TransferContract request) { + return blockingUnaryCall( + getChannel(), getCreateTransactionMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of CreateTransaction.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention createTransaction2(org.tron.protos.Contract.TransferContract request) { + return blockingUnaryCall( + getChannel(), getCreateTransaction2Method(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.Return broadcastTransaction(org.tron.protos.Protocol.Transaction request) { + return blockingUnaryCall( + getChannel(), getBroadcastTransactionMethod(), getCallOptions(), request); + } + + /** + *
+     *Please use UpdateAccount2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction updateAccount(org.tron.protos.Contract.AccountUpdateContract request) { + return blockingUnaryCall( + getChannel(), getUpdateAccountMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Transaction setAccountId(org.tron.protos.Contract.SetAccountIdContract request) { + return blockingUnaryCall( + getChannel(), getSetAccountIdMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of UpdateAccount.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention updateAccount2(org.tron.protos.Contract.AccountUpdateContract request) { + return blockingUnaryCall( + getChannel(), getUpdateAccount2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use VoteWitnessAccount2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction voteWitnessAccount(org.tron.protos.Contract.VoteWitnessContract request) { + return blockingUnaryCall( + getChannel(), getVoteWitnessAccountMethod(), getCallOptions(), request); + } + + /** + *
+     *modify the consume_user_resource_percent
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention updateSetting(org.tron.protos.Contract.UpdateSettingContract request) { + return blockingUnaryCall( + getChannel(), getUpdateSettingMethod(), getCallOptions(), request); + } + + /** + *
+     *modify the energy_limit
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention updateEnergyLimit(org.tron.protos.Contract.UpdateEnergyLimitContract request) { + return blockingUnaryCall( + getChannel(), getUpdateEnergyLimitMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of VoteWitnessAccount.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention voteWitnessAccount2(org.tron.protos.Contract.VoteWitnessContract request) { + return blockingUnaryCall( + getChannel(), getVoteWitnessAccount2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use CreateAssetIssue2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction createAssetIssue(org.tron.protos.Contract.AssetIssueContract request) { + return blockingUnaryCall( + getChannel(), getCreateAssetIssueMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of CreateAssetIssue.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention createAssetIssue2(org.tron.protos.Contract.AssetIssueContract request) { + return blockingUnaryCall( + getChannel(), getCreateAssetIssue2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use UpdateWitness2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction updateWitness(org.tron.protos.Contract.WitnessUpdateContract request) { + return blockingUnaryCall( + getChannel(), getUpdateWitnessMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of UpdateWitness.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention updateWitness2(org.tron.protos.Contract.WitnessUpdateContract request) { + return blockingUnaryCall( + getChannel(), getUpdateWitness2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use CreateAccount2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction createAccount(org.tron.protos.Contract.AccountCreateContract request) { + return blockingUnaryCall( + getChannel(), getCreateAccountMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of CreateAccount.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention createAccount2(org.tron.protos.Contract.AccountCreateContract request) { + return blockingUnaryCall( + getChannel(), getCreateAccount2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use CreateWitness2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction createWitness(org.tron.protos.Contract.WitnessCreateContract request) { + return blockingUnaryCall( + getChannel(), getCreateWitnessMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of CreateWitness.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention createWitness2(org.tron.protos.Contract.WitnessCreateContract request) { + return blockingUnaryCall( + getChannel(), getCreateWitness2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use TransferAsset2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction transferAsset(org.tron.protos.Contract.TransferAssetContract request) { + return blockingUnaryCall( + getChannel(), getTransferAssetMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of TransferAsset.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention transferAsset2(org.tron.protos.Contract.TransferAssetContract request) { + return blockingUnaryCall( + getChannel(), getTransferAsset2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use ParticipateAssetIssue2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction participateAssetIssue(org.tron.protos.Contract.ParticipateAssetIssueContract request) { + return blockingUnaryCall( + getChannel(), getParticipateAssetIssueMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of ParticipateAssetIssue.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention participateAssetIssue2(org.tron.protos.Contract.ParticipateAssetIssueContract request) { + return blockingUnaryCall( + getChannel(), getParticipateAssetIssue2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use FreezeBalance2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction freezeBalance(org.tron.protos.Contract.FreezeBalanceContract request) { + return blockingUnaryCall( + getChannel(), getFreezeBalanceMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of FreezeBalance.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention freezeBalance2(org.tron.protos.Contract.FreezeBalanceContract request) { + return blockingUnaryCall( + getChannel(), getFreezeBalance2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use UnfreezeBalance2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction unfreezeBalance(org.tron.protos.Contract.UnfreezeBalanceContract request) { + return blockingUnaryCall( + getChannel(), getUnfreezeBalanceMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of UnfreezeBalance.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention unfreezeBalance2(org.tron.protos.Contract.UnfreezeBalanceContract request) { + return blockingUnaryCall( + getChannel(), getUnfreezeBalance2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use UnfreezeAsset2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction unfreezeAsset(org.tron.protos.Contract.UnfreezeAssetContract request) { + return blockingUnaryCall( + getChannel(), getUnfreezeAssetMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of UnfreezeAsset.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention unfreezeAsset2(org.tron.protos.Contract.UnfreezeAssetContract request) { + return blockingUnaryCall( + getChannel(), getUnfreezeAsset2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use WithdrawBalance2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction withdrawBalance(org.tron.protos.Contract.WithdrawBalanceContract request) { + return blockingUnaryCall( + getChannel(), getWithdrawBalanceMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of WithdrawBalance.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention withdrawBalance2(org.tron.protos.Contract.WithdrawBalanceContract request) { + return blockingUnaryCall( + getChannel(), getWithdrawBalance2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use UpdateAsset2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction updateAsset(org.tron.protos.Contract.UpdateAssetContract request) { + return blockingUnaryCall( + getChannel(), getUpdateAssetMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of UpdateAsset.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention updateAsset2(org.tron.protos.Contract.UpdateAssetContract request) { + return blockingUnaryCall( + getChannel(), getUpdateAsset2Method(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention proposalCreate(org.tron.protos.Contract.ProposalCreateContract request) { + return blockingUnaryCall( + getChannel(), getProposalCreateMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention proposalApprove(org.tron.protos.Contract.ProposalApproveContract request) { + return blockingUnaryCall( + getChannel(), getProposalApproveMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention proposalDelete(org.tron.protos.Contract.ProposalDeleteContract request) { + return blockingUnaryCall( + getChannel(), getProposalDeleteMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention buyStorage(org.tron.protos.Contract.BuyStorageContract request) { + return blockingUnaryCall( + getChannel(), getBuyStorageMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention buyStorageBytes(org.tron.protos.Contract.BuyStorageBytesContract request) { + return blockingUnaryCall( + getChannel(), getBuyStorageBytesMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention sellStorage(org.tron.protos.Contract.SellStorageContract request) { + return blockingUnaryCall( + getChannel(), getSellStorageMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention exchangeCreate(org.tron.protos.Contract.ExchangeCreateContract request) { + return blockingUnaryCall( + getChannel(), getExchangeCreateMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention exchangeInject(org.tron.protos.Contract.ExchangeInjectContract request) { + return blockingUnaryCall( + getChannel(), getExchangeInjectMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention exchangeWithdraw(org.tron.protos.Contract.ExchangeWithdrawContract request) { + return blockingUnaryCall( + getChannel(), getExchangeWithdrawMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention exchangeTransaction(org.tron.protos.Contract.ExchangeTransactionContract request) { + return blockingUnaryCall( + getChannel(), getExchangeTransactionMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.NodeList listNodes(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getListNodesMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AssetIssueList getAssetIssueByAccount(org.tron.protos.Protocol.Account request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueByAccountMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AccountNetMessage getAccountNet(org.tron.protos.Protocol.Account request) { + return blockingUnaryCall( + getChannel(), getGetAccountNetMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AccountResourceMessage getAccountResource(org.tron.protos.Protocol.Account request) { + return blockingUnaryCall( + getChannel(), getGetAccountResourceMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Contract.AssetIssueContract getAssetIssueByName(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueByNameMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AssetIssueList getAssetIssueListByName(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueListByNameMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Contract.AssetIssueContract getAssetIssueById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueByIdMethod(), getCallOptions(), request); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Block getNowBlock(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetNowBlockMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockExtention getNowBlock2(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetNowBlock2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Block getBlockByNum(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetBlockByNumMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockExtention getBlockByNum2(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetBlockByNum2Method(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.NumberMessage getTransactionCountByBlockNum(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetTransactionCountByBlockNumMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Block getBlockById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetBlockByIdMethod(), getCallOptions(), request); + } + + /** + *
+     *Please use GetBlockByLimitNext2 instead of this function.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockList getBlockByLimitNext(org.tron.api.GrpcAPI.BlockLimit request) { + return blockingUnaryCall( + getChannel(), getGetBlockByLimitNextMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetBlockByLimitNext.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockListExtention getBlockByLimitNext2(org.tron.api.GrpcAPI.BlockLimit request) { + return blockingUnaryCall( + getChannel(), getGetBlockByLimitNext2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use GetBlockByLatestNum2 instead of this function.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockList getBlockByLatestNum(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetBlockByLatestNumMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetBlockByLatestNum.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockListExtention getBlockByLatestNum2(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetBlockByLatestNum2Method(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Transaction getTransactionById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetTransactionByIdMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention deployContract(org.tron.protos.Contract.CreateSmartContract request) { + return blockingUnaryCall( + getChannel(), getDeployContractMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.SmartContract getContract(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetContractMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention triggerContract(org.tron.protos.Contract.TriggerSmartContract request) { + return blockingUnaryCall( + getChannel(), getTriggerContractMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention triggerConstantContract(org.tron.protos.Contract.TriggerSmartContract request) { + return blockingUnaryCall( + getChannel(), getTriggerConstantContractMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention clearContractABI(org.tron.protos.Contract.ClearABIContract request) { + return blockingUnaryCall( + getChannel(), getClearContractABIMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.WitnessList listWitnesses(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getListWitnessesMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.DelegatedResourceList getDelegatedResource(org.tron.api.GrpcAPI.DelegatedResourceMessage request) { + return blockingUnaryCall( + getChannel(), getGetDelegatedResourceMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.DelegatedResourceAccountIndex getDelegatedResourceAccountIndex(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetDelegatedResourceAccountIndexMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.ProposalList listProposals(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getListProposalsMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.ProposalList getPaginatedProposalList(org.tron.api.GrpcAPI.PaginatedMessage request) { + return blockingUnaryCall( + getChannel(), getGetPaginatedProposalListMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Proposal getProposalById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetProposalByIdMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.ExchangeList listExchanges(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getListExchangesMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.ExchangeList getPaginatedExchangeList(org.tron.api.GrpcAPI.PaginatedMessage request) { + return blockingUnaryCall( + getChannel(), getGetPaginatedExchangeListMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Exchange getExchangeById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetExchangeByIdMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.ChainParameters getChainParameters(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetChainParametersMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AssetIssueList getAssetIssueList(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueListMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AssetIssueList getPaginatedAssetIssueList(org.tron.api.GrpcAPI.PaginatedMessage request) { + return blockingUnaryCall( + getChannel(), getGetPaginatedAssetIssueListMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.NumberMessage totalTransaction(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getTotalTransactionMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.NumberMessage getNextMaintenanceTime(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetNextMaintenanceTimeMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Please use GetTransactionSign2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Transaction getTransactionSign(org.tron.protos.Protocol.TransactionSign request) { + return blockingUnaryCall( + getChannel(), getGetTransactionSignMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Use this function instead of GetTransactionSign.
+     * 
+ */ + public org.tron.api.GrpcAPI.TransactionExtention getTransactionSign2(org.tron.protos.Protocol.TransactionSign request) { + return blockingUnaryCall( + getChannel(), getGetTransactionSign2Method(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public org.tron.api.GrpcAPI.BytesMessage createAddress(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getCreateAddressMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public org.tron.api.GrpcAPI.EasyTransferResponse easyTransferAsset(org.tron.api.GrpcAPI.EasyTransferAssetMessage request) { + return blockingUnaryCall( + getChannel(), getEasyTransferAssetMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public org.tron.api.GrpcAPI.EasyTransferResponse easyTransferAssetByPrivate(org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage request) { + return blockingUnaryCall( + getChannel(), getEasyTransferAssetByPrivateMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public org.tron.api.GrpcAPI.EasyTransferResponse easyTransfer(org.tron.api.GrpcAPI.EasyTransferMessage request) { + return blockingUnaryCall( + getChannel(), getEasyTransferMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public org.tron.api.GrpcAPI.EasyTransferResponse easyTransferByPrivate(org.tron.api.GrpcAPI.EasyTransferByPrivateMessage request) { + return blockingUnaryCall( + getChannel(), getEasyTransferByPrivateMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public org.tron.api.GrpcAPI.AddressPrKeyPairMessage generateAddress(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGenerateAddressMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.TransactionInfo getTransactionInfoById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetTransactionInfoByIdMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention accountPermissionUpdate(org.tron.protos.Contract.AccountPermissionUpdateContract request) { + return blockingUnaryCall( + getChannel(), getAccountPermissionUpdateMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionExtention addSign(org.tron.protos.Protocol.TransactionSign request) { + return blockingUnaryCall( + getChannel(), getAddSignMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionSignWeight getTransactionSignWeight(org.tron.protos.Protocol.Transaction request) { + return blockingUnaryCall( + getChannel(), getGetTransactionSignWeightMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.TransactionApprovedList getTransactionApprovedList(org.tron.protos.Protocol.Transaction request) { + return blockingUnaryCall( + getChannel(), getGetTransactionApprovedListMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.NodeInfo getNodeInfo(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetNodeInfoMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class WalletFutureStub extends io.grpc.stub.AbstractStub { + private WalletFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAccount( + org.tron.protos.Protocol.Account request) { + return futureUnaryCall( + getChannel().newCall(getGetAccountMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAccountById( + org.tron.protos.Protocol.Account request) { + return futureUnaryCall( + getChannel().newCall(getGetAccountByIdMethod(), getCallOptions()), request); + } + + /** + *
+     *Please use CreateTransaction2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createTransaction( + org.tron.protos.Contract.TransferContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateTransactionMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of CreateTransaction.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createTransaction2( + org.tron.protos.Contract.TransferContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateTransaction2Method(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture broadcastTransaction( + org.tron.protos.Protocol.Transaction request) { + return futureUnaryCall( + getChannel().newCall(getBroadcastTransactionMethod(), getCallOptions()), request); + } + + /** + *
+     *Please use UpdateAccount2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateAccount( + org.tron.protos.Contract.AccountUpdateContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateAccountMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture setAccountId( + org.tron.protos.Contract.SetAccountIdContract request) { + return futureUnaryCall( + getChannel().newCall(getSetAccountIdMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of UpdateAccount.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateAccount2( + org.tron.protos.Contract.AccountUpdateContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateAccount2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use VoteWitnessAccount2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture voteWitnessAccount( + org.tron.protos.Contract.VoteWitnessContract request) { + return futureUnaryCall( + getChannel().newCall(getVoteWitnessAccountMethod(), getCallOptions()), request); + } + + /** + *
+     *modify the consume_user_resource_percent
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateSetting( + org.tron.protos.Contract.UpdateSettingContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateSettingMethod(), getCallOptions()), request); + } + + /** + *
+     *modify the energy_limit
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateEnergyLimit( + org.tron.protos.Contract.UpdateEnergyLimitContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateEnergyLimitMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of VoteWitnessAccount.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture voteWitnessAccount2( + org.tron.protos.Contract.VoteWitnessContract request) { + return futureUnaryCall( + getChannel().newCall(getVoteWitnessAccount2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use CreateAssetIssue2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createAssetIssue( + org.tron.protos.Contract.AssetIssueContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateAssetIssueMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of CreateAssetIssue.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createAssetIssue2( + org.tron.protos.Contract.AssetIssueContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateAssetIssue2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use UpdateWitness2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateWitness( + org.tron.protos.Contract.WitnessUpdateContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateWitnessMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of UpdateWitness.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateWitness2( + org.tron.protos.Contract.WitnessUpdateContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateWitness2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use CreateAccount2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createAccount( + org.tron.protos.Contract.AccountCreateContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateAccountMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of CreateAccount.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createAccount2( + org.tron.protos.Contract.AccountCreateContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateAccount2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use CreateWitness2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createWitness( + org.tron.protos.Contract.WitnessCreateContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateWitnessMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of CreateWitness.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createWitness2( + org.tron.protos.Contract.WitnessCreateContract request) { + return futureUnaryCall( + getChannel().newCall(getCreateWitness2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use TransferAsset2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture transferAsset( + org.tron.protos.Contract.TransferAssetContract request) { + return futureUnaryCall( + getChannel().newCall(getTransferAssetMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of TransferAsset.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture transferAsset2( + org.tron.protos.Contract.TransferAssetContract request) { + return futureUnaryCall( + getChannel().newCall(getTransferAsset2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use ParticipateAssetIssue2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture participateAssetIssue( + org.tron.protos.Contract.ParticipateAssetIssueContract request) { + return futureUnaryCall( + getChannel().newCall(getParticipateAssetIssueMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of ParticipateAssetIssue.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture participateAssetIssue2( + org.tron.protos.Contract.ParticipateAssetIssueContract request) { + return futureUnaryCall( + getChannel().newCall(getParticipateAssetIssue2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use FreezeBalance2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture freezeBalance( + org.tron.protos.Contract.FreezeBalanceContract request) { + return futureUnaryCall( + getChannel().newCall(getFreezeBalanceMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of FreezeBalance.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture freezeBalance2( + org.tron.protos.Contract.FreezeBalanceContract request) { + return futureUnaryCall( + getChannel().newCall(getFreezeBalance2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use UnfreezeBalance2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture unfreezeBalance( + org.tron.protos.Contract.UnfreezeBalanceContract request) { + return futureUnaryCall( + getChannel().newCall(getUnfreezeBalanceMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of UnfreezeBalance.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture unfreezeBalance2( + org.tron.protos.Contract.UnfreezeBalanceContract request) { + return futureUnaryCall( + getChannel().newCall(getUnfreezeBalance2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use UnfreezeAsset2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture unfreezeAsset( + org.tron.protos.Contract.UnfreezeAssetContract request) { + return futureUnaryCall( + getChannel().newCall(getUnfreezeAssetMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of UnfreezeAsset.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture unfreezeAsset2( + org.tron.protos.Contract.UnfreezeAssetContract request) { + return futureUnaryCall( + getChannel().newCall(getUnfreezeAsset2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use WithdrawBalance2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture withdrawBalance( + org.tron.protos.Contract.WithdrawBalanceContract request) { + return futureUnaryCall( + getChannel().newCall(getWithdrawBalanceMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of WithdrawBalance.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture withdrawBalance2( + org.tron.protos.Contract.WithdrawBalanceContract request) { + return futureUnaryCall( + getChannel().newCall(getWithdrawBalance2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use UpdateAsset2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateAsset( + org.tron.protos.Contract.UpdateAssetContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateAssetMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of UpdateAsset.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture updateAsset2( + org.tron.protos.Contract.UpdateAssetContract request) { + return futureUnaryCall( + getChannel().newCall(getUpdateAsset2Method(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture proposalCreate( + org.tron.protos.Contract.ProposalCreateContract request) { + return futureUnaryCall( + getChannel().newCall(getProposalCreateMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture proposalApprove( + org.tron.protos.Contract.ProposalApproveContract request) { + return futureUnaryCall( + getChannel().newCall(getProposalApproveMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture proposalDelete( + org.tron.protos.Contract.ProposalDeleteContract request) { + return futureUnaryCall( + getChannel().newCall(getProposalDeleteMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture buyStorage( + org.tron.protos.Contract.BuyStorageContract request) { + return futureUnaryCall( + getChannel().newCall(getBuyStorageMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture buyStorageBytes( + org.tron.protos.Contract.BuyStorageBytesContract request) { + return futureUnaryCall( + getChannel().newCall(getBuyStorageBytesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture sellStorage( + org.tron.protos.Contract.SellStorageContract request) { + return futureUnaryCall( + getChannel().newCall(getSellStorageMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture exchangeCreate( + org.tron.protos.Contract.ExchangeCreateContract request) { + return futureUnaryCall( + getChannel().newCall(getExchangeCreateMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture exchangeInject( + org.tron.protos.Contract.ExchangeInjectContract request) { + return futureUnaryCall( + getChannel().newCall(getExchangeInjectMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture exchangeWithdraw( + org.tron.protos.Contract.ExchangeWithdrawContract request) { + return futureUnaryCall( + getChannel().newCall(getExchangeWithdrawMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture exchangeTransaction( + org.tron.protos.Contract.ExchangeTransactionContract request) { + return futureUnaryCall( + getChannel().newCall(getExchangeTransactionMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture listNodes( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getListNodesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueByAccount( + org.tron.protos.Protocol.Account request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueByAccountMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAccountNet( + org.tron.protos.Protocol.Account request) { + return futureUnaryCall( + getChannel().newCall(getGetAccountNetMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAccountResource( + org.tron.protos.Protocol.Account request) { + return futureUnaryCall( + getChannel().newCall(getGetAccountResourceMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueByName( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueByNameMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueListByName( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueListByNameMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueByIdMethod(), getCallOptions()), request); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getNowBlock( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetNowBlockMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getNowBlock2( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetNowBlock2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByNum( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByNumMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByNum2( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByNum2Method(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionCountByBlockNum( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionCountByBlockNumMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getBlockById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByIdMethod(), getCallOptions()), request); + } + + /** + *
+     *Please use GetBlockByLimitNext2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByLimitNext( + org.tron.api.GrpcAPI.BlockLimit request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByLimitNextMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetBlockByLimitNext.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByLimitNext2( + org.tron.api.GrpcAPI.BlockLimit request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByLimitNext2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use GetBlockByLatestNum2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByLatestNum( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByLatestNumMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetBlockByLatestNum.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByLatestNum2( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByLatestNum2Method(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionByIdMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture deployContract( + org.tron.protos.Contract.CreateSmartContract request) { + return futureUnaryCall( + getChannel().newCall(getDeployContractMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getContract( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetContractMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture triggerContract( + org.tron.protos.Contract.TriggerSmartContract request) { + return futureUnaryCall( + getChannel().newCall(getTriggerContractMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture triggerConstantContract( + org.tron.protos.Contract.TriggerSmartContract request) { + return futureUnaryCall( + getChannel().newCall(getTriggerConstantContractMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture clearContractABI( + org.tron.protos.Contract.ClearABIContract request) { + return futureUnaryCall( + getChannel().newCall(getClearContractABIMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture listWitnesses( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getListWitnessesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getDelegatedResource( + org.tron.api.GrpcAPI.DelegatedResourceMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetDelegatedResourceMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getDelegatedResourceAccountIndex( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetDelegatedResourceAccountIndexMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture listProposals( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getListProposalsMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getPaginatedProposalList( + org.tron.api.GrpcAPI.PaginatedMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetPaginatedProposalListMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getProposalById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetProposalByIdMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture listExchanges( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getListExchangesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getPaginatedExchangeList( + org.tron.api.GrpcAPI.PaginatedMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetPaginatedExchangeListMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getExchangeById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetExchangeByIdMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getChainParameters( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetChainParametersMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueList( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueListMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getPaginatedAssetIssueList( + org.tron.api.GrpcAPI.PaginatedMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetPaginatedAssetIssueListMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture totalTransaction( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getTotalTransactionMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getNextMaintenanceTime( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetNextMaintenanceTimeMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Please use GetTransactionSign2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getTransactionSign( + org.tron.protos.Protocol.TransactionSign request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionSignMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     *Use this function instead of GetTransactionSign.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getTransactionSign2( + org.tron.protos.Protocol.TransactionSign request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionSign2Method(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture createAddress( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getCreateAddressMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture easyTransferAsset( + org.tron.api.GrpcAPI.EasyTransferAssetMessage request) { + return futureUnaryCall( + getChannel().newCall(getEasyTransferAssetMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture easyTransferAssetByPrivate( + org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage request) { + return futureUnaryCall( + getChannel().newCall(getEasyTransferAssetByPrivateMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture easyTransfer( + org.tron.api.GrpcAPI.EasyTransferMessage request) { + return futureUnaryCall( + getChannel().newCall(getEasyTransferMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture easyTransferByPrivate( + org.tron.api.GrpcAPI.EasyTransferByPrivateMessage request) { + return futureUnaryCall( + getChannel().newCall(getEasyTransferByPrivateMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture generateAddress( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGenerateAddressMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionInfoById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionInfoByIdMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture accountPermissionUpdate( + org.tron.protos.Contract.AccountPermissionUpdateContract request) { + return futureUnaryCall( + getChannel().newCall(getAccountPermissionUpdateMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture addSign( + org.tron.protos.Protocol.TransactionSign request) { + return futureUnaryCall( + getChannel().newCall(getAddSignMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionSignWeight( + org.tron.protos.Protocol.Transaction request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionSignWeightMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionApprovedList( + org.tron.protos.Protocol.Transaction request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionApprovedListMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getNodeInfo( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetNodeInfoMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_GET_ACCOUNT = 0; + private static final int METHODID_GET_ACCOUNT_BY_ID = 1; + private static final int METHODID_CREATE_TRANSACTION = 2; + private static final int METHODID_CREATE_TRANSACTION2 = 3; + private static final int METHODID_BROADCAST_TRANSACTION = 4; + private static final int METHODID_UPDATE_ACCOUNT = 5; + private static final int METHODID_SET_ACCOUNT_ID = 6; + private static final int METHODID_UPDATE_ACCOUNT2 = 7; + private static final int METHODID_VOTE_WITNESS_ACCOUNT = 8; + private static final int METHODID_UPDATE_SETTING = 9; + private static final int METHODID_UPDATE_ENERGY_LIMIT = 10; + private static final int METHODID_VOTE_WITNESS_ACCOUNT2 = 11; + private static final int METHODID_CREATE_ASSET_ISSUE = 12; + private static final int METHODID_CREATE_ASSET_ISSUE2 = 13; + private static final int METHODID_UPDATE_WITNESS = 14; + private static final int METHODID_UPDATE_WITNESS2 = 15; + private static final int METHODID_CREATE_ACCOUNT = 16; + private static final int METHODID_CREATE_ACCOUNT2 = 17; + private static final int METHODID_CREATE_WITNESS = 18; + private static final int METHODID_CREATE_WITNESS2 = 19; + private static final int METHODID_TRANSFER_ASSET = 20; + private static final int METHODID_TRANSFER_ASSET2 = 21; + private static final int METHODID_PARTICIPATE_ASSET_ISSUE = 22; + private static final int METHODID_PARTICIPATE_ASSET_ISSUE2 = 23; + private static final int METHODID_FREEZE_BALANCE = 24; + private static final int METHODID_FREEZE_BALANCE2 = 25; + private static final int METHODID_UNFREEZE_BALANCE = 26; + private static final int METHODID_UNFREEZE_BALANCE2 = 27; + private static final int METHODID_UNFREEZE_ASSET = 28; + private static final int METHODID_UNFREEZE_ASSET2 = 29; + private static final int METHODID_WITHDRAW_BALANCE = 30; + private static final int METHODID_WITHDRAW_BALANCE2 = 31; + private static final int METHODID_UPDATE_ASSET = 32; + private static final int METHODID_UPDATE_ASSET2 = 33; + private static final int METHODID_PROPOSAL_CREATE = 34; + private static final int METHODID_PROPOSAL_APPROVE = 35; + private static final int METHODID_PROPOSAL_DELETE = 36; + private static final int METHODID_BUY_STORAGE = 37; + private static final int METHODID_BUY_STORAGE_BYTES = 38; + private static final int METHODID_SELL_STORAGE = 39; + private static final int METHODID_EXCHANGE_CREATE = 40; + private static final int METHODID_EXCHANGE_INJECT = 41; + private static final int METHODID_EXCHANGE_WITHDRAW = 42; + private static final int METHODID_EXCHANGE_TRANSACTION = 43; + private static final int METHODID_LIST_NODES = 44; + private static final int METHODID_GET_ASSET_ISSUE_BY_ACCOUNT = 45; + private static final int METHODID_GET_ACCOUNT_NET = 46; + private static final int METHODID_GET_ACCOUNT_RESOURCE = 47; + private static final int METHODID_GET_ASSET_ISSUE_BY_NAME = 48; + private static final int METHODID_GET_ASSET_ISSUE_LIST_BY_NAME = 49; + private static final int METHODID_GET_ASSET_ISSUE_BY_ID = 50; + private static final int METHODID_GET_NOW_BLOCK = 51; + private static final int METHODID_GET_NOW_BLOCK2 = 52; + private static final int METHODID_GET_BLOCK_BY_NUM = 53; + private static final int METHODID_GET_BLOCK_BY_NUM2 = 54; + private static final int METHODID_GET_TRANSACTION_COUNT_BY_BLOCK_NUM = 55; + private static final int METHODID_GET_BLOCK_BY_ID = 56; + private static final int METHODID_GET_BLOCK_BY_LIMIT_NEXT = 57; + private static final int METHODID_GET_BLOCK_BY_LIMIT_NEXT2 = 58; + private static final int METHODID_GET_BLOCK_BY_LATEST_NUM = 59; + private static final int METHODID_GET_BLOCK_BY_LATEST_NUM2 = 60; + private static final int METHODID_GET_TRANSACTION_BY_ID = 61; + private static final int METHODID_DEPLOY_CONTRACT = 62; + private static final int METHODID_GET_CONTRACT = 63; + private static final int METHODID_TRIGGER_CONTRACT = 64; + private static final int METHODID_TRIGGER_CONSTANT_CONTRACT = 65; + private static final int METHODID_CLEAR_CONTRACT_ABI = 66; + private static final int METHODID_LIST_WITNESSES = 67; + private static final int METHODID_GET_DELEGATED_RESOURCE = 68; + private static final int METHODID_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX = 69; + private static final int METHODID_LIST_PROPOSALS = 70; + private static final int METHODID_GET_PAGINATED_PROPOSAL_LIST = 71; + private static final int METHODID_GET_PROPOSAL_BY_ID = 72; + private static final int METHODID_LIST_EXCHANGES = 73; + private static final int METHODID_GET_PAGINATED_EXCHANGE_LIST = 74; + private static final int METHODID_GET_EXCHANGE_BY_ID = 75; + private static final int METHODID_GET_CHAIN_PARAMETERS = 76; + private static final int METHODID_GET_ASSET_ISSUE_LIST = 77; + private static final int METHODID_GET_PAGINATED_ASSET_ISSUE_LIST = 78; + private static final int METHODID_TOTAL_TRANSACTION = 79; + private static final int METHODID_GET_NEXT_MAINTENANCE_TIME = 80; + private static final int METHODID_GET_TRANSACTION_SIGN = 81; + private static final int METHODID_GET_TRANSACTION_SIGN2 = 82; + private static final int METHODID_CREATE_ADDRESS = 83; + private static final int METHODID_EASY_TRANSFER_ASSET = 84; + private static final int METHODID_EASY_TRANSFER_ASSET_BY_PRIVATE = 85; + private static final int METHODID_EASY_TRANSFER = 86; + private static final int METHODID_EASY_TRANSFER_BY_PRIVATE = 87; + private static final int METHODID_GENERATE_ADDRESS = 88; + private static final int METHODID_GET_TRANSACTION_INFO_BY_ID = 89; + private static final int METHODID_ACCOUNT_PERMISSION_UPDATE = 90; + private static final int METHODID_ADD_SIGN = 91; + private static final int METHODID_GET_TRANSACTION_SIGN_WEIGHT = 92; + private static final int METHODID_GET_TRANSACTION_APPROVED_LIST = 93; + private static final int METHODID_GET_NODE_INFO = 94; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final WalletImplBase serviceImpl; + private final int methodId; + + MethodHandlers(WalletImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_GET_ACCOUNT: + serviceImpl.getAccount((org.tron.protos.Protocol.Account) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ACCOUNT_BY_ID: + serviceImpl.getAccountById((org.tron.protos.Protocol.Account) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_TRANSACTION: + serviceImpl.createTransaction((org.tron.protos.Contract.TransferContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_TRANSACTION2: + serviceImpl.createTransaction2((org.tron.protos.Contract.TransferContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BROADCAST_TRANSACTION: + serviceImpl.broadcastTransaction((org.tron.protos.Protocol.Transaction) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_ACCOUNT: + serviceImpl.updateAccount((org.tron.protos.Contract.AccountUpdateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SET_ACCOUNT_ID: + serviceImpl.setAccountId((org.tron.protos.Contract.SetAccountIdContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_ACCOUNT2: + serviceImpl.updateAccount2((org.tron.protos.Contract.AccountUpdateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_VOTE_WITNESS_ACCOUNT: + serviceImpl.voteWitnessAccount((org.tron.protos.Contract.VoteWitnessContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_SETTING: + serviceImpl.updateSetting((org.tron.protos.Contract.UpdateSettingContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_ENERGY_LIMIT: + serviceImpl.updateEnergyLimit((org.tron.protos.Contract.UpdateEnergyLimitContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_VOTE_WITNESS_ACCOUNT2: + serviceImpl.voteWitnessAccount2((org.tron.protos.Contract.VoteWitnessContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_ASSET_ISSUE: + serviceImpl.createAssetIssue((org.tron.protos.Contract.AssetIssueContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_ASSET_ISSUE2: + serviceImpl.createAssetIssue2((org.tron.protos.Contract.AssetIssueContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_WITNESS: + serviceImpl.updateWitness((org.tron.protos.Contract.WitnessUpdateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_WITNESS2: + serviceImpl.updateWitness2((org.tron.protos.Contract.WitnessUpdateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_ACCOUNT: + serviceImpl.createAccount((org.tron.protos.Contract.AccountCreateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_ACCOUNT2: + serviceImpl.createAccount2((org.tron.protos.Contract.AccountCreateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_WITNESS: + serviceImpl.createWitness((org.tron.protos.Contract.WitnessCreateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_WITNESS2: + serviceImpl.createWitness2((org.tron.protos.Contract.WitnessCreateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_TRANSFER_ASSET: + serviceImpl.transferAsset((org.tron.protos.Contract.TransferAssetContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_TRANSFER_ASSET2: + serviceImpl.transferAsset2((org.tron.protos.Contract.TransferAssetContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_PARTICIPATE_ASSET_ISSUE: + serviceImpl.participateAssetIssue((org.tron.protos.Contract.ParticipateAssetIssueContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_PARTICIPATE_ASSET_ISSUE2: + serviceImpl.participateAssetIssue2((org.tron.protos.Contract.ParticipateAssetIssueContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_FREEZE_BALANCE: + serviceImpl.freezeBalance((org.tron.protos.Contract.FreezeBalanceContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_FREEZE_BALANCE2: + serviceImpl.freezeBalance2((org.tron.protos.Contract.FreezeBalanceContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UNFREEZE_BALANCE: + serviceImpl.unfreezeBalance((org.tron.protos.Contract.UnfreezeBalanceContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UNFREEZE_BALANCE2: + serviceImpl.unfreezeBalance2((org.tron.protos.Contract.UnfreezeBalanceContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UNFREEZE_ASSET: + serviceImpl.unfreezeAsset((org.tron.protos.Contract.UnfreezeAssetContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UNFREEZE_ASSET2: + serviceImpl.unfreezeAsset2((org.tron.protos.Contract.UnfreezeAssetContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_WITHDRAW_BALANCE: + serviceImpl.withdrawBalance((org.tron.protos.Contract.WithdrawBalanceContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_WITHDRAW_BALANCE2: + serviceImpl.withdrawBalance2((org.tron.protos.Contract.WithdrawBalanceContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_ASSET: + serviceImpl.updateAsset((org.tron.protos.Contract.UpdateAssetContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_ASSET2: + serviceImpl.updateAsset2((org.tron.protos.Contract.UpdateAssetContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_PROPOSAL_CREATE: + serviceImpl.proposalCreate((org.tron.protos.Contract.ProposalCreateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_PROPOSAL_APPROVE: + serviceImpl.proposalApprove((org.tron.protos.Contract.ProposalApproveContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_PROPOSAL_DELETE: + serviceImpl.proposalDelete((org.tron.protos.Contract.ProposalDeleteContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BUY_STORAGE: + serviceImpl.buyStorage((org.tron.protos.Contract.BuyStorageContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BUY_STORAGE_BYTES: + serviceImpl.buyStorageBytes((org.tron.protos.Contract.BuyStorageBytesContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SELL_STORAGE: + serviceImpl.sellStorage((org.tron.protos.Contract.SellStorageContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EXCHANGE_CREATE: + serviceImpl.exchangeCreate((org.tron.protos.Contract.ExchangeCreateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EXCHANGE_INJECT: + serviceImpl.exchangeInject((org.tron.protos.Contract.ExchangeInjectContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EXCHANGE_WITHDRAW: + serviceImpl.exchangeWithdraw((org.tron.protos.Contract.ExchangeWithdrawContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EXCHANGE_TRANSACTION: + serviceImpl.exchangeTransaction((org.tron.protos.Contract.ExchangeTransactionContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_NODES: + serviceImpl.listNodes((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_BY_ACCOUNT: + serviceImpl.getAssetIssueByAccount((org.tron.protos.Protocol.Account) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ACCOUNT_NET: + serviceImpl.getAccountNet((org.tron.protos.Protocol.Account) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ACCOUNT_RESOURCE: + serviceImpl.getAccountResource((org.tron.protos.Protocol.Account) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_BY_NAME: + serviceImpl.getAssetIssueByName((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_LIST_BY_NAME: + serviceImpl.getAssetIssueListByName((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_BY_ID: + serviceImpl.getAssetIssueById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_NOW_BLOCK: + serviceImpl.getNowBlock((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_NOW_BLOCK2: + serviceImpl.getNowBlock2((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_NUM: + serviceImpl.getBlockByNum((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_NUM2: + serviceImpl.getBlockByNum2((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_COUNT_BY_BLOCK_NUM: + serviceImpl.getTransactionCountByBlockNum((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_ID: + serviceImpl.getBlockById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_LIMIT_NEXT: + serviceImpl.getBlockByLimitNext((org.tron.api.GrpcAPI.BlockLimit) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_LIMIT_NEXT2: + serviceImpl.getBlockByLimitNext2((org.tron.api.GrpcAPI.BlockLimit) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_LATEST_NUM: + serviceImpl.getBlockByLatestNum((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_LATEST_NUM2: + serviceImpl.getBlockByLatestNum2((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_BY_ID: + serviceImpl.getTransactionById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_DEPLOY_CONTRACT: + serviceImpl.deployContract((org.tron.protos.Contract.CreateSmartContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_CONTRACT: + serviceImpl.getContract((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_TRIGGER_CONTRACT: + serviceImpl.triggerContract((org.tron.protos.Contract.TriggerSmartContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_TRIGGER_CONSTANT_CONTRACT: + serviceImpl.triggerConstantContract((org.tron.protos.Contract.TriggerSmartContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CLEAR_CONTRACT_ABI: + serviceImpl.clearContractABI((org.tron.protos.Contract.ClearABIContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_WITNESSES: + serviceImpl.listWitnesses((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_DELEGATED_RESOURCE: + serviceImpl.getDelegatedResource((org.tron.api.GrpcAPI.DelegatedResourceMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX: + serviceImpl.getDelegatedResourceAccountIndex((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_PROPOSALS: + serviceImpl.listProposals((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_PAGINATED_PROPOSAL_LIST: + serviceImpl.getPaginatedProposalList((org.tron.api.GrpcAPI.PaginatedMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_PROPOSAL_BY_ID: + serviceImpl.getProposalById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_EXCHANGES: + serviceImpl.listExchanges((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_PAGINATED_EXCHANGE_LIST: + serviceImpl.getPaginatedExchangeList((org.tron.api.GrpcAPI.PaginatedMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_EXCHANGE_BY_ID: + serviceImpl.getExchangeById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_CHAIN_PARAMETERS: + serviceImpl.getChainParameters((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_LIST: + serviceImpl.getAssetIssueList((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_PAGINATED_ASSET_ISSUE_LIST: + serviceImpl.getPaginatedAssetIssueList((org.tron.api.GrpcAPI.PaginatedMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_TOTAL_TRANSACTION: + serviceImpl.totalTransaction((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_NEXT_MAINTENANCE_TIME: + serviceImpl.getNextMaintenanceTime((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_SIGN: + serviceImpl.getTransactionSign((org.tron.protos.Protocol.TransactionSign) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_SIGN2: + serviceImpl.getTransactionSign2((org.tron.protos.Protocol.TransactionSign) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_ADDRESS: + serviceImpl.createAddress((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EASY_TRANSFER_ASSET: + serviceImpl.easyTransferAsset((org.tron.api.GrpcAPI.EasyTransferAssetMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EASY_TRANSFER_ASSET_BY_PRIVATE: + serviceImpl.easyTransferAssetByPrivate((org.tron.api.GrpcAPI.EasyTransferAssetByPrivateMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EASY_TRANSFER: + serviceImpl.easyTransfer((org.tron.api.GrpcAPI.EasyTransferMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_EASY_TRANSFER_BY_PRIVATE: + serviceImpl.easyTransferByPrivate((org.tron.api.GrpcAPI.EasyTransferByPrivateMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GENERATE_ADDRESS: + serviceImpl.generateAddress((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_INFO_BY_ID: + serviceImpl.getTransactionInfoById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_ACCOUNT_PERMISSION_UPDATE: + serviceImpl.accountPermissionUpdate((org.tron.protos.Contract.AccountPermissionUpdateContract) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_ADD_SIGN: + serviceImpl.addSign((org.tron.protos.Protocol.TransactionSign) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_SIGN_WEIGHT: + serviceImpl.getTransactionSignWeight((org.tron.protos.Protocol.Transaction) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_APPROVED_LIST: + serviceImpl.getTransactionApprovedList((org.tron.protos.Protocol.Transaction) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_NODE_INFO: + serviceImpl.getNodeInfo((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class WalletBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + WalletBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.tron.api.GrpcAPI.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("Wallet"); + } + } + + private static final class WalletFileDescriptorSupplier + extends WalletBaseDescriptorSupplier { + WalletFileDescriptorSupplier() {} + } + + private static final class WalletMethodDescriptorSupplier + extends WalletBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + WalletMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (WalletGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new WalletFileDescriptorSupplier()) + .addMethod(getGetAccountMethod()) + .addMethod(getGetAccountByIdMethod()) + .addMethod(getCreateTransactionMethod()) + .addMethod(getCreateTransaction2Method()) + .addMethod(getBroadcastTransactionMethod()) + .addMethod(getUpdateAccountMethod()) + .addMethod(getSetAccountIdMethod()) + .addMethod(getUpdateAccount2Method()) + .addMethod(getVoteWitnessAccountMethod()) + .addMethod(getUpdateSettingMethod()) + .addMethod(getUpdateEnergyLimitMethod()) + .addMethod(getVoteWitnessAccount2Method()) + .addMethod(getCreateAssetIssueMethod()) + .addMethod(getCreateAssetIssue2Method()) + .addMethod(getUpdateWitnessMethod()) + .addMethod(getUpdateWitness2Method()) + .addMethod(getCreateAccountMethod()) + .addMethod(getCreateAccount2Method()) + .addMethod(getCreateWitnessMethod()) + .addMethod(getCreateWitness2Method()) + .addMethod(getTransferAssetMethod()) + .addMethod(getTransferAsset2Method()) + .addMethod(getParticipateAssetIssueMethod()) + .addMethod(getParticipateAssetIssue2Method()) + .addMethod(getFreezeBalanceMethod()) + .addMethod(getFreezeBalance2Method()) + .addMethod(getUnfreezeBalanceMethod()) + .addMethod(getUnfreezeBalance2Method()) + .addMethod(getUnfreezeAssetMethod()) + .addMethod(getUnfreezeAsset2Method()) + .addMethod(getWithdrawBalanceMethod()) + .addMethod(getWithdrawBalance2Method()) + .addMethod(getUpdateAssetMethod()) + .addMethod(getUpdateAsset2Method()) + .addMethod(getProposalCreateMethod()) + .addMethod(getProposalApproveMethod()) + .addMethod(getProposalDeleteMethod()) + .addMethod(getBuyStorageMethod()) + .addMethod(getBuyStorageBytesMethod()) + .addMethod(getSellStorageMethod()) + .addMethod(getExchangeCreateMethod()) + .addMethod(getExchangeInjectMethod()) + .addMethod(getExchangeWithdrawMethod()) + .addMethod(getExchangeTransactionMethod()) + .addMethod(getListNodesMethod()) + .addMethod(getGetAssetIssueByAccountMethod()) + .addMethod(getGetAccountNetMethod()) + .addMethod(getGetAccountResourceMethod()) + .addMethod(getGetAssetIssueByNameMethod()) + .addMethod(getGetAssetIssueListByNameMethod()) + .addMethod(getGetAssetIssueByIdMethod()) + .addMethod(getGetNowBlockMethod()) + .addMethod(getGetNowBlock2Method()) + .addMethod(getGetBlockByNumMethod()) + .addMethod(getGetBlockByNum2Method()) + .addMethod(getGetTransactionCountByBlockNumMethod()) + .addMethod(getGetBlockByIdMethod()) + .addMethod(getGetBlockByLimitNextMethod()) + .addMethod(getGetBlockByLimitNext2Method()) + .addMethod(getGetBlockByLatestNumMethod()) + .addMethod(getGetBlockByLatestNum2Method()) + .addMethod(getGetTransactionByIdMethod()) + .addMethod(getDeployContractMethod()) + .addMethod(getGetContractMethod()) + .addMethod(getTriggerContractMethod()) + .addMethod(getTriggerConstantContractMethod()) + .addMethod(getClearContractABIMethod()) + .addMethod(getListWitnessesMethod()) + .addMethod(getGetDelegatedResourceMethod()) + .addMethod(getGetDelegatedResourceAccountIndexMethod()) + .addMethod(getListProposalsMethod()) + .addMethod(getGetPaginatedProposalListMethod()) + .addMethod(getGetProposalByIdMethod()) + .addMethod(getListExchangesMethod()) + .addMethod(getGetPaginatedExchangeListMethod()) + .addMethod(getGetExchangeByIdMethod()) + .addMethod(getGetChainParametersMethod()) + .addMethod(getGetAssetIssueListMethod()) + .addMethod(getGetPaginatedAssetIssueListMethod()) + .addMethod(getTotalTransactionMethod()) + .addMethod(getGetNextMaintenanceTimeMethod()) + .addMethod(getGetTransactionSignMethod()) + .addMethod(getGetTransactionSign2Method()) + .addMethod(getCreateAddressMethod()) + .addMethod(getEasyTransferAssetMethod()) + .addMethod(getEasyTransferAssetByPrivateMethod()) + .addMethod(getEasyTransferMethod()) + .addMethod(getEasyTransferByPrivateMethod()) + .addMethod(getGenerateAddressMethod()) + .addMethod(getGetTransactionInfoByIdMethod()) + .addMethod(getAccountPermissionUpdateMethod()) + .addMethod(getAddSignMethod()) + .addMethod(getGetTransactionSignWeightMethod()) + .addMethod(getGetTransactionApprovedListMethod()) + .addMethod(getGetNodeInfoMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/framework/src/main/gen/org/tron/api/WalletSolidityGrpc.java b/framework/src/main/gen/org/tron/api/WalletSolidityGrpc.java new file mode 100644 index 00000000000..a4eeb81bc6b --- /dev/null +++ b/framework/src/main/gen/org/tron/api/WalletSolidityGrpc.java @@ -0,0 +1,1766 @@ +package org.tron.api; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.9.0)", + comments = "Source: api/api.proto") +public final class WalletSolidityGrpc { + + private WalletSolidityGrpc() {} + + public static final String SERVICE_NAME = "protocol.WalletSolidity"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAccountMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ACCOUNT = getGetAccountMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAccountMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAccountMethod() { + io.grpc.MethodDescriptor getGetAccountMethod; + if ((getGetAccountMethod = WalletSolidityGrpc.getGetAccountMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetAccountMethod = WalletSolidityGrpc.getGetAccountMethod) == null) { + WalletSolidityGrpc.getGetAccountMethod = getGetAccountMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetAccount")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetAccount")) + .build(); + } + } + } + return getGetAccountMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAccountByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ACCOUNT_BY_ID = getGetAccountByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAccountByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAccountByIdMethod() { + io.grpc.MethodDescriptor getGetAccountByIdMethod; + if ((getGetAccountByIdMethod = WalletSolidityGrpc.getGetAccountByIdMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetAccountByIdMethod = WalletSolidityGrpc.getGetAccountByIdMethod) == null) { + WalletSolidityGrpc.getGetAccountByIdMethod = getGetAccountByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetAccountById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Account.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetAccountById")) + .build(); + } + } + } + return getGetAccountByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getListWitnessesMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_LIST_WITNESSES = getListWitnessesMethod(); + + private static volatile io.grpc.MethodDescriptor getListWitnessesMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getListWitnessesMethod() { + io.grpc.MethodDescriptor getListWitnessesMethod; + if ((getListWitnessesMethod = WalletSolidityGrpc.getListWitnessesMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getListWitnessesMethod = WalletSolidityGrpc.getListWitnessesMethod) == null) { + WalletSolidityGrpc.getListWitnessesMethod = getListWitnessesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "ListWitnesses")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.WitnessList.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("ListWitnesses")) + .build(); + } + } + } + return getListWitnessesMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueListMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_LIST = getGetAssetIssueListMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueListMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueListMethod() { + io.grpc.MethodDescriptor getGetAssetIssueListMethod; + if ((getGetAssetIssueListMethod = WalletSolidityGrpc.getGetAssetIssueListMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetAssetIssueListMethod = WalletSolidityGrpc.getGetAssetIssueListMethod) == null) { + WalletSolidityGrpc.getGetAssetIssueListMethod = getGetAssetIssueListMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetAssetIssueList")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetAssetIssueList")) + .build(); + } + } + } + return getGetAssetIssueListMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetPaginatedAssetIssueListMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_PAGINATED_ASSET_ISSUE_LIST = getGetPaginatedAssetIssueListMethod(); + + private static volatile io.grpc.MethodDescriptor getGetPaginatedAssetIssueListMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetPaginatedAssetIssueListMethod() { + io.grpc.MethodDescriptor getGetPaginatedAssetIssueListMethod; + if ((getGetPaginatedAssetIssueListMethod = WalletSolidityGrpc.getGetPaginatedAssetIssueListMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetPaginatedAssetIssueListMethod = WalletSolidityGrpc.getGetPaginatedAssetIssueListMethod) == null) { + WalletSolidityGrpc.getGetPaginatedAssetIssueListMethod = getGetPaginatedAssetIssueListMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetPaginatedAssetIssueList")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.PaginatedMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetPaginatedAssetIssueList")) + .build(); + } + } + } + return getGetPaginatedAssetIssueListMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueByNameMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_BY_NAME = getGetAssetIssueByNameMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueByNameMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueByNameMethod() { + io.grpc.MethodDescriptor getGetAssetIssueByNameMethod; + if ((getGetAssetIssueByNameMethod = WalletSolidityGrpc.getGetAssetIssueByNameMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetAssetIssueByNameMethod = WalletSolidityGrpc.getGetAssetIssueByNameMethod) == null) { + WalletSolidityGrpc.getGetAssetIssueByNameMethod = getGetAssetIssueByNameMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetAssetIssueByName")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AssetIssueContract.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetAssetIssueByName")) + .build(); + } + } + } + return getGetAssetIssueByNameMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueListByNameMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_LIST_BY_NAME = getGetAssetIssueListByNameMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueListByNameMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueListByNameMethod() { + io.grpc.MethodDescriptor getGetAssetIssueListByNameMethod; + if ((getGetAssetIssueListByNameMethod = WalletSolidityGrpc.getGetAssetIssueListByNameMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetAssetIssueListByNameMethod = WalletSolidityGrpc.getGetAssetIssueListByNameMethod) == null) { + WalletSolidityGrpc.getGetAssetIssueListByNameMethod = getGetAssetIssueListByNameMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetAssetIssueListByName")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AssetIssueList.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetAssetIssueListByName")) + .build(); + } + } + } + return getGetAssetIssueListByNameMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetAssetIssueByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_ASSET_ISSUE_BY_ID = getGetAssetIssueByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetAssetIssueByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetAssetIssueByIdMethod() { + io.grpc.MethodDescriptor getGetAssetIssueByIdMethod; + if ((getGetAssetIssueByIdMethod = WalletSolidityGrpc.getGetAssetIssueByIdMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetAssetIssueByIdMethod = WalletSolidityGrpc.getGetAssetIssueByIdMethod) == null) { + WalletSolidityGrpc.getGetAssetIssueByIdMethod = getGetAssetIssueByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetAssetIssueById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Contract.AssetIssueContract.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetAssetIssueById")) + .build(); + } + } + } + return getGetAssetIssueByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetNowBlockMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_NOW_BLOCK = getGetNowBlockMethod(); + + private static volatile io.grpc.MethodDescriptor getGetNowBlockMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetNowBlockMethod() { + io.grpc.MethodDescriptor getGetNowBlockMethod; + if ((getGetNowBlockMethod = WalletSolidityGrpc.getGetNowBlockMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetNowBlockMethod = WalletSolidityGrpc.getGetNowBlockMethod) == null) { + WalletSolidityGrpc.getGetNowBlockMethod = getGetNowBlockMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetNowBlock")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Block.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetNowBlock")) + .build(); + } + } + } + return getGetNowBlockMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetNowBlock2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_NOW_BLOCK2 = getGetNowBlock2Method(); + + private static volatile io.grpc.MethodDescriptor getGetNowBlock2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetNowBlock2Method() { + io.grpc.MethodDescriptor getGetNowBlock2Method; + if ((getGetNowBlock2Method = WalletSolidityGrpc.getGetNowBlock2Method) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetNowBlock2Method = WalletSolidityGrpc.getGetNowBlock2Method) == null) { + WalletSolidityGrpc.getGetNowBlock2Method = getGetNowBlock2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetNowBlock2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetNowBlock2")) + .build(); + } + } + } + return getGetNowBlock2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByNumMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_NUM = getGetBlockByNumMethod(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByNumMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByNumMethod() { + io.grpc.MethodDescriptor getGetBlockByNumMethod; + if ((getGetBlockByNumMethod = WalletSolidityGrpc.getGetBlockByNumMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetBlockByNumMethod = WalletSolidityGrpc.getGetBlockByNumMethod) == null) { + WalletSolidityGrpc.getGetBlockByNumMethod = getGetBlockByNumMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetBlockByNum")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Block.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetBlockByNum")) + .build(); + } + } + } + return getGetBlockByNumMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetBlockByNum2Method()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_BLOCK_BY_NUM2 = getGetBlockByNum2Method(); + + private static volatile io.grpc.MethodDescriptor getGetBlockByNum2Method; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetBlockByNum2Method() { + io.grpc.MethodDescriptor getGetBlockByNum2Method; + if ((getGetBlockByNum2Method = WalletSolidityGrpc.getGetBlockByNum2Method) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetBlockByNum2Method = WalletSolidityGrpc.getGetBlockByNum2Method) == null) { + WalletSolidityGrpc.getGetBlockByNum2Method = getGetBlockByNum2Method = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetBlockByNum2")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BlockExtention.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetBlockByNum2")) + .build(); + } + } + } + return getGetBlockByNum2Method; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionCountByBlockNumMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_COUNT_BY_BLOCK_NUM = getGetTransactionCountByBlockNumMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionCountByBlockNumMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionCountByBlockNumMethod() { + io.grpc.MethodDescriptor getGetTransactionCountByBlockNumMethod; + if ((getGetTransactionCountByBlockNumMethod = WalletSolidityGrpc.getGetTransactionCountByBlockNumMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetTransactionCountByBlockNumMethod = WalletSolidityGrpc.getGetTransactionCountByBlockNumMethod) == null) { + WalletSolidityGrpc.getGetTransactionCountByBlockNumMethod = getGetTransactionCountByBlockNumMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetTransactionCountByBlockNum")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.NumberMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetTransactionCountByBlockNum")) + .build(); + } + } + } + return getGetTransactionCountByBlockNumMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetDelegatedResourceMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_DELEGATED_RESOURCE = getGetDelegatedResourceMethod(); + + private static volatile io.grpc.MethodDescriptor getGetDelegatedResourceMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetDelegatedResourceMethod() { + io.grpc.MethodDescriptor getGetDelegatedResourceMethod; + if ((getGetDelegatedResourceMethod = WalletSolidityGrpc.getGetDelegatedResourceMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetDelegatedResourceMethod = WalletSolidityGrpc.getGetDelegatedResourceMethod) == null) { + WalletSolidityGrpc.getGetDelegatedResourceMethod = getGetDelegatedResourceMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetDelegatedResource")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.DelegatedResourceMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.DelegatedResourceList.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetDelegatedResource")) + .build(); + } + } + } + return getGetDelegatedResourceMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetDelegatedResourceAccountIndexMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX = getGetDelegatedResourceAccountIndexMethod(); + + private static volatile io.grpc.MethodDescriptor getGetDelegatedResourceAccountIndexMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetDelegatedResourceAccountIndexMethod() { + io.grpc.MethodDescriptor getGetDelegatedResourceAccountIndexMethod; + if ((getGetDelegatedResourceAccountIndexMethod = WalletSolidityGrpc.getGetDelegatedResourceAccountIndexMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetDelegatedResourceAccountIndexMethod = WalletSolidityGrpc.getGetDelegatedResourceAccountIndexMethod) == null) { + WalletSolidityGrpc.getGetDelegatedResourceAccountIndexMethod = getGetDelegatedResourceAccountIndexMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetDelegatedResourceAccountIndex")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.DelegatedResourceAccountIndex.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetDelegatedResourceAccountIndex")) + .build(); + } + } + } + return getGetDelegatedResourceAccountIndexMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetExchangeByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_EXCHANGE_BY_ID = getGetExchangeByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetExchangeByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetExchangeByIdMethod() { + io.grpc.MethodDescriptor getGetExchangeByIdMethod; + if ((getGetExchangeByIdMethod = WalletSolidityGrpc.getGetExchangeByIdMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetExchangeByIdMethod = WalletSolidityGrpc.getGetExchangeByIdMethod) == null) { + WalletSolidityGrpc.getGetExchangeByIdMethod = getGetExchangeByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetExchangeById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Exchange.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetExchangeById")) + .build(); + } + } + } + return getGetExchangeByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getListExchangesMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_LIST_EXCHANGES = getListExchangesMethod(); + + private static volatile io.grpc.MethodDescriptor getListExchangesMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getListExchangesMethod() { + io.grpc.MethodDescriptor getListExchangesMethod; + if ((getListExchangesMethod = WalletSolidityGrpc.getListExchangesMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getListExchangesMethod = WalletSolidityGrpc.getListExchangesMethod) == null) { + WalletSolidityGrpc.getListExchangesMethod = getListExchangesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "ListExchanges")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.ExchangeList.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("ListExchanges")) + .build(); + } + } + } + return getListExchangesMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_BY_ID = getGetTransactionByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionByIdMethod() { + io.grpc.MethodDescriptor getGetTransactionByIdMethod; + if ((getGetTransactionByIdMethod = WalletSolidityGrpc.getGetTransactionByIdMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetTransactionByIdMethod = WalletSolidityGrpc.getGetTransactionByIdMethod) == null) { + WalletSolidityGrpc.getGetTransactionByIdMethod = getGetTransactionByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetTransactionById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.Transaction.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetTransactionById")) + .build(); + } + } + } + return getGetTransactionByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetTransactionInfoByIdMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_TRANSACTION_INFO_BY_ID = getGetTransactionInfoByIdMethod(); + + private static volatile io.grpc.MethodDescriptor getGetTransactionInfoByIdMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetTransactionInfoByIdMethod() { + io.grpc.MethodDescriptor getGetTransactionInfoByIdMethod; + if ((getGetTransactionInfoByIdMethod = WalletSolidityGrpc.getGetTransactionInfoByIdMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGetTransactionInfoByIdMethod = WalletSolidityGrpc.getGetTransactionInfoByIdMethod) == null) { + WalletSolidityGrpc.getGetTransactionInfoByIdMethod = getGetTransactionInfoByIdMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GetTransactionInfoById")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.BytesMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.protos.Protocol.TransactionInfo.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GetTransactionInfoById")) + .build(); + } + } + } + return getGetTransactionInfoByIdMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGenerateAddressMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GENERATE_ADDRESS = getGenerateAddressMethod(); + + private static volatile io.grpc.MethodDescriptor getGenerateAddressMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGenerateAddressMethod() { + io.grpc.MethodDescriptor getGenerateAddressMethod; + if ((getGenerateAddressMethod = WalletSolidityGrpc.getGenerateAddressMethod) == null) { + synchronized (WalletSolidityGrpc.class) { + if ((getGenerateAddressMethod = WalletSolidityGrpc.getGenerateAddressMethod) == null) { + WalletSolidityGrpc.getGenerateAddressMethod = getGenerateAddressMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "protocol.WalletSolidity", "GenerateAddress")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.EmptyMessage.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.tron.api.GrpcAPI.AddressPrKeyPairMessage.getDefaultInstance())) + .setSchemaDescriptor(new WalletSolidityMethodDescriptorSupplier("GenerateAddress")) + .build(); + } + } + } + return getGenerateAddressMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static WalletSolidityStub newStub(io.grpc.Channel channel) { + return new WalletSolidityStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static WalletSolidityBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new WalletSolidityBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static WalletSolidityFutureStub newFutureStub( + io.grpc.Channel channel) { + return new WalletSolidityFutureStub(channel); + } + + /** + */ + public static abstract class WalletSolidityImplBase implements io.grpc.BindableService { + + /** + */ + public void getAccount(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAccountMethod(), responseObserver); + } + + /** + */ + public void getAccountById(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAccountByIdMethod(), responseObserver); + } + + /** + */ + public void listWitnesses(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getListWitnessesMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueList(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueListMethod(), responseObserver); + } + + /** + */ + public void getPaginatedAssetIssueList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetPaginatedAssetIssueListMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueByNameMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueListByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueListByNameMethod(), responseObserver); + } + + /** + */ + public void getAssetIssueById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetAssetIssueByIdMethod(), responseObserver); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public void getNowBlock(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetNowBlockMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public void getNowBlock2(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetNowBlock2Method(), responseObserver); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public void getBlockByNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByNumMethod(), responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public void getBlockByNum2(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetBlockByNum2Method(), responseObserver); + } + + /** + */ + public void getTransactionCountByBlockNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionCountByBlockNumMethod(), responseObserver); + } + + /** + */ + public void getDelegatedResource(org.tron.api.GrpcAPI.DelegatedResourceMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetDelegatedResourceMethod(), responseObserver); + } + + /** + */ + public void getDelegatedResourceAccountIndex(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetDelegatedResourceAccountIndexMethod(), responseObserver); + } + + /** + */ + public void getExchangeById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetExchangeByIdMethod(), responseObserver); + } + + /** + */ + public void listExchanges(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getListExchangesMethod(), responseObserver); + } + + /** + */ + public void getTransactionById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionByIdMethod(), responseObserver); + } + + /** + */ + public void getTransactionInfoById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetTransactionInfoByIdMethod(), responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void generateAddress(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGenerateAddressMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getGetAccountMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Account, + org.tron.protos.Protocol.Account>( + this, METHODID_GET_ACCOUNT))) + .addMethod( + getGetAccountByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.protos.Protocol.Account, + org.tron.protos.Protocol.Account>( + this, METHODID_GET_ACCOUNT_BY_ID))) + .addMethod( + getListWitnessesMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.WitnessList>( + this, METHODID_LIST_WITNESSES))) + .addMethod( + getGetAssetIssueListMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.AssetIssueList>( + this, METHODID_GET_ASSET_ISSUE_LIST))) + .addMethod( + getGetPaginatedAssetIssueListMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.PaginatedMessage, + org.tron.api.GrpcAPI.AssetIssueList>( + this, METHODID_GET_PAGINATED_ASSET_ISSUE_LIST))) + .addMethod( + getGetAssetIssueByNameMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Contract.AssetIssueContract>( + this, METHODID_GET_ASSET_ISSUE_BY_NAME))) + .addMethod( + getGetAssetIssueListByNameMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.api.GrpcAPI.AssetIssueList>( + this, METHODID_GET_ASSET_ISSUE_LIST_BY_NAME))) + .addMethod( + getGetAssetIssueByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Contract.AssetIssueContract>( + this, METHODID_GET_ASSET_ISSUE_BY_ID))) + .addMethod( + getGetNowBlockMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.protos.Protocol.Block>( + this, METHODID_GET_NOW_BLOCK))) + .addMethod( + getGetNowBlock2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.BlockExtention>( + this, METHODID_GET_NOW_BLOCK2))) + .addMethod( + getGetBlockByNumMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.protos.Protocol.Block>( + this, METHODID_GET_BLOCK_BY_NUM))) + .addMethod( + getGetBlockByNum2Method(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.api.GrpcAPI.BlockExtention>( + this, METHODID_GET_BLOCK_BY_NUM2))) + .addMethod( + getGetTransactionCountByBlockNumMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.NumberMessage, + org.tron.api.GrpcAPI.NumberMessage>( + this, METHODID_GET_TRANSACTION_COUNT_BY_BLOCK_NUM))) + .addMethod( + getGetDelegatedResourceMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.DelegatedResourceMessage, + org.tron.api.GrpcAPI.DelegatedResourceList>( + this, METHODID_GET_DELEGATED_RESOURCE))) + .addMethod( + getGetDelegatedResourceAccountIndexMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.DelegatedResourceAccountIndex>( + this, METHODID_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX))) + .addMethod( + getGetExchangeByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.Exchange>( + this, METHODID_GET_EXCHANGE_BY_ID))) + .addMethod( + getListExchangesMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.ExchangeList>( + this, METHODID_LIST_EXCHANGES))) + .addMethod( + getGetTransactionByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.Transaction>( + this, METHODID_GET_TRANSACTION_BY_ID))) + .addMethod( + getGetTransactionInfoByIdMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.BytesMessage, + org.tron.protos.Protocol.TransactionInfo>( + this, METHODID_GET_TRANSACTION_INFO_BY_ID))) + .addMethod( + getGenerateAddressMethod(), + asyncUnaryCall( + new MethodHandlers< + org.tron.api.GrpcAPI.EmptyMessage, + org.tron.api.GrpcAPI.AddressPrKeyPairMessage>( + this, METHODID_GENERATE_ADDRESS))) + .build(); + } + } + + /** + */ + public static final class WalletSolidityStub extends io.grpc.stub.AbstractStub { + private WalletSolidityStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletSolidityStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletSolidityStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletSolidityStub(channel, callOptions); + } + + /** + */ + public void getAccount(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAccountMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAccountById(org.tron.protos.Protocol.Account request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAccountByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listWitnesses(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListWitnessesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueList(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueListMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getPaginatedAssetIssueList(org.tron.api.GrpcAPI.PaginatedMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetPaginatedAssetIssueListMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueByNameMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueListByName(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueListByNameMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getAssetIssueById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetAssetIssueByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public void getNowBlock(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetNowBlockMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public void getNowBlock2(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetNowBlock2Method(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public void getBlockByNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByNumMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public void getBlockByNum2(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetBlockByNum2Method(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionCountByBlockNum(org.tron.api.GrpcAPI.NumberMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionCountByBlockNumMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getDelegatedResource(org.tron.api.GrpcAPI.DelegatedResourceMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetDelegatedResourceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getDelegatedResourceAccountIndex(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetDelegatedResourceAccountIndexMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getExchangeById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetExchangeByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listExchanges(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListExchangesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getTransactionInfoById(org.tron.api.GrpcAPI.BytesMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetTransactionInfoByIdMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public void generateAddress(org.tron.api.GrpcAPI.EmptyMessage request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGenerateAddressMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class WalletSolidityBlockingStub extends io.grpc.stub.AbstractStub { + private WalletSolidityBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletSolidityBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletSolidityBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletSolidityBlockingStub(channel, callOptions); + } + + /** + */ + public org.tron.protos.Protocol.Account getAccount(org.tron.protos.Protocol.Account request) { + return blockingUnaryCall( + getChannel(), getGetAccountMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Account getAccountById(org.tron.protos.Protocol.Account request) { + return blockingUnaryCall( + getChannel(), getGetAccountByIdMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.WitnessList listWitnesses(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getListWitnessesMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AssetIssueList getAssetIssueList(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueListMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AssetIssueList getPaginatedAssetIssueList(org.tron.api.GrpcAPI.PaginatedMessage request) { + return blockingUnaryCall( + getChannel(), getGetPaginatedAssetIssueListMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Contract.AssetIssueContract getAssetIssueByName(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueByNameMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.AssetIssueList getAssetIssueListByName(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueListByNameMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Contract.AssetIssueContract getAssetIssueById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetAssetIssueByIdMethod(), getCallOptions(), request); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Block getNowBlock(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetNowBlockMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockExtention getNowBlock2(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGetNowBlock2Method(), getCallOptions(), request); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public org.tron.protos.Protocol.Block getBlockByNum(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetBlockByNumMethod(), getCallOptions(), request); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public org.tron.api.GrpcAPI.BlockExtention getBlockByNum2(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetBlockByNum2Method(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.NumberMessage getTransactionCountByBlockNum(org.tron.api.GrpcAPI.NumberMessage request) { + return blockingUnaryCall( + getChannel(), getGetTransactionCountByBlockNumMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.DelegatedResourceList getDelegatedResource(org.tron.api.GrpcAPI.DelegatedResourceMessage request) { + return blockingUnaryCall( + getChannel(), getGetDelegatedResourceMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.DelegatedResourceAccountIndex getDelegatedResourceAccountIndex(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetDelegatedResourceAccountIndexMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Exchange getExchangeById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetExchangeByIdMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.api.GrpcAPI.ExchangeList listExchanges(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getListExchangesMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.Transaction getTransactionById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetTransactionByIdMethod(), getCallOptions(), request); + } + + /** + */ + public org.tron.protos.Protocol.TransactionInfo getTransactionInfoById(org.tron.api.GrpcAPI.BytesMessage request) { + return blockingUnaryCall( + getChannel(), getGetTransactionInfoByIdMethod(), getCallOptions(), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public org.tron.api.GrpcAPI.AddressPrKeyPairMessage generateAddress(org.tron.api.GrpcAPI.EmptyMessage request) { + return blockingUnaryCall( + getChannel(), getGenerateAddressMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class WalletSolidityFutureStub extends io.grpc.stub.AbstractStub { + private WalletSolidityFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private WalletSolidityFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected WalletSolidityFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new WalletSolidityFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAccount( + org.tron.protos.Protocol.Account request) { + return futureUnaryCall( + getChannel().newCall(getGetAccountMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAccountById( + org.tron.protos.Protocol.Account request) { + return futureUnaryCall( + getChannel().newCall(getGetAccountByIdMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture listWitnesses( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getListWitnessesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueList( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueListMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getPaginatedAssetIssueList( + org.tron.api.GrpcAPI.PaginatedMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetPaginatedAssetIssueListMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueByName( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueByNameMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueListByName( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueListByNameMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getAssetIssueById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetAssetIssueByIdMethod(), getCallOptions()), request); + } + + /** + *
+     *Please use GetNowBlock2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getNowBlock( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetNowBlockMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetNowBlock.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getNowBlock2( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetNowBlock2Method(), getCallOptions()), request); + } + + /** + *
+     *Please use GetBlockByNum2 instead of this function.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByNum( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByNumMethod(), getCallOptions()), request); + } + + /** + *
+     *Use this function instead of GetBlockByNum.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getBlockByNum2( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetBlockByNum2Method(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionCountByBlockNum( + org.tron.api.GrpcAPI.NumberMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionCountByBlockNumMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getDelegatedResource( + org.tron.api.GrpcAPI.DelegatedResourceMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetDelegatedResourceMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getDelegatedResourceAccountIndex( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetDelegatedResourceAccountIndexMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getExchangeById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetExchangeByIdMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture listExchanges( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getListExchangesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionByIdMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getTransactionInfoById( + org.tron.api.GrpcAPI.BytesMessage request) { + return futureUnaryCall( + getChannel().newCall(getGetTransactionInfoByIdMethod(), getCallOptions()), request); + } + + /** + *
+     *Warning: do not invoke this interface provided by others.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture generateAddress( + org.tron.api.GrpcAPI.EmptyMessage request) { + return futureUnaryCall( + getChannel().newCall(getGenerateAddressMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_GET_ACCOUNT = 0; + private static final int METHODID_GET_ACCOUNT_BY_ID = 1; + private static final int METHODID_LIST_WITNESSES = 2; + private static final int METHODID_GET_ASSET_ISSUE_LIST = 3; + private static final int METHODID_GET_PAGINATED_ASSET_ISSUE_LIST = 4; + private static final int METHODID_GET_ASSET_ISSUE_BY_NAME = 5; + private static final int METHODID_GET_ASSET_ISSUE_LIST_BY_NAME = 6; + private static final int METHODID_GET_ASSET_ISSUE_BY_ID = 7; + private static final int METHODID_GET_NOW_BLOCK = 8; + private static final int METHODID_GET_NOW_BLOCK2 = 9; + private static final int METHODID_GET_BLOCK_BY_NUM = 10; + private static final int METHODID_GET_BLOCK_BY_NUM2 = 11; + private static final int METHODID_GET_TRANSACTION_COUNT_BY_BLOCK_NUM = 12; + private static final int METHODID_GET_DELEGATED_RESOURCE = 13; + private static final int METHODID_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX = 14; + private static final int METHODID_GET_EXCHANGE_BY_ID = 15; + private static final int METHODID_LIST_EXCHANGES = 16; + private static final int METHODID_GET_TRANSACTION_BY_ID = 17; + private static final int METHODID_GET_TRANSACTION_INFO_BY_ID = 18; + private static final int METHODID_GENERATE_ADDRESS = 19; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final WalletSolidityImplBase serviceImpl; + private final int methodId; + + MethodHandlers(WalletSolidityImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_GET_ACCOUNT: + serviceImpl.getAccount((org.tron.protos.Protocol.Account) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ACCOUNT_BY_ID: + serviceImpl.getAccountById((org.tron.protos.Protocol.Account) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_WITNESSES: + serviceImpl.listWitnesses((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_LIST: + serviceImpl.getAssetIssueList((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_PAGINATED_ASSET_ISSUE_LIST: + serviceImpl.getPaginatedAssetIssueList((org.tron.api.GrpcAPI.PaginatedMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_BY_NAME: + serviceImpl.getAssetIssueByName((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_LIST_BY_NAME: + serviceImpl.getAssetIssueListByName((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_ASSET_ISSUE_BY_ID: + serviceImpl.getAssetIssueById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_NOW_BLOCK: + serviceImpl.getNowBlock((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_NOW_BLOCK2: + serviceImpl.getNowBlock2((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_NUM: + serviceImpl.getBlockByNum((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BLOCK_BY_NUM2: + serviceImpl.getBlockByNum2((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_COUNT_BY_BLOCK_NUM: + serviceImpl.getTransactionCountByBlockNum((org.tron.api.GrpcAPI.NumberMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_DELEGATED_RESOURCE: + serviceImpl.getDelegatedResource((org.tron.api.GrpcAPI.DelegatedResourceMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_DELEGATED_RESOURCE_ACCOUNT_INDEX: + serviceImpl.getDelegatedResourceAccountIndex((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_EXCHANGE_BY_ID: + serviceImpl.getExchangeById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_EXCHANGES: + serviceImpl.listExchanges((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_BY_ID: + serviceImpl.getTransactionById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_TRANSACTION_INFO_BY_ID: + serviceImpl.getTransactionInfoById((org.tron.api.GrpcAPI.BytesMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GENERATE_ADDRESS: + serviceImpl.generateAddress((org.tron.api.GrpcAPI.EmptyMessage) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class WalletSolidityBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + WalletSolidityBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.tron.api.GrpcAPI.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("WalletSolidity"); + } + } + + private static final class WalletSolidityFileDescriptorSupplier + extends WalletSolidityBaseDescriptorSupplier { + WalletSolidityFileDescriptorSupplier() {} + } + + private static final class WalletSolidityMethodDescriptorSupplier + extends WalletSolidityBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + WalletSolidityMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (WalletSolidityGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new WalletSolidityFileDescriptorSupplier()) + .addMethod(getGetAccountMethod()) + .addMethod(getGetAccountByIdMethod()) + .addMethod(getListWitnessesMethod()) + .addMethod(getGetAssetIssueListMethod()) + .addMethod(getGetPaginatedAssetIssueListMethod()) + .addMethod(getGetAssetIssueByNameMethod()) + .addMethod(getGetAssetIssueListByNameMethod()) + .addMethod(getGetAssetIssueByIdMethod()) + .addMethod(getGetNowBlockMethod()) + .addMethod(getGetNowBlock2Method()) + .addMethod(getGetBlockByNumMethod()) + .addMethod(getGetBlockByNum2Method()) + .addMethod(getGetTransactionCountByBlockNumMethod()) + .addMethod(getGetDelegatedResourceMethod()) + .addMethod(getGetDelegatedResourceAccountIndexMethod()) + .addMethod(getGetExchangeByIdMethod()) + .addMethod(getListExchangesMethod()) + .addMethod(getGetTransactionByIdMethod()) + .addMethod(getGetTransactionInfoByIdMethod()) + .addMethod(getGenerateAddressMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/framework/src/main/gen/org/tron/protos/Contract.java b/framework/src/main/gen/org/tron/protos/Contract.java new file mode 100644 index 00000000000..b1f57eeb961 --- /dev/null +++ b/framework/src/main/gen/org/tron/protos/Contract.java @@ -0,0 +1,23815 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: core/Contract.proto + +package org.tron.protos; + +public final class Contract { + private Contract() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + /** + * Protobuf enum {@code protocol.ResourceCode} + */ + public enum ResourceCode + implements com.google.protobuf.ProtocolMessageEnum { + /** + * BANDWIDTH = 0; + */ + BANDWIDTH(0), + /** + * ENERGY = 1; + */ + ENERGY(1), + UNRECOGNIZED(-1), + ; + + /** + * BANDWIDTH = 0; + */ + public static final int BANDWIDTH_VALUE = 0; + /** + * ENERGY = 1; + */ + public static final int ENERGY_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ResourceCode valueOf(int value) { + return forNumber(value); + } + + public static ResourceCode forNumber(int value) { + switch (value) { + case 0: return BANDWIDTH; + case 1: return ENERGY; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + ResourceCode> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ResourceCode findValueByNumber(int number) { + return ResourceCode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Contract.getDescriptor().getEnumTypes().get(0); + } + + private static final ResourceCode[] VALUES = values(); + + public static ResourceCode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ResourceCode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.ResourceCode) + } + + public interface AccountCreateContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AccountCreateContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes account_address = 2; + */ + com.google.protobuf.ByteString getAccountAddress(); + + /** + * .protocol.AccountType type = 3; + */ + int getTypeValue(); + /** + * .protocol.AccountType type = 3; + */ + org.tron.protos.Protocol.AccountType getType(); + } + /** + * Protobuf type {@code protocol.AccountCreateContract} + */ + public static final class AccountCreateContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AccountCreateContract) + AccountCreateContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountCreateContract.newBuilder() to construct. + private AccountCreateContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountCreateContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + accountAddress_ = com.google.protobuf.ByteString.EMPTY; + type_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountCreateContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + accountAddress_ = input.readBytes(); + break; + } + case 24: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AccountCreateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AccountCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AccountCreateContract.class, org.tron.protos.Contract.AccountCreateContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int ACCOUNT_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString accountAddress_; + /** + * bytes account_address = 2; + */ + public com.google.protobuf.ByteString getAccountAddress() { + return accountAddress_; + } + + public static final int TYPE_FIELD_NUMBER = 3; + private int type_; + /** + * .protocol.AccountType type = 3; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.AccountType type = 3; + */ + public org.tron.protos.Protocol.AccountType getType() { + org.tron.protos.Protocol.AccountType result = org.tron.protos.Protocol.AccountType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.AccountType.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!accountAddress_.isEmpty()) { + output.writeBytes(2, accountAddress_); + } + if (type_ != org.tron.protos.Protocol.AccountType.Normal.getNumber()) { + output.writeEnum(3, type_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!accountAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, accountAddress_); + } + if (type_ != org.tron.protos.Protocol.AccountType.Normal.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(3, type_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.AccountCreateContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.AccountCreateContract other = (org.tron.protos.Contract.AccountCreateContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getAccountAddress() + .equals(other.getAccountAddress()); + result = result && type_ == other.type_; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + ACCOUNT_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAccountAddress().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AccountCreateContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountCreateContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountCreateContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.AccountCreateContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AccountCreateContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AccountCreateContract) + org.tron.protos.Contract.AccountCreateContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AccountCreateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AccountCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AccountCreateContract.class, org.tron.protos.Contract.AccountCreateContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.AccountCreateContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + accountAddress_ = com.google.protobuf.ByteString.EMPTY; + + type_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_AccountCreateContract_descriptor; + } + + public org.tron.protos.Contract.AccountCreateContract getDefaultInstanceForType() { + return org.tron.protos.Contract.AccountCreateContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.AccountCreateContract build() { + org.tron.protos.Contract.AccountCreateContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.AccountCreateContract buildPartial() { + org.tron.protos.Contract.AccountCreateContract result = new org.tron.protos.Contract.AccountCreateContract(this); + result.ownerAddress_ = ownerAddress_; + result.accountAddress_ = accountAddress_; + result.type_ = type_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.AccountCreateContract) { + return mergeFrom((org.tron.protos.Contract.AccountCreateContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.AccountCreateContract other) { + if (other == org.tron.protos.Contract.AccountCreateContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getAccountAddress() != com.google.protobuf.ByteString.EMPTY) { + setAccountAddress(other.getAccountAddress()); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.AccountCreateContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.AccountCreateContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString accountAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes account_address = 2; + */ + public com.google.protobuf.ByteString getAccountAddress() { + return accountAddress_; + } + /** + * bytes account_address = 2; + */ + public Builder setAccountAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + accountAddress_ = value; + onChanged(); + return this; + } + /** + * bytes account_address = 2; + */ + public Builder clearAccountAddress() { + + accountAddress_ = getDefaultInstance().getAccountAddress(); + onChanged(); + return this; + } + + private int type_ = 0; + /** + * .protocol.AccountType type = 3; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.AccountType type = 3; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.AccountType type = 3; + */ + public org.tron.protos.Protocol.AccountType getType() { + org.tron.protos.Protocol.AccountType result = org.tron.protos.Protocol.AccountType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.AccountType.UNRECOGNIZED : result; + } + /** + * .protocol.AccountType type = 3; + */ + public Builder setType(org.tron.protos.Protocol.AccountType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.AccountType type = 3; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AccountCreateContract) + } + + // @@protoc_insertion_point(class_scope:protocol.AccountCreateContract) + private static final org.tron.protos.Contract.AccountCreateContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.AccountCreateContract(); + } + + public static org.tron.protos.Contract.AccountCreateContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountCreateContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountCreateContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.AccountCreateContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AccountUpdateContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AccountUpdateContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes account_name = 1; + */ + com.google.protobuf.ByteString getAccountName(); + + /** + * bytes owner_address = 2; + */ + com.google.protobuf.ByteString getOwnerAddress(); + } + /** + *
+   * Update account name. Account name is not unique now.
+   * 
+ * + * Protobuf type {@code protocol.AccountUpdateContract} + */ + public static final class AccountUpdateContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AccountUpdateContract) + AccountUpdateContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountUpdateContract.newBuilder() to construct. + private AccountUpdateContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountUpdateContract() { + accountName_ = com.google.protobuf.ByteString.EMPTY; + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountUpdateContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + accountName_ = input.readBytes(); + break; + } + case 18: { + + ownerAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AccountUpdateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AccountUpdateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AccountUpdateContract.class, org.tron.protos.Contract.AccountUpdateContract.Builder.class); + } + + public static final int ACCOUNT_NAME_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString accountName_; + /** + * bytes account_name = 1; + */ + public com.google.protobuf.ByteString getAccountName() { + return accountName_; + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 2; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!accountName_.isEmpty()) { + output.writeBytes(1, accountName_); + } + if (!ownerAddress_.isEmpty()) { + output.writeBytes(2, ownerAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!accountName_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, accountName_); + } + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, ownerAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.AccountUpdateContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.AccountUpdateContract other = (org.tron.protos.Contract.AccountUpdateContract) obj; + + boolean result = true; + result = result && getAccountName() + .equals(other.getAccountName()); + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ACCOUNT_NAME_FIELD_NUMBER; + hash = (53 * hash) + getAccountName().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AccountUpdateContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountUpdateContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountUpdateContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.AccountUpdateContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Update account name. Account name is not unique now.
+     * 
+ * + * Protobuf type {@code protocol.AccountUpdateContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AccountUpdateContract) + org.tron.protos.Contract.AccountUpdateContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AccountUpdateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AccountUpdateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AccountUpdateContract.class, org.tron.protos.Contract.AccountUpdateContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.AccountUpdateContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + accountName_ = com.google.protobuf.ByteString.EMPTY; + + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_AccountUpdateContract_descriptor; + } + + public org.tron.protos.Contract.AccountUpdateContract getDefaultInstanceForType() { + return org.tron.protos.Contract.AccountUpdateContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.AccountUpdateContract build() { + org.tron.protos.Contract.AccountUpdateContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.AccountUpdateContract buildPartial() { + org.tron.protos.Contract.AccountUpdateContract result = new org.tron.protos.Contract.AccountUpdateContract(this); + result.accountName_ = accountName_; + result.ownerAddress_ = ownerAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.AccountUpdateContract) { + return mergeFrom((org.tron.protos.Contract.AccountUpdateContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.AccountUpdateContract other) { + if (other == org.tron.protos.Contract.AccountUpdateContract.getDefaultInstance()) return this; + if (other.getAccountName() != com.google.protobuf.ByteString.EMPTY) { + setAccountName(other.getAccountName()); + } + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.AccountUpdateContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.AccountUpdateContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString accountName_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes account_name = 1; + */ + public com.google.protobuf.ByteString getAccountName() { + return accountName_; + } + /** + * bytes account_name = 1; + */ + public Builder setAccountName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + accountName_ = value; + onChanged(); + return this; + } + /** + * bytes account_name = 1; + */ + public Builder clearAccountName() { + + accountName_ = getDefaultInstance().getAccountName(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 2; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 2; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 2; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AccountUpdateContract) + } + + // @@protoc_insertion_point(class_scope:protocol.AccountUpdateContract) + private static final org.tron.protos.Contract.AccountUpdateContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.AccountUpdateContract(); + } + + public static org.tron.protos.Contract.AccountUpdateContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountUpdateContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountUpdateContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.AccountUpdateContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SetAccountIdContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.SetAccountIdContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes account_id = 1; + */ + com.google.protobuf.ByteString getAccountId(); + + /** + * bytes owner_address = 2; + */ + com.google.protobuf.ByteString getOwnerAddress(); + } + /** + *
+   * Set account id if the account has no id. Account id is unique and case insensitive.
+   * 
+ * + * Protobuf type {@code protocol.SetAccountIdContract} + */ + public static final class SetAccountIdContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.SetAccountIdContract) + SetAccountIdContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use SetAccountIdContract.newBuilder() to construct. + private SetAccountIdContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SetAccountIdContract() { + accountId_ = com.google.protobuf.ByteString.EMPTY; + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SetAccountIdContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + accountId_ = input.readBytes(); + break; + } + case 18: { + + ownerAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_SetAccountIdContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_SetAccountIdContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.SetAccountIdContract.class, org.tron.protos.Contract.SetAccountIdContract.Builder.class); + } + + public static final int ACCOUNT_ID_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString accountId_; + /** + * bytes account_id = 1; + */ + public com.google.protobuf.ByteString getAccountId() { + return accountId_; + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 2; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!accountId_.isEmpty()) { + output.writeBytes(1, accountId_); + } + if (!ownerAddress_.isEmpty()) { + output.writeBytes(2, ownerAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!accountId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, accountId_); + } + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, ownerAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.SetAccountIdContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.SetAccountIdContract other = (org.tron.protos.Contract.SetAccountIdContract) obj; + + boolean result = true; + result = result && getAccountId() + .equals(other.getAccountId()); + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ACCOUNT_ID_FIELD_NUMBER; + hash = (53 * hash) + getAccountId().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.SetAccountIdContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.SetAccountIdContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.SetAccountIdContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.SetAccountIdContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Set account id if the account has no id. Account id is unique and case insensitive.
+     * 
+ * + * Protobuf type {@code protocol.SetAccountIdContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.SetAccountIdContract) + org.tron.protos.Contract.SetAccountIdContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_SetAccountIdContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_SetAccountIdContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.SetAccountIdContract.class, org.tron.protos.Contract.SetAccountIdContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.SetAccountIdContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + accountId_ = com.google.protobuf.ByteString.EMPTY; + + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_SetAccountIdContract_descriptor; + } + + public org.tron.protos.Contract.SetAccountIdContract getDefaultInstanceForType() { + return org.tron.protos.Contract.SetAccountIdContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.SetAccountIdContract build() { + org.tron.protos.Contract.SetAccountIdContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.SetAccountIdContract buildPartial() { + org.tron.protos.Contract.SetAccountIdContract result = new org.tron.protos.Contract.SetAccountIdContract(this); + result.accountId_ = accountId_; + result.ownerAddress_ = ownerAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.SetAccountIdContract) { + return mergeFrom((org.tron.protos.Contract.SetAccountIdContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.SetAccountIdContract other) { + if (other == org.tron.protos.Contract.SetAccountIdContract.getDefaultInstance()) return this; + if (other.getAccountId() != com.google.protobuf.ByteString.EMPTY) { + setAccountId(other.getAccountId()); + } + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.SetAccountIdContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.SetAccountIdContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString accountId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes account_id = 1; + */ + public com.google.protobuf.ByteString getAccountId() { + return accountId_; + } + /** + * bytes account_id = 1; + */ + public Builder setAccountId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + accountId_ = value; + onChanged(); + return this; + } + /** + * bytes account_id = 1; + */ + public Builder clearAccountId() { + + accountId_ = getDefaultInstance().getAccountId(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 2; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 2; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 2; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.SetAccountIdContract) + } + + // @@protoc_insertion_point(class_scope:protocol.SetAccountIdContract) + private static final org.tron.protos.Contract.SetAccountIdContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.SetAccountIdContract(); + } + + public static org.tron.protos.Contract.SetAccountIdContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public SetAccountIdContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SetAccountIdContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.SetAccountIdContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransferContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransferContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes to_address = 2; + */ + com.google.protobuf.ByteString getToAddress(); + + /** + * int64 amount = 3; + */ + long getAmount(); + } + /** + * Protobuf type {@code protocol.TransferContract} + */ + public static final class TransferContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransferContract) + TransferContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransferContract.newBuilder() to construct. + private TransferContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransferContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + amount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransferContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + toAddress_ = input.readBytes(); + break; + } + case 24: { + + amount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_TransferContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_TransferContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.TransferContract.class, org.tron.protos.Contract.TransferContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int TO_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes to_address = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + public static final int AMOUNT_FIELD_NUMBER = 3; + private long amount_; + /** + * int64 amount = 3; + */ + public long getAmount() { + return amount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(2, toAddress_); + } + if (amount_ != 0L) { + output.writeInt64(3, amount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, toAddress_); + } + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, amount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.TransferContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.TransferContract other = (org.tron.protos.Contract.TransferContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && (getAmount() + == other.getAmount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + TO_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.TransferContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TransferContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TransferContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TransferContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TransferContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TransferContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TransferContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TransferContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.TransferContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TransferContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.TransferContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TransferContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.TransferContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransferContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransferContract) + org.tron.protos.Contract.TransferContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_TransferContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_TransferContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.TransferContract.class, org.tron.protos.Contract.TransferContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.TransferContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + amount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_TransferContract_descriptor; + } + + public org.tron.protos.Contract.TransferContract getDefaultInstanceForType() { + return org.tron.protos.Contract.TransferContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.TransferContract build() { + org.tron.protos.Contract.TransferContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.TransferContract buildPartial() { + org.tron.protos.Contract.TransferContract result = new org.tron.protos.Contract.TransferContract(this); + result.ownerAddress_ = ownerAddress_; + result.toAddress_ = toAddress_; + result.amount_ = amount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.TransferContract) { + return mergeFrom((org.tron.protos.Contract.TransferContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.TransferContract other) { + if (other == org.tron.protos.Contract.TransferContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.TransferContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.TransferContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes to_address = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes to_address = 2; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes to_address = 2; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + + private long amount_ ; + /** + * int64 amount = 3; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 3; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 3; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransferContract) + } + + // @@protoc_insertion_point(class_scope:protocol.TransferContract) + private static final org.tron.protos.Contract.TransferContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.TransferContract(); + } + + public static org.tron.protos.Contract.TransferContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransferContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransferContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.TransferContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransferAssetContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransferAssetContract) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+     * 
+ * + * bytes asset_name = 1; + */ + com.google.protobuf.ByteString getAssetName(); + + /** + * bytes owner_address = 2; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes to_address = 3; + */ + com.google.protobuf.ByteString getToAddress(); + + /** + * int64 amount = 4; + */ + long getAmount(); + } + /** + * Protobuf type {@code protocol.TransferAssetContract} + */ + public static final class TransferAssetContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransferAssetContract) + TransferAssetContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransferAssetContract.newBuilder() to construct. + private TransferAssetContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransferAssetContract() { + assetName_ = com.google.protobuf.ByteString.EMPTY; + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + amount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransferAssetContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + assetName_ = input.readBytes(); + break; + } + case 18: { + + ownerAddress_ = input.readBytes(); + break; + } + case 26: { + + toAddress_ = input.readBytes(); + break; + } + case 32: { + + amount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_TransferAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_TransferAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.TransferAssetContract.class, org.tron.protos.Contract.TransferAssetContract.Builder.class); + } + + public static final int ASSET_NAME_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString assetName_; + /** + *
+     * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+     * 
+ * + * bytes asset_name = 1; + */ + public com.google.protobuf.ByteString getAssetName() { + return assetName_; + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 2; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int TO_ADDRESS_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes to_address = 3; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + public static final int AMOUNT_FIELD_NUMBER = 4; + private long amount_; + /** + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!assetName_.isEmpty()) { + output.writeBytes(1, assetName_); + } + if (!ownerAddress_.isEmpty()) { + output.writeBytes(2, ownerAddress_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(3, toAddress_); + } + if (amount_ != 0L) { + output.writeInt64(4, amount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!assetName_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, assetName_); + } + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, ownerAddress_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, toAddress_); + } + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, amount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.TransferAssetContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.TransferAssetContract other = (org.tron.protos.Contract.TransferAssetContract) obj; + + boolean result = true; + result = result && getAssetName() + .equals(other.getAssetName()); + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && (getAmount() + == other.getAmount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ASSET_NAME_FIELD_NUMBER; + hash = (53 * hash) + getAssetName().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + TO_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.TransferAssetContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TransferAssetContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TransferAssetContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.TransferAssetContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransferAssetContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransferAssetContract) + org.tron.protos.Contract.TransferAssetContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_TransferAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_TransferAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.TransferAssetContract.class, org.tron.protos.Contract.TransferAssetContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.TransferAssetContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + assetName_ = com.google.protobuf.ByteString.EMPTY; + + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + amount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_TransferAssetContract_descriptor; + } + + public org.tron.protos.Contract.TransferAssetContract getDefaultInstanceForType() { + return org.tron.protos.Contract.TransferAssetContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.TransferAssetContract build() { + org.tron.protos.Contract.TransferAssetContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.TransferAssetContract buildPartial() { + org.tron.protos.Contract.TransferAssetContract result = new org.tron.protos.Contract.TransferAssetContract(this); + result.assetName_ = assetName_; + result.ownerAddress_ = ownerAddress_; + result.toAddress_ = toAddress_; + result.amount_ = amount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.TransferAssetContract) { + return mergeFrom((org.tron.protos.Contract.TransferAssetContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.TransferAssetContract other) { + if (other == org.tron.protos.Contract.TransferAssetContract.getDefaultInstance()) return this; + if (other.getAssetName() != com.google.protobuf.ByteString.EMPTY) { + setAssetName(other.getAssetName()); + } + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.TransferAssetContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.TransferAssetContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString assetName_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+       * 
+ * + * bytes asset_name = 1; + */ + public com.google.protobuf.ByteString getAssetName() { + return assetName_; + } + /** + *
+       * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+       * 
+ * + * bytes asset_name = 1; + */ + public Builder setAssetName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + assetName_ = value; + onChanged(); + return this; + } + /** + *
+       * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+       * 
+ * + * bytes asset_name = 1; + */ + public Builder clearAssetName() { + + assetName_ = getDefaultInstance().getAssetName(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 2; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 2; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 2; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes to_address = 3; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes to_address = 3; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes to_address = 3; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + + private long amount_ ; + /** + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 4; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 4; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransferAssetContract) + } + + // @@protoc_insertion_point(class_scope:protocol.TransferAssetContract) + private static final org.tron.protos.Contract.TransferAssetContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.TransferAssetContract(); + } + + public static org.tron.protos.Contract.TransferAssetContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransferAssetContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransferAssetContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.TransferAssetContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface VoteAssetContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.VoteAssetContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * repeated bytes vote_address = 2; + */ + java.util.List getVoteAddressList(); + /** + * repeated bytes vote_address = 2; + */ + int getVoteAddressCount(); + /** + * repeated bytes vote_address = 2; + */ + com.google.protobuf.ByteString getVoteAddress(int index); + + /** + * bool support = 3; + */ + boolean getSupport(); + + /** + * int32 count = 5; + */ + int getCount(); + } + /** + * Protobuf type {@code protocol.VoteAssetContract} + */ + public static final class VoteAssetContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.VoteAssetContract) + VoteAssetContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use VoteAssetContract.newBuilder() to construct. + private VoteAssetContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private VoteAssetContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + voteAddress_ = java.util.Collections.emptyList(); + support_ = false; + count_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private VoteAssetContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + voteAddress_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + voteAddress_.add(input.readBytes()); + break; + } + case 24: { + + support_ = input.readBool(); + break; + } + case 40: { + + count_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + voteAddress_ = java.util.Collections.unmodifiableList(voteAddress_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_VoteAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_VoteAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.VoteAssetContract.class, org.tron.protos.Contract.VoteAssetContract.Builder.class); + } + + private int bitField0_; + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int VOTE_ADDRESS_FIELD_NUMBER = 2; + private java.util.List voteAddress_; + /** + * repeated bytes vote_address = 2; + */ + public java.util.List + getVoteAddressList() { + return voteAddress_; + } + /** + * repeated bytes vote_address = 2; + */ + public int getVoteAddressCount() { + return voteAddress_.size(); + } + /** + * repeated bytes vote_address = 2; + */ + public com.google.protobuf.ByteString getVoteAddress(int index) { + return voteAddress_.get(index); + } + + public static final int SUPPORT_FIELD_NUMBER = 3; + private boolean support_; + /** + * bool support = 3; + */ + public boolean getSupport() { + return support_; + } + + public static final int COUNT_FIELD_NUMBER = 5; + private int count_; + /** + * int32 count = 5; + */ + public int getCount() { + return count_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + for (int i = 0; i < voteAddress_.size(); i++) { + output.writeBytes(2, voteAddress_.get(i)); + } + if (support_ != false) { + output.writeBool(3, support_); + } + if (count_ != 0) { + output.writeInt32(5, count_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + { + int dataSize = 0; + for (int i = 0; i < voteAddress_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(voteAddress_.get(i)); + } + size += dataSize; + size += 1 * getVoteAddressList().size(); + } + if (support_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, support_); + } + if (count_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, count_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.VoteAssetContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.VoteAssetContract other = (org.tron.protos.Contract.VoteAssetContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getVoteAddressList() + .equals(other.getVoteAddressList()); + result = result && (getSupport() + == other.getSupport()); + result = result && (getCount() + == other.getCount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + if (getVoteAddressCount() > 0) { + hash = (37 * hash) + VOTE_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getVoteAddressList().hashCode(); + } + hash = (37 * hash) + SUPPORT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getSupport()); + hash = (37 * hash) + COUNT_FIELD_NUMBER; + hash = (53 * hash) + getCount(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.VoteAssetContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteAssetContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteAssetContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.VoteAssetContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.VoteAssetContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.VoteAssetContract) + org.tron.protos.Contract.VoteAssetContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_VoteAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_VoteAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.VoteAssetContract.class, org.tron.protos.Contract.VoteAssetContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.VoteAssetContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + voteAddress_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + support_ = false; + + count_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_VoteAssetContract_descriptor; + } + + public org.tron.protos.Contract.VoteAssetContract getDefaultInstanceForType() { + return org.tron.protos.Contract.VoteAssetContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.VoteAssetContract build() { + org.tron.protos.Contract.VoteAssetContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.VoteAssetContract buildPartial() { + org.tron.protos.Contract.VoteAssetContract result = new org.tron.protos.Contract.VoteAssetContract(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.ownerAddress_ = ownerAddress_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + voteAddress_ = java.util.Collections.unmodifiableList(voteAddress_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.voteAddress_ = voteAddress_; + result.support_ = support_; + result.count_ = count_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.VoteAssetContract) { + return mergeFrom((org.tron.protos.Contract.VoteAssetContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.VoteAssetContract other) { + if (other == org.tron.protos.Contract.VoteAssetContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (!other.voteAddress_.isEmpty()) { + if (voteAddress_.isEmpty()) { + voteAddress_ = other.voteAddress_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureVoteAddressIsMutable(); + voteAddress_.addAll(other.voteAddress_); + } + onChanged(); + } + if (other.getSupport() != false) { + setSupport(other.getSupport()); + } + if (other.getCount() != 0) { + setCount(other.getCount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.VoteAssetContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.VoteAssetContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private java.util.List voteAddress_ = java.util.Collections.emptyList(); + private void ensureVoteAddressIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + voteAddress_ = new java.util.ArrayList(voteAddress_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes vote_address = 2; + */ + public java.util.List + getVoteAddressList() { + return java.util.Collections.unmodifiableList(voteAddress_); + } + /** + * repeated bytes vote_address = 2; + */ + public int getVoteAddressCount() { + return voteAddress_.size(); + } + /** + * repeated bytes vote_address = 2; + */ + public com.google.protobuf.ByteString getVoteAddress(int index) { + return voteAddress_.get(index); + } + /** + * repeated bytes vote_address = 2; + */ + public Builder setVoteAddress( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVoteAddressIsMutable(); + voteAddress_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes vote_address = 2; + */ + public Builder addVoteAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVoteAddressIsMutable(); + voteAddress_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes vote_address = 2; + */ + public Builder addAllVoteAddress( + java.lang.Iterable values) { + ensureVoteAddressIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, voteAddress_); + onChanged(); + return this; + } + /** + * repeated bytes vote_address = 2; + */ + public Builder clearVoteAddress() { + voteAddress_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private boolean support_ ; + /** + * bool support = 3; + */ + public boolean getSupport() { + return support_; + } + /** + * bool support = 3; + */ + public Builder setSupport(boolean value) { + + support_ = value; + onChanged(); + return this; + } + /** + * bool support = 3; + */ + public Builder clearSupport() { + + support_ = false; + onChanged(); + return this; + } + + private int count_ ; + /** + * int32 count = 5; + */ + public int getCount() { + return count_; + } + /** + * int32 count = 5; + */ + public Builder setCount(int value) { + + count_ = value; + onChanged(); + return this; + } + /** + * int32 count = 5; + */ + public Builder clearCount() { + + count_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.VoteAssetContract) + } + + // @@protoc_insertion_point(class_scope:protocol.VoteAssetContract) + private static final org.tron.protos.Contract.VoteAssetContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.VoteAssetContract(); + } + + public static org.tron.protos.Contract.VoteAssetContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public VoteAssetContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new VoteAssetContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.VoteAssetContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface VoteWitnessContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.VoteWitnessContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + java.util.List + getVotesList(); + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + org.tron.protos.Contract.VoteWitnessContract.Vote getVotes(int index); + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + int getVotesCount(); + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + java.util.List + getVotesOrBuilderList(); + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + org.tron.protos.Contract.VoteWitnessContract.VoteOrBuilder getVotesOrBuilder( + int index); + + /** + * bool support = 3; + */ + boolean getSupport(); + } + /** + * Protobuf type {@code protocol.VoteWitnessContract} + */ + public static final class VoteWitnessContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.VoteWitnessContract) + VoteWitnessContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use VoteWitnessContract.newBuilder() to construct. + private VoteWitnessContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private VoteWitnessContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + votes_ = java.util.Collections.emptyList(); + support_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private VoteWitnessContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + votes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + votes_.add( + input.readMessage(org.tron.protos.Contract.VoteWitnessContract.Vote.parser(), extensionRegistry)); + break; + } + case 24: { + + support_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + votes_ = java.util.Collections.unmodifiableList(votes_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.VoteWitnessContract.class, org.tron.protos.Contract.VoteWitnessContract.Builder.class); + } + + public interface VoteOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.VoteWitnessContract.Vote) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes vote_address = 1; + */ + com.google.protobuf.ByteString getVoteAddress(); + + /** + * int64 vote_count = 2; + */ + long getVoteCount(); + } + /** + * Protobuf type {@code protocol.VoteWitnessContract.Vote} + */ + public static final class Vote extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.VoteWitnessContract.Vote) + VoteOrBuilder { + private static final long serialVersionUID = 0L; + // Use Vote.newBuilder() to construct. + private Vote(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Vote() { + voteAddress_ = com.google.protobuf.ByteString.EMPTY; + voteCount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Vote( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + voteAddress_ = input.readBytes(); + break; + } + case 16: { + + voteCount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_Vote_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_Vote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.VoteWitnessContract.Vote.class, org.tron.protos.Contract.VoteWitnessContract.Vote.Builder.class); + } + + public static final int VOTE_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString voteAddress_; + /** + * bytes vote_address = 1; + */ + public com.google.protobuf.ByteString getVoteAddress() { + return voteAddress_; + } + + public static final int VOTE_COUNT_FIELD_NUMBER = 2; + private long voteCount_; + /** + * int64 vote_count = 2; + */ + public long getVoteCount() { + return voteCount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!voteAddress_.isEmpty()) { + output.writeBytes(1, voteAddress_); + } + if (voteCount_ != 0L) { + output.writeInt64(2, voteCount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!voteAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, voteAddress_); + } + if (voteCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, voteCount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.VoteWitnessContract.Vote)) { + return super.equals(obj); + } + org.tron.protos.Contract.VoteWitnessContract.Vote other = (org.tron.protos.Contract.VoteWitnessContract.Vote) obj; + + boolean result = true; + result = result && getVoteAddress() + .equals(other.getVoteAddress()); + result = result && (getVoteCount() + == other.getVoteCount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + VOTE_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getVoteAddress().hashCode(); + hash = (37 * hash) + VOTE_COUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getVoteCount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteWitnessContract.Vote parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.VoteWitnessContract.Vote prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.VoteWitnessContract.Vote} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.VoteWitnessContract.Vote) + org.tron.protos.Contract.VoteWitnessContract.VoteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_Vote_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_Vote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.VoteWitnessContract.Vote.class, org.tron.protos.Contract.VoteWitnessContract.Vote.Builder.class); + } + + // Construct using org.tron.protos.Contract.VoteWitnessContract.Vote.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + voteAddress_ = com.google.protobuf.ByteString.EMPTY; + + voteCount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_Vote_descriptor; + } + + public org.tron.protos.Contract.VoteWitnessContract.Vote getDefaultInstanceForType() { + return org.tron.protos.Contract.VoteWitnessContract.Vote.getDefaultInstance(); + } + + public org.tron.protos.Contract.VoteWitnessContract.Vote build() { + org.tron.protos.Contract.VoteWitnessContract.Vote result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.VoteWitnessContract.Vote buildPartial() { + org.tron.protos.Contract.VoteWitnessContract.Vote result = new org.tron.protos.Contract.VoteWitnessContract.Vote(this); + result.voteAddress_ = voteAddress_; + result.voteCount_ = voteCount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.VoteWitnessContract.Vote) { + return mergeFrom((org.tron.protos.Contract.VoteWitnessContract.Vote)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.VoteWitnessContract.Vote other) { + if (other == org.tron.protos.Contract.VoteWitnessContract.Vote.getDefaultInstance()) return this; + if (other.getVoteAddress() != com.google.protobuf.ByteString.EMPTY) { + setVoteAddress(other.getVoteAddress()); + } + if (other.getVoteCount() != 0L) { + setVoteCount(other.getVoteCount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.VoteWitnessContract.Vote parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.VoteWitnessContract.Vote) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString voteAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes vote_address = 1; + */ + public com.google.protobuf.ByteString getVoteAddress() { + return voteAddress_; + } + /** + * bytes vote_address = 1; + */ + public Builder setVoteAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + voteAddress_ = value; + onChanged(); + return this; + } + /** + * bytes vote_address = 1; + */ + public Builder clearVoteAddress() { + + voteAddress_ = getDefaultInstance().getVoteAddress(); + onChanged(); + return this; + } + + private long voteCount_ ; + /** + * int64 vote_count = 2; + */ + public long getVoteCount() { + return voteCount_; + } + /** + * int64 vote_count = 2; + */ + public Builder setVoteCount(long value) { + + voteCount_ = value; + onChanged(); + return this; + } + /** + * int64 vote_count = 2; + */ + public Builder clearVoteCount() { + + voteCount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.VoteWitnessContract.Vote) + } + + // @@protoc_insertion_point(class_scope:protocol.VoteWitnessContract.Vote) + private static final org.tron.protos.Contract.VoteWitnessContract.Vote DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.VoteWitnessContract.Vote(); + } + + public static org.tron.protos.Contract.VoteWitnessContract.Vote getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Vote parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Vote(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.VoteWitnessContract.Vote getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int VOTES_FIELD_NUMBER = 2; + private java.util.List votes_; + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public java.util.List getVotesList() { + return votes_; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public java.util.List + getVotesOrBuilderList() { + return votes_; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public int getVotesCount() { + return votes_.size(); + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public org.tron.protos.Contract.VoteWitnessContract.Vote getVotes(int index) { + return votes_.get(index); + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public org.tron.protos.Contract.VoteWitnessContract.VoteOrBuilder getVotesOrBuilder( + int index) { + return votes_.get(index); + } + + public static final int SUPPORT_FIELD_NUMBER = 3; + private boolean support_; + /** + * bool support = 3; + */ + public boolean getSupport() { + return support_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + for (int i = 0; i < votes_.size(); i++) { + output.writeMessage(2, votes_.get(i)); + } + if (support_ != false) { + output.writeBool(3, support_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + for (int i = 0; i < votes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, votes_.get(i)); + } + if (support_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, support_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.VoteWitnessContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.VoteWitnessContract other = (org.tron.protos.Contract.VoteWitnessContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getVotesList() + .equals(other.getVotesList()); + result = result && (getSupport() + == other.getSupport()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + if (getVotesCount() > 0) { + hash = (37 * hash) + VOTES_FIELD_NUMBER; + hash = (53 * hash) + getVotesList().hashCode(); + } + hash = (37 * hash) + SUPPORT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getSupport()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteWitnessContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.VoteWitnessContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.VoteWitnessContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.VoteWitnessContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.VoteWitnessContract) + org.tron.protos.Contract.VoteWitnessContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.VoteWitnessContract.class, org.tron.protos.Contract.VoteWitnessContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.VoteWitnessContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getVotesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + if (votesBuilder_ == null) { + votes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + votesBuilder_.clear(); + } + support_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_VoteWitnessContract_descriptor; + } + + public org.tron.protos.Contract.VoteWitnessContract getDefaultInstanceForType() { + return org.tron.protos.Contract.VoteWitnessContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.VoteWitnessContract build() { + org.tron.protos.Contract.VoteWitnessContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.VoteWitnessContract buildPartial() { + org.tron.protos.Contract.VoteWitnessContract result = new org.tron.protos.Contract.VoteWitnessContract(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.ownerAddress_ = ownerAddress_; + if (votesBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + votes_ = java.util.Collections.unmodifiableList(votes_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.votes_ = votes_; + } else { + result.votes_ = votesBuilder_.build(); + } + result.support_ = support_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.VoteWitnessContract) { + return mergeFrom((org.tron.protos.Contract.VoteWitnessContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.VoteWitnessContract other) { + if (other == org.tron.protos.Contract.VoteWitnessContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (votesBuilder_ == null) { + if (!other.votes_.isEmpty()) { + if (votes_.isEmpty()) { + votes_ = other.votes_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureVotesIsMutable(); + votes_.addAll(other.votes_); + } + onChanged(); + } + } else { + if (!other.votes_.isEmpty()) { + if (votesBuilder_.isEmpty()) { + votesBuilder_.dispose(); + votesBuilder_ = null; + votes_ = other.votes_; + bitField0_ = (bitField0_ & ~0x00000002); + votesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getVotesFieldBuilder() : null; + } else { + votesBuilder_.addAllMessages(other.votes_); + } + } + } + if (other.getSupport() != false) { + setSupport(other.getSupport()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.VoteWitnessContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.VoteWitnessContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private java.util.List votes_ = + java.util.Collections.emptyList(); + private void ensureVotesIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + votes_ = new java.util.ArrayList(votes_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.VoteWitnessContract.Vote, org.tron.protos.Contract.VoteWitnessContract.Vote.Builder, org.tron.protos.Contract.VoteWitnessContract.VoteOrBuilder> votesBuilder_; + + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public java.util.List getVotesList() { + if (votesBuilder_ == null) { + return java.util.Collections.unmodifiableList(votes_); + } else { + return votesBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public int getVotesCount() { + if (votesBuilder_ == null) { + return votes_.size(); + } else { + return votesBuilder_.getCount(); + } + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public org.tron.protos.Contract.VoteWitnessContract.Vote getVotes(int index) { + if (votesBuilder_ == null) { + return votes_.get(index); + } else { + return votesBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder setVotes( + int index, org.tron.protos.Contract.VoteWitnessContract.Vote value) { + if (votesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureVotesIsMutable(); + votes_.set(index, value); + onChanged(); + } else { + votesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder setVotes( + int index, org.tron.protos.Contract.VoteWitnessContract.Vote.Builder builderForValue) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.set(index, builderForValue.build()); + onChanged(); + } else { + votesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder addVotes(org.tron.protos.Contract.VoteWitnessContract.Vote value) { + if (votesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureVotesIsMutable(); + votes_.add(value); + onChanged(); + } else { + votesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder addVotes( + int index, org.tron.protos.Contract.VoteWitnessContract.Vote value) { + if (votesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureVotesIsMutable(); + votes_.add(index, value); + onChanged(); + } else { + votesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder addVotes( + org.tron.protos.Contract.VoteWitnessContract.Vote.Builder builderForValue) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.add(builderForValue.build()); + onChanged(); + } else { + votesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder addVotes( + int index, org.tron.protos.Contract.VoteWitnessContract.Vote.Builder builderForValue) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.add(index, builderForValue.build()); + onChanged(); + } else { + votesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder addAllVotes( + java.lang.Iterable values) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, votes_); + onChanged(); + } else { + votesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder clearVotes() { + if (votesBuilder_ == null) { + votes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + votesBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public Builder removeVotes(int index) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.remove(index); + onChanged(); + } else { + votesBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public org.tron.protos.Contract.VoteWitnessContract.Vote.Builder getVotesBuilder( + int index) { + return getVotesFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public org.tron.protos.Contract.VoteWitnessContract.VoteOrBuilder getVotesOrBuilder( + int index) { + if (votesBuilder_ == null) { + return votes_.get(index); } else { + return votesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public java.util.List + getVotesOrBuilderList() { + if (votesBuilder_ != null) { + return votesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(votes_); + } + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public org.tron.protos.Contract.VoteWitnessContract.Vote.Builder addVotesBuilder() { + return getVotesFieldBuilder().addBuilder( + org.tron.protos.Contract.VoteWitnessContract.Vote.getDefaultInstance()); + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public org.tron.protos.Contract.VoteWitnessContract.Vote.Builder addVotesBuilder( + int index) { + return getVotesFieldBuilder().addBuilder( + index, org.tron.protos.Contract.VoteWitnessContract.Vote.getDefaultInstance()); + } + /** + * repeated .protocol.VoteWitnessContract.Vote votes = 2; + */ + public java.util.List + getVotesBuilderList() { + return getVotesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.VoteWitnessContract.Vote, org.tron.protos.Contract.VoteWitnessContract.Vote.Builder, org.tron.protos.Contract.VoteWitnessContract.VoteOrBuilder> + getVotesFieldBuilder() { + if (votesBuilder_ == null) { + votesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.VoteWitnessContract.Vote, org.tron.protos.Contract.VoteWitnessContract.Vote.Builder, org.tron.protos.Contract.VoteWitnessContract.VoteOrBuilder>( + votes_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + votes_ = null; + } + return votesBuilder_; + } + + private boolean support_ ; + /** + * bool support = 3; + */ + public boolean getSupport() { + return support_; + } + /** + * bool support = 3; + */ + public Builder setSupport(boolean value) { + + support_ = value; + onChanged(); + return this; + } + /** + * bool support = 3; + */ + public Builder clearSupport() { + + support_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.VoteWitnessContract) + } + + // @@protoc_insertion_point(class_scope:protocol.VoteWitnessContract) + private static final org.tron.protos.Contract.VoteWitnessContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.VoteWitnessContract(); + } + + public static org.tron.protos.Contract.VoteWitnessContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public VoteWitnessContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new VoteWitnessContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.VoteWitnessContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface UpdateSettingContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.UpdateSettingContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes contract_address = 2; + */ + com.google.protobuf.ByteString getContractAddress(); + + /** + * int64 consume_user_resource_percent = 3; + */ + long getConsumeUserResourcePercent(); + } + /** + * Protobuf type {@code protocol.UpdateSettingContract} + */ + public static final class UpdateSettingContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.UpdateSettingContract) + UpdateSettingContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use UpdateSettingContract.newBuilder() to construct. + private UpdateSettingContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private UpdateSettingContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + consumeUserResourcePercent_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private UpdateSettingContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + contractAddress_ = input.readBytes(); + break; + } + case 24: { + + consumeUserResourcePercent_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UpdateSettingContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UpdateSettingContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UpdateSettingContract.class, org.tron.protos.Contract.UpdateSettingContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int CONTRACT_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString contractAddress_; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + + public static final int CONSUME_USER_RESOURCE_PERCENT_FIELD_NUMBER = 3; + private long consumeUserResourcePercent_; + /** + * int64 consume_user_resource_percent = 3; + */ + public long getConsumeUserResourcePercent() { + return consumeUserResourcePercent_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + output.writeBytes(2, contractAddress_); + } + if (consumeUserResourcePercent_ != 0L) { + output.writeInt64(3, consumeUserResourcePercent_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, contractAddress_); + } + if (consumeUserResourcePercent_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, consumeUserResourcePercent_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.UpdateSettingContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.UpdateSettingContract other = (org.tron.protos.Contract.UpdateSettingContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getContractAddress() + .equals(other.getContractAddress()); + result = result && (getConsumeUserResourcePercent() + == other.getConsumeUserResourcePercent()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + CONTRACT_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getContractAddress().hashCode(); + hash = (37 * hash) + CONSUME_USER_RESOURCE_PERCENT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getConsumeUserResourcePercent()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateSettingContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateSettingContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateSettingContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.UpdateSettingContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.UpdateSettingContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.UpdateSettingContract) + org.tron.protos.Contract.UpdateSettingContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UpdateSettingContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UpdateSettingContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UpdateSettingContract.class, org.tron.protos.Contract.UpdateSettingContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.UpdateSettingContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + + consumeUserResourcePercent_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_UpdateSettingContract_descriptor; + } + + public org.tron.protos.Contract.UpdateSettingContract getDefaultInstanceForType() { + return org.tron.protos.Contract.UpdateSettingContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.UpdateSettingContract build() { + org.tron.protos.Contract.UpdateSettingContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.UpdateSettingContract buildPartial() { + org.tron.protos.Contract.UpdateSettingContract result = new org.tron.protos.Contract.UpdateSettingContract(this); + result.ownerAddress_ = ownerAddress_; + result.contractAddress_ = contractAddress_; + result.consumeUserResourcePercent_ = consumeUserResourcePercent_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.UpdateSettingContract) { + return mergeFrom((org.tron.protos.Contract.UpdateSettingContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.UpdateSettingContract other) { + if (other == org.tron.protos.Contract.UpdateSettingContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getContractAddress() != com.google.protobuf.ByteString.EMPTY) { + setContractAddress(other.getContractAddress()); + } + if (other.getConsumeUserResourcePercent() != 0L) { + setConsumeUserResourcePercent(other.getConsumeUserResourcePercent()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.UpdateSettingContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.UpdateSettingContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString contractAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + /** + * bytes contract_address = 2; + */ + public Builder setContractAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + contractAddress_ = value; + onChanged(); + return this; + } + /** + * bytes contract_address = 2; + */ + public Builder clearContractAddress() { + + contractAddress_ = getDefaultInstance().getContractAddress(); + onChanged(); + return this; + } + + private long consumeUserResourcePercent_ ; + /** + * int64 consume_user_resource_percent = 3; + */ + public long getConsumeUserResourcePercent() { + return consumeUserResourcePercent_; + } + /** + * int64 consume_user_resource_percent = 3; + */ + public Builder setConsumeUserResourcePercent(long value) { + + consumeUserResourcePercent_ = value; + onChanged(); + return this; + } + /** + * int64 consume_user_resource_percent = 3; + */ + public Builder clearConsumeUserResourcePercent() { + + consumeUserResourcePercent_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.UpdateSettingContract) + } + + // @@protoc_insertion_point(class_scope:protocol.UpdateSettingContract) + private static final org.tron.protos.Contract.UpdateSettingContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.UpdateSettingContract(); + } + + public static org.tron.protos.Contract.UpdateSettingContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public UpdateSettingContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new UpdateSettingContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.UpdateSettingContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface UpdateEnergyLimitContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.UpdateEnergyLimitContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes contract_address = 2; + */ + com.google.protobuf.ByteString getContractAddress(); + + /** + * int64 origin_energy_limit = 3; + */ + long getOriginEnergyLimit(); + } + /** + * Protobuf type {@code protocol.UpdateEnergyLimitContract} + */ + public static final class UpdateEnergyLimitContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.UpdateEnergyLimitContract) + UpdateEnergyLimitContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use UpdateEnergyLimitContract.newBuilder() to construct. + private UpdateEnergyLimitContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private UpdateEnergyLimitContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + originEnergyLimit_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private UpdateEnergyLimitContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + contractAddress_ = input.readBytes(); + break; + } + case 24: { + + originEnergyLimit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UpdateEnergyLimitContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UpdateEnergyLimitContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UpdateEnergyLimitContract.class, org.tron.protos.Contract.UpdateEnergyLimitContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int CONTRACT_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString contractAddress_; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + + public static final int ORIGIN_ENERGY_LIMIT_FIELD_NUMBER = 3; + private long originEnergyLimit_; + /** + * int64 origin_energy_limit = 3; + */ + public long getOriginEnergyLimit() { + return originEnergyLimit_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + output.writeBytes(2, contractAddress_); + } + if (originEnergyLimit_ != 0L) { + output.writeInt64(3, originEnergyLimit_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, contractAddress_); + } + if (originEnergyLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, originEnergyLimit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.UpdateEnergyLimitContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.UpdateEnergyLimitContract other = (org.tron.protos.Contract.UpdateEnergyLimitContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getContractAddress() + .equals(other.getContractAddress()); + result = result && (getOriginEnergyLimit() + == other.getOriginEnergyLimit()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + CONTRACT_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getContractAddress().hashCode(); + hash = (37 * hash) + ORIGIN_ENERGY_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOriginEnergyLimit()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateEnergyLimitContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.UpdateEnergyLimitContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.UpdateEnergyLimitContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.UpdateEnergyLimitContract) + org.tron.protos.Contract.UpdateEnergyLimitContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UpdateEnergyLimitContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UpdateEnergyLimitContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UpdateEnergyLimitContract.class, org.tron.protos.Contract.UpdateEnergyLimitContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.UpdateEnergyLimitContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + + originEnergyLimit_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_UpdateEnergyLimitContract_descriptor; + } + + public org.tron.protos.Contract.UpdateEnergyLimitContract getDefaultInstanceForType() { + return org.tron.protos.Contract.UpdateEnergyLimitContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.UpdateEnergyLimitContract build() { + org.tron.protos.Contract.UpdateEnergyLimitContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.UpdateEnergyLimitContract buildPartial() { + org.tron.protos.Contract.UpdateEnergyLimitContract result = new org.tron.protos.Contract.UpdateEnergyLimitContract(this); + result.ownerAddress_ = ownerAddress_; + result.contractAddress_ = contractAddress_; + result.originEnergyLimit_ = originEnergyLimit_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.UpdateEnergyLimitContract) { + return mergeFrom((org.tron.protos.Contract.UpdateEnergyLimitContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.UpdateEnergyLimitContract other) { + if (other == org.tron.protos.Contract.UpdateEnergyLimitContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getContractAddress() != com.google.protobuf.ByteString.EMPTY) { + setContractAddress(other.getContractAddress()); + } + if (other.getOriginEnergyLimit() != 0L) { + setOriginEnergyLimit(other.getOriginEnergyLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.UpdateEnergyLimitContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.UpdateEnergyLimitContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString contractAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + /** + * bytes contract_address = 2; + */ + public Builder setContractAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + contractAddress_ = value; + onChanged(); + return this; + } + /** + * bytes contract_address = 2; + */ + public Builder clearContractAddress() { + + contractAddress_ = getDefaultInstance().getContractAddress(); + onChanged(); + return this; + } + + private long originEnergyLimit_ ; + /** + * int64 origin_energy_limit = 3; + */ + public long getOriginEnergyLimit() { + return originEnergyLimit_; + } + /** + * int64 origin_energy_limit = 3; + */ + public Builder setOriginEnergyLimit(long value) { + + originEnergyLimit_ = value; + onChanged(); + return this; + } + /** + * int64 origin_energy_limit = 3; + */ + public Builder clearOriginEnergyLimit() { + + originEnergyLimit_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.UpdateEnergyLimitContract) + } + + // @@protoc_insertion_point(class_scope:protocol.UpdateEnergyLimitContract) + private static final org.tron.protos.Contract.UpdateEnergyLimitContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.UpdateEnergyLimitContract(); + } + + public static org.tron.protos.Contract.UpdateEnergyLimitContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public UpdateEnergyLimitContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new UpdateEnergyLimitContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.UpdateEnergyLimitContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ClearABIContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ClearABIContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes contract_address = 2; + */ + com.google.protobuf.ByteString getContractAddress(); + } + /** + * Protobuf type {@code protocol.ClearABIContract} + */ + public static final class ClearABIContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ClearABIContract) + ClearABIContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ClearABIContract.newBuilder() to construct. + private ClearABIContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ClearABIContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ClearABIContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + contractAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ClearABIContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ClearABIContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ClearABIContract.class, org.tron.protos.Contract.ClearABIContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int CONTRACT_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString contractAddress_; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + output.writeBytes(2, contractAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, contractAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ClearABIContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ClearABIContract other = (org.tron.protos.Contract.ClearABIContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getContractAddress() + .equals(other.getContractAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + CONTRACT_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getContractAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ClearABIContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ClearABIContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ClearABIContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ClearABIContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ClearABIContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ClearABIContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ClearABIContract) + org.tron.protos.Contract.ClearABIContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ClearABIContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ClearABIContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ClearABIContract.class, org.tron.protos.Contract.ClearABIContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ClearABIContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ClearABIContract_descriptor; + } + + public org.tron.protos.Contract.ClearABIContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ClearABIContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ClearABIContract build() { + org.tron.protos.Contract.ClearABIContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ClearABIContract buildPartial() { + org.tron.protos.Contract.ClearABIContract result = new org.tron.protos.Contract.ClearABIContract(this); + result.ownerAddress_ = ownerAddress_; + result.contractAddress_ = contractAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ClearABIContract) { + return mergeFrom((org.tron.protos.Contract.ClearABIContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ClearABIContract other) { + if (other == org.tron.protos.Contract.ClearABIContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getContractAddress() != com.google.protobuf.ByteString.EMPTY) { + setContractAddress(other.getContractAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ClearABIContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ClearABIContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString contractAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + /** + * bytes contract_address = 2; + */ + public Builder setContractAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + contractAddress_ = value; + onChanged(); + return this; + } + /** + * bytes contract_address = 2; + */ + public Builder clearContractAddress() { + + contractAddress_ = getDefaultInstance().getContractAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ClearABIContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ClearABIContract) + private static final org.tron.protos.Contract.ClearABIContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ClearABIContract(); + } + + public static org.tron.protos.Contract.ClearABIContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ClearABIContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ClearABIContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ClearABIContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface WitnessCreateContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.WitnessCreateContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes url = 2; + */ + com.google.protobuf.ByteString getUrl(); + } + /** + * Protobuf type {@code protocol.WitnessCreateContract} + */ + public static final class WitnessCreateContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.WitnessCreateContract) + WitnessCreateContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use WitnessCreateContract.newBuilder() to construct. + private WitnessCreateContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private WitnessCreateContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + url_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private WitnessCreateContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + url_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_WitnessCreateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_WitnessCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.WitnessCreateContract.class, org.tron.protos.Contract.WitnessCreateContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int URL_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString url_; + /** + * bytes url = 2; + */ + public com.google.protobuf.ByteString getUrl() { + return url_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!url_.isEmpty()) { + output.writeBytes(2, url_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!url_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, url_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.WitnessCreateContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.WitnessCreateContract other = (org.tron.protos.Contract.WitnessCreateContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessCreateContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WitnessCreateContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WitnessCreateContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.WitnessCreateContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.WitnessCreateContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.WitnessCreateContract) + org.tron.protos.Contract.WitnessCreateContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_WitnessCreateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_WitnessCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.WitnessCreateContract.class, org.tron.protos.Contract.WitnessCreateContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.WitnessCreateContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + url_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_WitnessCreateContract_descriptor; + } + + public org.tron.protos.Contract.WitnessCreateContract getDefaultInstanceForType() { + return org.tron.protos.Contract.WitnessCreateContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.WitnessCreateContract build() { + org.tron.protos.Contract.WitnessCreateContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.WitnessCreateContract buildPartial() { + org.tron.protos.Contract.WitnessCreateContract result = new org.tron.protos.Contract.WitnessCreateContract(this); + result.ownerAddress_ = ownerAddress_; + result.url_ = url_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.WitnessCreateContract) { + return mergeFrom((org.tron.protos.Contract.WitnessCreateContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.WitnessCreateContract other) { + if (other == org.tron.protos.Contract.WitnessCreateContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getUrl() != com.google.protobuf.ByteString.EMPTY) { + setUrl(other.getUrl()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.WitnessCreateContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.WitnessCreateContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString url_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes url = 2; + */ + public com.google.protobuf.ByteString getUrl() { + return url_; + } + /** + * bytes url = 2; + */ + public Builder setUrl(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * bytes url = 2; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.WitnessCreateContract) + } + + // @@protoc_insertion_point(class_scope:protocol.WitnessCreateContract) + private static final org.tron.protos.Contract.WitnessCreateContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.WitnessCreateContract(); + } + + public static org.tron.protos.Contract.WitnessCreateContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public WitnessCreateContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new WitnessCreateContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.WitnessCreateContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface WitnessUpdateContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.WitnessUpdateContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes update_url = 12; + */ + com.google.protobuf.ByteString getUpdateUrl(); + } + /** + * Protobuf type {@code protocol.WitnessUpdateContract} + */ + public static final class WitnessUpdateContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.WitnessUpdateContract) + WitnessUpdateContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use WitnessUpdateContract.newBuilder() to construct. + private WitnessUpdateContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private WitnessUpdateContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + updateUrl_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private WitnessUpdateContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 98: { + + updateUrl_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_WitnessUpdateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_WitnessUpdateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.WitnessUpdateContract.class, org.tron.protos.Contract.WitnessUpdateContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int UPDATE_URL_FIELD_NUMBER = 12; + private com.google.protobuf.ByteString updateUrl_; + /** + * bytes update_url = 12; + */ + public com.google.protobuf.ByteString getUpdateUrl() { + return updateUrl_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!updateUrl_.isEmpty()) { + output.writeBytes(12, updateUrl_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!updateUrl_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(12, updateUrl_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.WitnessUpdateContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.WitnessUpdateContract other = (org.tron.protos.Contract.WitnessUpdateContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getUpdateUrl() + .equals(other.getUpdateUrl()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + UPDATE_URL_FIELD_NUMBER; + hash = (53 * hash) + getUpdateUrl().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WitnessUpdateContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.WitnessUpdateContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.WitnessUpdateContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.WitnessUpdateContract) + org.tron.protos.Contract.WitnessUpdateContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_WitnessUpdateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_WitnessUpdateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.WitnessUpdateContract.class, org.tron.protos.Contract.WitnessUpdateContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.WitnessUpdateContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + updateUrl_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_WitnessUpdateContract_descriptor; + } + + public org.tron.protos.Contract.WitnessUpdateContract getDefaultInstanceForType() { + return org.tron.protos.Contract.WitnessUpdateContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.WitnessUpdateContract build() { + org.tron.protos.Contract.WitnessUpdateContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.WitnessUpdateContract buildPartial() { + org.tron.protos.Contract.WitnessUpdateContract result = new org.tron.protos.Contract.WitnessUpdateContract(this); + result.ownerAddress_ = ownerAddress_; + result.updateUrl_ = updateUrl_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.WitnessUpdateContract) { + return mergeFrom((org.tron.protos.Contract.WitnessUpdateContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.WitnessUpdateContract other) { + if (other == org.tron.protos.Contract.WitnessUpdateContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getUpdateUrl() != com.google.protobuf.ByteString.EMPTY) { + setUpdateUrl(other.getUpdateUrl()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.WitnessUpdateContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.WitnessUpdateContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString updateUrl_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes update_url = 12; + */ + public com.google.protobuf.ByteString getUpdateUrl() { + return updateUrl_; + } + /** + * bytes update_url = 12; + */ + public Builder setUpdateUrl(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + updateUrl_ = value; + onChanged(); + return this; + } + /** + * bytes update_url = 12; + */ + public Builder clearUpdateUrl() { + + updateUrl_ = getDefaultInstance().getUpdateUrl(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.WitnessUpdateContract) + } + + // @@protoc_insertion_point(class_scope:protocol.WitnessUpdateContract) + private static final org.tron.protos.Contract.WitnessUpdateContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.WitnessUpdateContract(); + } + + public static org.tron.protos.Contract.WitnessUpdateContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public WitnessUpdateContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new WitnessUpdateContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.WitnessUpdateContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AssetIssueContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AssetIssueContract) + com.google.protobuf.MessageOrBuilder { + + /** + * string id = 41; + */ + java.lang.String getId(); + /** + * string id = 41; + */ + com.google.protobuf.ByteString + getIdBytes(); + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes name = 2; + */ + com.google.protobuf.ByteString getName(); + + /** + * bytes abbr = 3; + */ + com.google.protobuf.ByteString getAbbr(); + + /** + * int64 total_supply = 4; + */ + long getTotalSupply(); + + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + java.util.List + getFrozenSupplyList(); + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + org.tron.protos.Contract.AssetIssueContract.FrozenSupply getFrozenSupply(int index); + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + int getFrozenSupplyCount(); + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + java.util.List + getFrozenSupplyOrBuilderList(); + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + org.tron.protos.Contract.AssetIssueContract.FrozenSupplyOrBuilder getFrozenSupplyOrBuilder( + int index); + + /** + * int32 trx_num = 6; + */ + int getTrxNum(); + + /** + * int32 precision = 7; + */ + int getPrecision(); + + /** + * int32 num = 8; + */ + int getNum(); + + /** + * int64 start_time = 9; + */ + long getStartTime(); + + /** + * int64 end_time = 10; + */ + long getEndTime(); + + /** + *
+     * useless
+     * 
+ * + * int64 order = 11; + */ + long getOrder(); + + /** + * int32 vote_score = 16; + */ + int getVoteScore(); + + /** + * bytes description = 20; + */ + com.google.protobuf.ByteString getDescription(); + + /** + * bytes url = 21; + */ + com.google.protobuf.ByteString getUrl(); + + /** + * int64 free_asset_net_limit = 22; + */ + long getFreeAssetNetLimit(); + + /** + * int64 public_free_asset_net_limit = 23; + */ + long getPublicFreeAssetNetLimit(); + + /** + * int64 public_free_asset_net_usage = 24; + */ + long getPublicFreeAssetNetUsage(); + + /** + * int64 public_latest_free_net_time = 25; + */ + long getPublicLatestFreeNetTime(); + } + /** + * Protobuf type {@code protocol.AssetIssueContract} + */ + public static final class AssetIssueContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AssetIssueContract) + AssetIssueContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use AssetIssueContract.newBuilder() to construct. + private AssetIssueContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AssetIssueContract() { + id_ = ""; + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + name_ = com.google.protobuf.ByteString.EMPTY; + abbr_ = com.google.protobuf.ByteString.EMPTY; + totalSupply_ = 0L; + frozenSupply_ = java.util.Collections.emptyList(); + trxNum_ = 0; + precision_ = 0; + num_ = 0; + startTime_ = 0L; + endTime_ = 0L; + order_ = 0L; + voteScore_ = 0; + description_ = com.google.protobuf.ByteString.EMPTY; + url_ = com.google.protobuf.ByteString.EMPTY; + freeAssetNetLimit_ = 0L; + publicFreeAssetNetLimit_ = 0L; + publicFreeAssetNetUsage_ = 0L; + publicLatestFreeNetTime_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AssetIssueContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + name_ = input.readBytes(); + break; + } + case 26: { + + abbr_ = input.readBytes(); + break; + } + case 32: { + + totalSupply_ = input.readInt64(); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + frozenSupply_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + frozenSupply_.add( + input.readMessage(org.tron.protos.Contract.AssetIssueContract.FrozenSupply.parser(), extensionRegistry)); + break; + } + case 48: { + + trxNum_ = input.readInt32(); + break; + } + case 56: { + + precision_ = input.readInt32(); + break; + } + case 64: { + + num_ = input.readInt32(); + break; + } + case 72: { + + startTime_ = input.readInt64(); + break; + } + case 80: { + + endTime_ = input.readInt64(); + break; + } + case 88: { + + order_ = input.readInt64(); + break; + } + case 128: { + + voteScore_ = input.readInt32(); + break; + } + case 162: { + + description_ = input.readBytes(); + break; + } + case 170: { + + url_ = input.readBytes(); + break; + } + case 176: { + + freeAssetNetLimit_ = input.readInt64(); + break; + } + case 184: { + + publicFreeAssetNetLimit_ = input.readInt64(); + break; + } + case 192: { + + publicFreeAssetNetUsage_ = input.readInt64(); + break; + } + case 200: { + + publicLatestFreeNetTime_ = input.readInt64(); + break; + } + case 330: { + java.lang.String s = input.readStringRequireUtf8(); + + id_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + frozenSupply_ = java.util.Collections.unmodifiableList(frozenSupply_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AssetIssueContract.class, org.tron.protos.Contract.AssetIssueContract.Builder.class); + } + + public interface FrozenSupplyOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AssetIssueContract.FrozenSupply) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 frozen_amount = 1; + */ + long getFrozenAmount(); + + /** + * int64 frozen_days = 2; + */ + long getFrozenDays(); + } + /** + * Protobuf type {@code protocol.AssetIssueContract.FrozenSupply} + */ + public static final class FrozenSupply extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AssetIssueContract.FrozenSupply) + FrozenSupplyOrBuilder { + private static final long serialVersionUID = 0L; + // Use FrozenSupply.newBuilder() to construct. + private FrozenSupply(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private FrozenSupply() { + frozenAmount_ = 0L; + frozenDays_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private FrozenSupply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + frozenAmount_ = input.readInt64(); + break; + } + case 16: { + + frozenDays_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_FrozenSupply_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_FrozenSupply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AssetIssueContract.FrozenSupply.class, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder.class); + } + + public static final int FROZEN_AMOUNT_FIELD_NUMBER = 1; + private long frozenAmount_; + /** + * int64 frozen_amount = 1; + */ + public long getFrozenAmount() { + return frozenAmount_; + } + + public static final int FROZEN_DAYS_FIELD_NUMBER = 2; + private long frozenDays_; + /** + * int64 frozen_days = 2; + */ + public long getFrozenDays() { + return frozenDays_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (frozenAmount_ != 0L) { + output.writeInt64(1, frozenAmount_); + } + if (frozenDays_ != 0L) { + output.writeInt64(2, frozenDays_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (frozenAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, frozenAmount_); + } + if (frozenDays_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, frozenDays_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.AssetIssueContract.FrozenSupply)) { + return super.equals(obj); + } + org.tron.protos.Contract.AssetIssueContract.FrozenSupply other = (org.tron.protos.Contract.AssetIssueContract.FrozenSupply) obj; + + boolean result = true; + result = result && (getFrozenAmount() + == other.getFrozenAmount()); + result = result && (getFrozenDays() + == other.getFrozenDays()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FROZEN_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFrozenAmount()); + hash = (37 * hash) + FROZEN_DAYS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFrozenDays()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.AssetIssueContract.FrozenSupply prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AssetIssueContract.FrozenSupply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AssetIssueContract.FrozenSupply) + org.tron.protos.Contract.AssetIssueContract.FrozenSupplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_FrozenSupply_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_FrozenSupply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AssetIssueContract.FrozenSupply.class, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder.class); + } + + // Construct using org.tron.protos.Contract.AssetIssueContract.FrozenSupply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + frozenAmount_ = 0L; + + frozenDays_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_FrozenSupply_descriptor; + } + + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply getDefaultInstanceForType() { + return org.tron.protos.Contract.AssetIssueContract.FrozenSupply.getDefaultInstance(); + } + + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply build() { + org.tron.protos.Contract.AssetIssueContract.FrozenSupply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply buildPartial() { + org.tron.protos.Contract.AssetIssueContract.FrozenSupply result = new org.tron.protos.Contract.AssetIssueContract.FrozenSupply(this); + result.frozenAmount_ = frozenAmount_; + result.frozenDays_ = frozenDays_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.AssetIssueContract.FrozenSupply) { + return mergeFrom((org.tron.protos.Contract.AssetIssueContract.FrozenSupply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.AssetIssueContract.FrozenSupply other) { + if (other == org.tron.protos.Contract.AssetIssueContract.FrozenSupply.getDefaultInstance()) return this; + if (other.getFrozenAmount() != 0L) { + setFrozenAmount(other.getFrozenAmount()); + } + if (other.getFrozenDays() != 0L) { + setFrozenDays(other.getFrozenDays()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.AssetIssueContract.FrozenSupply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.AssetIssueContract.FrozenSupply) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long frozenAmount_ ; + /** + * int64 frozen_amount = 1; + */ + public long getFrozenAmount() { + return frozenAmount_; + } + /** + * int64 frozen_amount = 1; + */ + public Builder setFrozenAmount(long value) { + + frozenAmount_ = value; + onChanged(); + return this; + } + /** + * int64 frozen_amount = 1; + */ + public Builder clearFrozenAmount() { + + frozenAmount_ = 0L; + onChanged(); + return this; + } + + private long frozenDays_ ; + /** + * int64 frozen_days = 2; + */ + public long getFrozenDays() { + return frozenDays_; + } + /** + * int64 frozen_days = 2; + */ + public Builder setFrozenDays(long value) { + + frozenDays_ = value; + onChanged(); + return this; + } + /** + * int64 frozen_days = 2; + */ + public Builder clearFrozenDays() { + + frozenDays_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AssetIssueContract.FrozenSupply) + } + + // @@protoc_insertion_point(class_scope:protocol.AssetIssueContract.FrozenSupply) + private static final org.tron.protos.Contract.AssetIssueContract.FrozenSupply DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.AssetIssueContract.FrozenSupply(); + } + + public static org.tron.protos.Contract.AssetIssueContract.FrozenSupply getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public FrozenSupply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new FrozenSupply(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int ID_FIELD_NUMBER = 41; + private volatile java.lang.Object id_; + /** + * string id = 41; + */ + public java.lang.String getId() { + java.lang.Object ref = id_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + id_ = s; + return s; + } + } + /** + * string id = 41; + */ + public com.google.protobuf.ByteString + getIdBytes() { + java.lang.Object ref = id_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int NAME_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString name_; + /** + * bytes name = 2; + */ + public com.google.protobuf.ByteString getName() { + return name_; + } + + public static final int ABBR_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString abbr_; + /** + * bytes abbr = 3; + */ + public com.google.protobuf.ByteString getAbbr() { + return abbr_; + } + + public static final int TOTAL_SUPPLY_FIELD_NUMBER = 4; + private long totalSupply_; + /** + * int64 total_supply = 4; + */ + public long getTotalSupply() { + return totalSupply_; + } + + public static final int FROZEN_SUPPLY_FIELD_NUMBER = 5; + private java.util.List frozenSupply_; + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public java.util.List getFrozenSupplyList() { + return frozenSupply_; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public java.util.List + getFrozenSupplyOrBuilderList() { + return frozenSupply_; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public int getFrozenSupplyCount() { + return frozenSupply_.size(); + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply getFrozenSupply(int index) { + return frozenSupply_.get(index); + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public org.tron.protos.Contract.AssetIssueContract.FrozenSupplyOrBuilder getFrozenSupplyOrBuilder( + int index) { + return frozenSupply_.get(index); + } + + public static final int TRX_NUM_FIELD_NUMBER = 6; + private int trxNum_; + /** + * int32 trx_num = 6; + */ + public int getTrxNum() { + return trxNum_; + } + + public static final int PRECISION_FIELD_NUMBER = 7; + private int precision_; + /** + * int32 precision = 7; + */ + public int getPrecision() { + return precision_; + } + + public static final int NUM_FIELD_NUMBER = 8; + private int num_; + /** + * int32 num = 8; + */ + public int getNum() { + return num_; + } + + public static final int START_TIME_FIELD_NUMBER = 9; + private long startTime_; + /** + * int64 start_time = 9; + */ + public long getStartTime() { + return startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 10; + private long endTime_; + /** + * int64 end_time = 10; + */ + public long getEndTime() { + return endTime_; + } + + public static final int ORDER_FIELD_NUMBER = 11; + private long order_; + /** + *
+     * useless
+     * 
+ * + * int64 order = 11; + */ + public long getOrder() { + return order_; + } + + public static final int VOTE_SCORE_FIELD_NUMBER = 16; + private int voteScore_; + /** + * int32 vote_score = 16; + */ + public int getVoteScore() { + return voteScore_; + } + + public static final int DESCRIPTION_FIELD_NUMBER = 20; + private com.google.protobuf.ByteString description_; + /** + * bytes description = 20; + */ + public com.google.protobuf.ByteString getDescription() { + return description_; + } + + public static final int URL_FIELD_NUMBER = 21; + private com.google.protobuf.ByteString url_; + /** + * bytes url = 21; + */ + public com.google.protobuf.ByteString getUrl() { + return url_; + } + + public static final int FREE_ASSET_NET_LIMIT_FIELD_NUMBER = 22; + private long freeAssetNetLimit_; + /** + * int64 free_asset_net_limit = 22; + */ + public long getFreeAssetNetLimit() { + return freeAssetNetLimit_; + } + + public static final int PUBLIC_FREE_ASSET_NET_LIMIT_FIELD_NUMBER = 23; + private long publicFreeAssetNetLimit_; + /** + * int64 public_free_asset_net_limit = 23; + */ + public long getPublicFreeAssetNetLimit() { + return publicFreeAssetNetLimit_; + } + + public static final int PUBLIC_FREE_ASSET_NET_USAGE_FIELD_NUMBER = 24; + private long publicFreeAssetNetUsage_; + /** + * int64 public_free_asset_net_usage = 24; + */ + public long getPublicFreeAssetNetUsage() { + return publicFreeAssetNetUsage_; + } + + public static final int PUBLIC_LATEST_FREE_NET_TIME_FIELD_NUMBER = 25; + private long publicLatestFreeNetTime_; + /** + * int64 public_latest_free_net_time = 25; + */ + public long getPublicLatestFreeNetTime() { + return publicLatestFreeNetTime_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!name_.isEmpty()) { + output.writeBytes(2, name_); + } + if (!abbr_.isEmpty()) { + output.writeBytes(3, abbr_); + } + if (totalSupply_ != 0L) { + output.writeInt64(4, totalSupply_); + } + for (int i = 0; i < frozenSupply_.size(); i++) { + output.writeMessage(5, frozenSupply_.get(i)); + } + if (trxNum_ != 0) { + output.writeInt32(6, trxNum_); + } + if (precision_ != 0) { + output.writeInt32(7, precision_); + } + if (num_ != 0) { + output.writeInt32(8, num_); + } + if (startTime_ != 0L) { + output.writeInt64(9, startTime_); + } + if (endTime_ != 0L) { + output.writeInt64(10, endTime_); + } + if (order_ != 0L) { + output.writeInt64(11, order_); + } + if (voteScore_ != 0) { + output.writeInt32(16, voteScore_); + } + if (!description_.isEmpty()) { + output.writeBytes(20, description_); + } + if (!url_.isEmpty()) { + output.writeBytes(21, url_); + } + if (freeAssetNetLimit_ != 0L) { + output.writeInt64(22, freeAssetNetLimit_); + } + if (publicFreeAssetNetLimit_ != 0L) { + output.writeInt64(23, publicFreeAssetNetLimit_); + } + if (publicFreeAssetNetUsage_ != 0L) { + output.writeInt64(24, publicFreeAssetNetUsage_); + } + if (publicLatestFreeNetTime_ != 0L) { + output.writeInt64(25, publicLatestFreeNetTime_); + } + if (!getIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 41, id_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!name_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, name_); + } + if (!abbr_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, abbr_); + } + if (totalSupply_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, totalSupply_); + } + for (int i = 0; i < frozenSupply_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, frozenSupply_.get(i)); + } + if (trxNum_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(6, trxNum_); + } + if (precision_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(7, precision_); + } + if (num_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(8, num_); + } + if (startTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(9, startTime_); + } + if (endTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(10, endTime_); + } + if (order_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(11, order_); + } + if (voteScore_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(16, voteScore_); + } + if (!description_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(20, description_); + } + if (!url_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(21, url_); + } + if (freeAssetNetLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(22, freeAssetNetLimit_); + } + if (publicFreeAssetNetLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(23, publicFreeAssetNetLimit_); + } + if (publicFreeAssetNetUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(24, publicFreeAssetNetUsage_); + } + if (publicLatestFreeNetTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(25, publicLatestFreeNetTime_); + } + if (!getIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(41, id_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.AssetIssueContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.AssetIssueContract other = (org.tron.protos.Contract.AssetIssueContract) obj; + + boolean result = true; + result = result && getId() + .equals(other.getId()); + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getName() + .equals(other.getName()); + result = result && getAbbr() + .equals(other.getAbbr()); + result = result && (getTotalSupply() + == other.getTotalSupply()); + result = result && getFrozenSupplyList() + .equals(other.getFrozenSupplyList()); + result = result && (getTrxNum() + == other.getTrxNum()); + result = result && (getPrecision() + == other.getPrecision()); + result = result && (getNum() + == other.getNum()); + result = result && (getStartTime() + == other.getStartTime()); + result = result && (getEndTime() + == other.getEndTime()); + result = result && (getOrder() + == other.getOrder()); + result = result && (getVoteScore() + == other.getVoteScore()); + result = result && getDescription() + .equals(other.getDescription()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && (getFreeAssetNetLimit() + == other.getFreeAssetNetLimit()); + result = result && (getPublicFreeAssetNetLimit() + == other.getPublicFreeAssetNetLimit()); + result = result && (getPublicFreeAssetNetUsage() + == other.getPublicFreeAssetNetUsage()); + result = result && (getPublicLatestFreeNetTime() + == other.getPublicLatestFreeNetTime()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + ABBR_FIELD_NUMBER; + hash = (53 * hash) + getAbbr().hashCode(); + hash = (37 * hash) + TOTAL_SUPPLY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalSupply()); + if (getFrozenSupplyCount() > 0) { + hash = (37 * hash) + FROZEN_SUPPLY_FIELD_NUMBER; + hash = (53 * hash) + getFrozenSupplyList().hashCode(); + } + hash = (37 * hash) + TRX_NUM_FIELD_NUMBER; + hash = (53 * hash) + getTrxNum(); + hash = (37 * hash) + PRECISION_FIELD_NUMBER; + hash = (53 * hash) + getPrecision(); + hash = (37 * hash) + NUM_FIELD_NUMBER; + hash = (53 * hash) + getNum(); + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getStartTime()); + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEndTime()); + hash = (37 * hash) + ORDER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOrder()); + hash = (37 * hash) + VOTE_SCORE_FIELD_NUMBER; + hash = (53 * hash) + getVoteScore(); + hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER; + hash = (53 * hash) + getDescription().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (37 * hash) + FREE_ASSET_NET_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFreeAssetNetLimit()); + hash = (37 * hash) + PUBLIC_FREE_ASSET_NET_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPublicFreeAssetNetLimit()); + hash = (37 * hash) + PUBLIC_FREE_ASSET_NET_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPublicFreeAssetNetUsage()); + hash = (37 * hash) + PUBLIC_LATEST_FREE_NET_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPublicLatestFreeNetTime()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AssetIssueContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AssetIssueContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.AssetIssueContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AssetIssueContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AssetIssueContract) + org.tron.protos.Contract.AssetIssueContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AssetIssueContract.class, org.tron.protos.Contract.AssetIssueContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.AssetIssueContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getFrozenSupplyFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + id_ = ""; + + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + name_ = com.google.protobuf.ByteString.EMPTY; + + abbr_ = com.google.protobuf.ByteString.EMPTY; + + totalSupply_ = 0L; + + if (frozenSupplyBuilder_ == null) { + frozenSupply_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + } else { + frozenSupplyBuilder_.clear(); + } + trxNum_ = 0; + + precision_ = 0; + + num_ = 0; + + startTime_ = 0L; + + endTime_ = 0L; + + order_ = 0L; + + voteScore_ = 0; + + description_ = com.google.protobuf.ByteString.EMPTY; + + url_ = com.google.protobuf.ByteString.EMPTY; + + freeAssetNetLimit_ = 0L; + + publicFreeAssetNetLimit_ = 0L; + + publicFreeAssetNetUsage_ = 0L; + + publicLatestFreeNetTime_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_AssetIssueContract_descriptor; + } + + public org.tron.protos.Contract.AssetIssueContract getDefaultInstanceForType() { + return org.tron.protos.Contract.AssetIssueContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.AssetIssueContract build() { + org.tron.protos.Contract.AssetIssueContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.AssetIssueContract buildPartial() { + org.tron.protos.Contract.AssetIssueContract result = new org.tron.protos.Contract.AssetIssueContract(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.id_ = id_; + result.ownerAddress_ = ownerAddress_; + result.name_ = name_; + result.abbr_ = abbr_; + result.totalSupply_ = totalSupply_; + if (frozenSupplyBuilder_ == null) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { + frozenSupply_ = java.util.Collections.unmodifiableList(frozenSupply_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.frozenSupply_ = frozenSupply_; + } else { + result.frozenSupply_ = frozenSupplyBuilder_.build(); + } + result.trxNum_ = trxNum_; + result.precision_ = precision_; + result.num_ = num_; + result.startTime_ = startTime_; + result.endTime_ = endTime_; + result.order_ = order_; + result.voteScore_ = voteScore_; + result.description_ = description_; + result.url_ = url_; + result.freeAssetNetLimit_ = freeAssetNetLimit_; + result.publicFreeAssetNetLimit_ = publicFreeAssetNetLimit_; + result.publicFreeAssetNetUsage_ = publicFreeAssetNetUsage_; + result.publicLatestFreeNetTime_ = publicLatestFreeNetTime_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.AssetIssueContract) { + return mergeFrom((org.tron.protos.Contract.AssetIssueContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.AssetIssueContract other) { + if (other == org.tron.protos.Contract.AssetIssueContract.getDefaultInstance()) return this; + if (!other.getId().isEmpty()) { + id_ = other.id_; + onChanged(); + } + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getName() != com.google.protobuf.ByteString.EMPTY) { + setName(other.getName()); + } + if (other.getAbbr() != com.google.protobuf.ByteString.EMPTY) { + setAbbr(other.getAbbr()); + } + if (other.getTotalSupply() != 0L) { + setTotalSupply(other.getTotalSupply()); + } + if (frozenSupplyBuilder_ == null) { + if (!other.frozenSupply_.isEmpty()) { + if (frozenSupply_.isEmpty()) { + frozenSupply_ = other.frozenSupply_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureFrozenSupplyIsMutable(); + frozenSupply_.addAll(other.frozenSupply_); + } + onChanged(); + } + } else { + if (!other.frozenSupply_.isEmpty()) { + if (frozenSupplyBuilder_.isEmpty()) { + frozenSupplyBuilder_.dispose(); + frozenSupplyBuilder_ = null; + frozenSupply_ = other.frozenSupply_; + bitField0_ = (bitField0_ & ~0x00000020); + frozenSupplyBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getFrozenSupplyFieldBuilder() : null; + } else { + frozenSupplyBuilder_.addAllMessages(other.frozenSupply_); + } + } + } + if (other.getTrxNum() != 0) { + setTrxNum(other.getTrxNum()); + } + if (other.getPrecision() != 0) { + setPrecision(other.getPrecision()); + } + if (other.getNum() != 0) { + setNum(other.getNum()); + } + if (other.getStartTime() != 0L) { + setStartTime(other.getStartTime()); + } + if (other.getEndTime() != 0L) { + setEndTime(other.getEndTime()); + } + if (other.getOrder() != 0L) { + setOrder(other.getOrder()); + } + if (other.getVoteScore() != 0) { + setVoteScore(other.getVoteScore()); + } + if (other.getDescription() != com.google.protobuf.ByteString.EMPTY) { + setDescription(other.getDescription()); + } + if (other.getUrl() != com.google.protobuf.ByteString.EMPTY) { + setUrl(other.getUrl()); + } + if (other.getFreeAssetNetLimit() != 0L) { + setFreeAssetNetLimit(other.getFreeAssetNetLimit()); + } + if (other.getPublicFreeAssetNetLimit() != 0L) { + setPublicFreeAssetNetLimit(other.getPublicFreeAssetNetLimit()); + } + if (other.getPublicFreeAssetNetUsage() != 0L) { + setPublicFreeAssetNetUsage(other.getPublicFreeAssetNetUsage()); + } + if (other.getPublicLatestFreeNetTime() != 0L) { + setPublicLatestFreeNetTime(other.getPublicLatestFreeNetTime()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.AssetIssueContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.AssetIssueContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object id_ = ""; + /** + * string id = 41; + */ + public java.lang.String getId() { + java.lang.Object ref = id_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + id_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string id = 41; + */ + public com.google.protobuf.ByteString + getIdBytes() { + java.lang.Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string id = 41; + */ + public Builder setId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + id_ = value; + onChanged(); + return this; + } + /** + * string id = 41; + */ + public Builder clearId() { + + id_ = getDefaultInstance().getId(); + onChanged(); + return this; + } + /** + * string id = 41; + */ + public Builder setIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + id_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString name_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes name = 2; + */ + public com.google.protobuf.ByteString getName() { + return name_; + } + /** + * bytes name = 2; + */ + public Builder setName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * bytes name = 2; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString abbr_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes abbr = 3; + */ + public com.google.protobuf.ByteString getAbbr() { + return abbr_; + } + /** + * bytes abbr = 3; + */ + public Builder setAbbr(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + abbr_ = value; + onChanged(); + return this; + } + /** + * bytes abbr = 3; + */ + public Builder clearAbbr() { + + abbr_ = getDefaultInstance().getAbbr(); + onChanged(); + return this; + } + + private long totalSupply_ ; + /** + * int64 total_supply = 4; + */ + public long getTotalSupply() { + return totalSupply_; + } + /** + * int64 total_supply = 4; + */ + public Builder setTotalSupply(long value) { + + totalSupply_ = value; + onChanged(); + return this; + } + /** + * int64 total_supply = 4; + */ + public Builder clearTotalSupply() { + + totalSupply_ = 0L; + onChanged(); + return this; + } + + private java.util.List frozenSupply_ = + java.util.Collections.emptyList(); + private void ensureFrozenSupplyIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + frozenSupply_ = new java.util.ArrayList(frozenSupply_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.AssetIssueContract.FrozenSupply, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder, org.tron.protos.Contract.AssetIssueContract.FrozenSupplyOrBuilder> frozenSupplyBuilder_; + + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public java.util.List getFrozenSupplyList() { + if (frozenSupplyBuilder_ == null) { + return java.util.Collections.unmodifiableList(frozenSupply_); + } else { + return frozenSupplyBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public int getFrozenSupplyCount() { + if (frozenSupplyBuilder_ == null) { + return frozenSupply_.size(); + } else { + return frozenSupplyBuilder_.getCount(); + } + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply getFrozenSupply(int index) { + if (frozenSupplyBuilder_ == null) { + return frozenSupply_.get(index); + } else { + return frozenSupplyBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder setFrozenSupply( + int index, org.tron.protos.Contract.AssetIssueContract.FrozenSupply value) { + if (frozenSupplyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenSupplyIsMutable(); + frozenSupply_.set(index, value); + onChanged(); + } else { + frozenSupplyBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder setFrozenSupply( + int index, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder builderForValue) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.set(index, builderForValue.build()); + onChanged(); + } else { + frozenSupplyBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder addFrozenSupply(org.tron.protos.Contract.AssetIssueContract.FrozenSupply value) { + if (frozenSupplyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(value); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder addFrozenSupply( + int index, org.tron.protos.Contract.AssetIssueContract.FrozenSupply value) { + if (frozenSupplyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(index, value); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder addFrozenSupply( + org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder builderForValue) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(builderForValue.build()); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder addFrozenSupply( + int index, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder builderForValue) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(index, builderForValue.build()); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder addAllFrozenSupply( + java.lang.Iterable values) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, frozenSupply_); + onChanged(); + } else { + frozenSupplyBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder clearFrozenSupply() { + if (frozenSupplyBuilder_ == null) { + frozenSupply_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + frozenSupplyBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public Builder removeFrozenSupply(int index) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.remove(index); + onChanged(); + } else { + frozenSupplyBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder getFrozenSupplyBuilder( + int index) { + return getFrozenSupplyFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public org.tron.protos.Contract.AssetIssueContract.FrozenSupplyOrBuilder getFrozenSupplyOrBuilder( + int index) { + if (frozenSupplyBuilder_ == null) { + return frozenSupply_.get(index); } else { + return frozenSupplyBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public java.util.List + getFrozenSupplyOrBuilderList() { + if (frozenSupplyBuilder_ != null) { + return frozenSupplyBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(frozenSupply_); + } + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder addFrozenSupplyBuilder() { + return getFrozenSupplyFieldBuilder().addBuilder( + org.tron.protos.Contract.AssetIssueContract.FrozenSupply.getDefaultInstance()); + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder addFrozenSupplyBuilder( + int index) { + return getFrozenSupplyFieldBuilder().addBuilder( + index, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.getDefaultInstance()); + } + /** + * repeated .protocol.AssetIssueContract.FrozenSupply frozen_supply = 5; + */ + public java.util.List + getFrozenSupplyBuilderList() { + return getFrozenSupplyFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.AssetIssueContract.FrozenSupply, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder, org.tron.protos.Contract.AssetIssueContract.FrozenSupplyOrBuilder> + getFrozenSupplyFieldBuilder() { + if (frozenSupplyBuilder_ == null) { + frozenSupplyBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Contract.AssetIssueContract.FrozenSupply, org.tron.protos.Contract.AssetIssueContract.FrozenSupply.Builder, org.tron.protos.Contract.AssetIssueContract.FrozenSupplyOrBuilder>( + frozenSupply_, + ((bitField0_ & 0x00000020) == 0x00000020), + getParentForChildren(), + isClean()); + frozenSupply_ = null; + } + return frozenSupplyBuilder_; + } + + private int trxNum_ ; + /** + * int32 trx_num = 6; + */ + public int getTrxNum() { + return trxNum_; + } + /** + * int32 trx_num = 6; + */ + public Builder setTrxNum(int value) { + + trxNum_ = value; + onChanged(); + return this; + } + /** + * int32 trx_num = 6; + */ + public Builder clearTrxNum() { + + trxNum_ = 0; + onChanged(); + return this; + } + + private int precision_ ; + /** + * int32 precision = 7; + */ + public int getPrecision() { + return precision_; + } + /** + * int32 precision = 7; + */ + public Builder setPrecision(int value) { + + precision_ = value; + onChanged(); + return this; + } + /** + * int32 precision = 7; + */ + public Builder clearPrecision() { + + precision_ = 0; + onChanged(); + return this; + } + + private int num_ ; + /** + * int32 num = 8; + */ + public int getNum() { + return num_; + } + /** + * int32 num = 8; + */ + public Builder setNum(int value) { + + num_ = value; + onChanged(); + return this; + } + /** + * int32 num = 8; + */ + public Builder clearNum() { + + num_ = 0; + onChanged(); + return this; + } + + private long startTime_ ; + /** + * int64 start_time = 9; + */ + public long getStartTime() { + return startTime_; + } + /** + * int64 start_time = 9; + */ + public Builder setStartTime(long value) { + + startTime_ = value; + onChanged(); + return this; + } + /** + * int64 start_time = 9; + */ + public Builder clearStartTime() { + + startTime_ = 0L; + onChanged(); + return this; + } + + private long endTime_ ; + /** + * int64 end_time = 10; + */ + public long getEndTime() { + return endTime_; + } + /** + * int64 end_time = 10; + */ + public Builder setEndTime(long value) { + + endTime_ = value; + onChanged(); + return this; + } + /** + * int64 end_time = 10; + */ + public Builder clearEndTime() { + + endTime_ = 0L; + onChanged(); + return this; + } + + private long order_ ; + /** + *
+       * useless
+       * 
+ * + * int64 order = 11; + */ + public long getOrder() { + return order_; + } + /** + *
+       * useless
+       * 
+ * + * int64 order = 11; + */ + public Builder setOrder(long value) { + + order_ = value; + onChanged(); + return this; + } + /** + *
+       * useless
+       * 
+ * + * int64 order = 11; + */ + public Builder clearOrder() { + + order_ = 0L; + onChanged(); + return this; + } + + private int voteScore_ ; + /** + * int32 vote_score = 16; + */ + public int getVoteScore() { + return voteScore_; + } + /** + * int32 vote_score = 16; + */ + public Builder setVoteScore(int value) { + + voteScore_ = value; + onChanged(); + return this; + } + /** + * int32 vote_score = 16; + */ + public Builder clearVoteScore() { + + voteScore_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString description_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes description = 20; + */ + public com.google.protobuf.ByteString getDescription() { + return description_; + } + /** + * bytes description = 20; + */ + public Builder setDescription(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * bytes description = 20; + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString url_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes url = 21; + */ + public com.google.protobuf.ByteString getUrl() { + return url_; + } + /** + * bytes url = 21; + */ + public Builder setUrl(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * bytes url = 21; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + + private long freeAssetNetLimit_ ; + /** + * int64 free_asset_net_limit = 22; + */ + public long getFreeAssetNetLimit() { + return freeAssetNetLimit_; + } + /** + * int64 free_asset_net_limit = 22; + */ + public Builder setFreeAssetNetLimit(long value) { + + freeAssetNetLimit_ = value; + onChanged(); + return this; + } + /** + * int64 free_asset_net_limit = 22; + */ + public Builder clearFreeAssetNetLimit() { + + freeAssetNetLimit_ = 0L; + onChanged(); + return this; + } + + private long publicFreeAssetNetLimit_ ; + /** + * int64 public_free_asset_net_limit = 23; + */ + public long getPublicFreeAssetNetLimit() { + return publicFreeAssetNetLimit_; + } + /** + * int64 public_free_asset_net_limit = 23; + */ + public Builder setPublicFreeAssetNetLimit(long value) { + + publicFreeAssetNetLimit_ = value; + onChanged(); + return this; + } + /** + * int64 public_free_asset_net_limit = 23; + */ + public Builder clearPublicFreeAssetNetLimit() { + + publicFreeAssetNetLimit_ = 0L; + onChanged(); + return this; + } + + private long publicFreeAssetNetUsage_ ; + /** + * int64 public_free_asset_net_usage = 24; + */ + public long getPublicFreeAssetNetUsage() { + return publicFreeAssetNetUsage_; + } + /** + * int64 public_free_asset_net_usage = 24; + */ + public Builder setPublicFreeAssetNetUsage(long value) { + + publicFreeAssetNetUsage_ = value; + onChanged(); + return this; + } + /** + * int64 public_free_asset_net_usage = 24; + */ + public Builder clearPublicFreeAssetNetUsage() { + + publicFreeAssetNetUsage_ = 0L; + onChanged(); + return this; + } + + private long publicLatestFreeNetTime_ ; + /** + * int64 public_latest_free_net_time = 25; + */ + public long getPublicLatestFreeNetTime() { + return publicLatestFreeNetTime_; + } + /** + * int64 public_latest_free_net_time = 25; + */ + public Builder setPublicLatestFreeNetTime(long value) { + + publicLatestFreeNetTime_ = value; + onChanged(); + return this; + } + /** + * int64 public_latest_free_net_time = 25; + */ + public Builder clearPublicLatestFreeNetTime() { + + publicLatestFreeNetTime_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AssetIssueContract) + } + + // @@protoc_insertion_point(class_scope:protocol.AssetIssueContract) + private static final org.tron.protos.Contract.AssetIssueContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.AssetIssueContract(); + } + + public static org.tron.protos.Contract.AssetIssueContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AssetIssueContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AssetIssueContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.AssetIssueContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ParticipateAssetIssueContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ParticipateAssetIssueContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes to_address = 2; + */ + com.google.protobuf.ByteString getToAddress(); + + /** + *
+     * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+     * 
+ * + * bytes asset_name = 3; + */ + com.google.protobuf.ByteString getAssetName(); + + /** + *
+     * the amount of drops
+     * 
+ * + * int64 amount = 4; + */ + long getAmount(); + } + /** + * Protobuf type {@code protocol.ParticipateAssetIssueContract} + */ + public static final class ParticipateAssetIssueContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ParticipateAssetIssueContract) + ParticipateAssetIssueContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ParticipateAssetIssueContract.newBuilder() to construct. + private ParticipateAssetIssueContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ParticipateAssetIssueContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + toAddress_ = com.google.protobuf.ByteString.EMPTY; + assetName_ = com.google.protobuf.ByteString.EMPTY; + amount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ParticipateAssetIssueContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + toAddress_ = input.readBytes(); + break; + } + case 26: { + + assetName_ = input.readBytes(); + break; + } + case 32: { + + amount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ParticipateAssetIssueContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ParticipateAssetIssueContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ParticipateAssetIssueContract.class, org.tron.protos.Contract.ParticipateAssetIssueContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int TO_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString toAddress_; + /** + * bytes to_address = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + + public static final int ASSET_NAME_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString assetName_; + /** + *
+     * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+     * 
+ * + * bytes asset_name = 3; + */ + public com.google.protobuf.ByteString getAssetName() { + return assetName_; + } + + public static final int AMOUNT_FIELD_NUMBER = 4; + private long amount_; + /** + *
+     * the amount of drops
+     * 
+ * + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!toAddress_.isEmpty()) { + output.writeBytes(2, toAddress_); + } + if (!assetName_.isEmpty()) { + output.writeBytes(3, assetName_); + } + if (amount_ != 0L) { + output.writeInt64(4, amount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!toAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, toAddress_); + } + if (!assetName_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, assetName_); + } + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, amount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ParticipateAssetIssueContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ParticipateAssetIssueContract other = (org.tron.protos.Contract.ParticipateAssetIssueContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getToAddress() + .equals(other.getToAddress()); + result = result && getAssetName() + .equals(other.getAssetName()); + result = result && (getAmount() + == other.getAmount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + TO_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getToAddress().hashCode(); + hash = (37 * hash) + ASSET_NAME_FIELD_NUMBER; + hash = (53 * hash) + getAssetName().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ParticipateAssetIssueContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ParticipateAssetIssueContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ParticipateAssetIssueContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ParticipateAssetIssueContract) + org.tron.protos.Contract.ParticipateAssetIssueContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ParticipateAssetIssueContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ParticipateAssetIssueContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ParticipateAssetIssueContract.class, org.tron.protos.Contract.ParticipateAssetIssueContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ParticipateAssetIssueContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + toAddress_ = com.google.protobuf.ByteString.EMPTY; + + assetName_ = com.google.protobuf.ByteString.EMPTY; + + amount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ParticipateAssetIssueContract_descriptor; + } + + public org.tron.protos.Contract.ParticipateAssetIssueContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ParticipateAssetIssueContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ParticipateAssetIssueContract build() { + org.tron.protos.Contract.ParticipateAssetIssueContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ParticipateAssetIssueContract buildPartial() { + org.tron.protos.Contract.ParticipateAssetIssueContract result = new org.tron.protos.Contract.ParticipateAssetIssueContract(this); + result.ownerAddress_ = ownerAddress_; + result.toAddress_ = toAddress_; + result.assetName_ = assetName_; + result.amount_ = amount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ParticipateAssetIssueContract) { + return mergeFrom((org.tron.protos.Contract.ParticipateAssetIssueContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ParticipateAssetIssueContract other) { + if (other == org.tron.protos.Contract.ParticipateAssetIssueContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getToAddress() != com.google.protobuf.ByteString.EMPTY) { + setToAddress(other.getToAddress()); + } + if (other.getAssetName() != com.google.protobuf.ByteString.EMPTY) { + setAssetName(other.getAssetName()); + } + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ParticipateAssetIssueContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ParticipateAssetIssueContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString toAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes to_address = 2; + */ + public com.google.protobuf.ByteString getToAddress() { + return toAddress_; + } + /** + * bytes to_address = 2; + */ + public Builder setToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + toAddress_ = value; + onChanged(); + return this; + } + /** + * bytes to_address = 2; + */ + public Builder clearToAddress() { + + toAddress_ = getDefaultInstance().getToAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString assetName_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+       * 
+ * + * bytes asset_name = 3; + */ + public com.google.protobuf.ByteString getAssetName() { + return assetName_; + } + /** + *
+       * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+       * 
+ * + * bytes asset_name = 3; + */ + public Builder setAssetName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + assetName_ = value; + onChanged(); + return this; + } + /** + *
+       * this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id and token is should be in string format.
+       * 
+ * + * bytes asset_name = 3; + */ + public Builder clearAssetName() { + + assetName_ = getDefaultInstance().getAssetName(); + onChanged(); + return this; + } + + private long amount_ ; + /** + *
+       * the amount of drops
+       * 
+ * + * int64 amount = 4; + */ + public long getAmount() { + return amount_; + } + /** + *
+       * the amount of drops
+       * 
+ * + * int64 amount = 4; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + *
+       * the amount of drops
+       * 
+ * + * int64 amount = 4; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ParticipateAssetIssueContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ParticipateAssetIssueContract) + private static final org.tron.protos.Contract.ParticipateAssetIssueContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ParticipateAssetIssueContract(); + } + + public static org.tron.protos.Contract.ParticipateAssetIssueContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ParticipateAssetIssueContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ParticipateAssetIssueContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ParticipateAssetIssueContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface FreezeBalanceContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.FreezeBalanceContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * int64 frozen_balance = 2; + */ + long getFrozenBalance(); + + /** + * int64 frozen_duration = 3; + */ + long getFrozenDuration(); + + /** + * .protocol.ResourceCode resource = 10; + */ + int getResourceValue(); + /** + * .protocol.ResourceCode resource = 10; + */ + org.tron.protos.Contract.ResourceCode getResource(); + + /** + * bytes receiver_address = 15; + */ + com.google.protobuf.ByteString getReceiverAddress(); + } + /** + * Protobuf type {@code protocol.FreezeBalanceContract} + */ + public static final class FreezeBalanceContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.FreezeBalanceContract) + FreezeBalanceContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use FreezeBalanceContract.newBuilder() to construct. + private FreezeBalanceContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private FreezeBalanceContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + frozenBalance_ = 0L; + frozenDuration_ = 0L; + resource_ = 0; + receiverAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private FreezeBalanceContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + frozenBalance_ = input.readInt64(); + break; + } + case 24: { + + frozenDuration_ = input.readInt64(); + break; + } + case 80: { + int rawValue = input.readEnum(); + + resource_ = rawValue; + break; + } + case 122: { + + receiverAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_FreezeBalanceContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_FreezeBalanceContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.FreezeBalanceContract.class, org.tron.protos.Contract.FreezeBalanceContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int FROZEN_BALANCE_FIELD_NUMBER = 2; + private long frozenBalance_; + /** + * int64 frozen_balance = 2; + */ + public long getFrozenBalance() { + return frozenBalance_; + } + + public static final int FROZEN_DURATION_FIELD_NUMBER = 3; + private long frozenDuration_; + /** + * int64 frozen_duration = 3; + */ + public long getFrozenDuration() { + return frozenDuration_; + } + + public static final int RESOURCE_FIELD_NUMBER = 10; + private int resource_; + /** + * .protocol.ResourceCode resource = 10; + */ + public int getResourceValue() { + return resource_; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public org.tron.protos.Contract.ResourceCode getResource() { + org.tron.protos.Contract.ResourceCode result = org.tron.protos.Contract.ResourceCode.valueOf(resource_); + return result == null ? org.tron.protos.Contract.ResourceCode.UNRECOGNIZED : result; + } + + public static final int RECEIVER_ADDRESS_FIELD_NUMBER = 15; + private com.google.protobuf.ByteString receiverAddress_; + /** + * bytes receiver_address = 15; + */ + public com.google.protobuf.ByteString getReceiverAddress() { + return receiverAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (frozenBalance_ != 0L) { + output.writeInt64(2, frozenBalance_); + } + if (frozenDuration_ != 0L) { + output.writeInt64(3, frozenDuration_); + } + if (resource_ != org.tron.protos.Contract.ResourceCode.BANDWIDTH.getNumber()) { + output.writeEnum(10, resource_); + } + if (!receiverAddress_.isEmpty()) { + output.writeBytes(15, receiverAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (frozenBalance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, frozenBalance_); + } + if (frozenDuration_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, frozenDuration_); + } + if (resource_ != org.tron.protos.Contract.ResourceCode.BANDWIDTH.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(10, resource_); + } + if (!receiverAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(15, receiverAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.FreezeBalanceContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.FreezeBalanceContract other = (org.tron.protos.Contract.FreezeBalanceContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getFrozenBalance() + == other.getFrozenBalance()); + result = result && (getFrozenDuration() + == other.getFrozenDuration()); + result = result && resource_ == other.resource_; + result = result && getReceiverAddress() + .equals(other.getReceiverAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + FROZEN_BALANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFrozenBalance()); + hash = (37 * hash) + FROZEN_DURATION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFrozenDuration()); + hash = (37 * hash) + RESOURCE_FIELD_NUMBER; + hash = (53 * hash) + resource_; + hash = (37 * hash) + RECEIVER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getReceiverAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.FreezeBalanceContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.FreezeBalanceContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.FreezeBalanceContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.FreezeBalanceContract) + org.tron.protos.Contract.FreezeBalanceContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_FreezeBalanceContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_FreezeBalanceContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.FreezeBalanceContract.class, org.tron.protos.Contract.FreezeBalanceContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.FreezeBalanceContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + frozenBalance_ = 0L; + + frozenDuration_ = 0L; + + resource_ = 0; + + receiverAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_FreezeBalanceContract_descriptor; + } + + public org.tron.protos.Contract.FreezeBalanceContract getDefaultInstanceForType() { + return org.tron.protos.Contract.FreezeBalanceContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.FreezeBalanceContract build() { + org.tron.protos.Contract.FreezeBalanceContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.FreezeBalanceContract buildPartial() { + org.tron.protos.Contract.FreezeBalanceContract result = new org.tron.protos.Contract.FreezeBalanceContract(this); + result.ownerAddress_ = ownerAddress_; + result.frozenBalance_ = frozenBalance_; + result.frozenDuration_ = frozenDuration_; + result.resource_ = resource_; + result.receiverAddress_ = receiverAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.FreezeBalanceContract) { + return mergeFrom((org.tron.protos.Contract.FreezeBalanceContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.FreezeBalanceContract other) { + if (other == org.tron.protos.Contract.FreezeBalanceContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getFrozenBalance() != 0L) { + setFrozenBalance(other.getFrozenBalance()); + } + if (other.getFrozenDuration() != 0L) { + setFrozenDuration(other.getFrozenDuration()); + } + if (other.resource_ != 0) { + setResourceValue(other.getResourceValue()); + } + if (other.getReceiverAddress() != com.google.protobuf.ByteString.EMPTY) { + setReceiverAddress(other.getReceiverAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.FreezeBalanceContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.FreezeBalanceContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long frozenBalance_ ; + /** + * int64 frozen_balance = 2; + */ + public long getFrozenBalance() { + return frozenBalance_; + } + /** + * int64 frozen_balance = 2; + */ + public Builder setFrozenBalance(long value) { + + frozenBalance_ = value; + onChanged(); + return this; + } + /** + * int64 frozen_balance = 2; + */ + public Builder clearFrozenBalance() { + + frozenBalance_ = 0L; + onChanged(); + return this; + } + + private long frozenDuration_ ; + /** + * int64 frozen_duration = 3; + */ + public long getFrozenDuration() { + return frozenDuration_; + } + /** + * int64 frozen_duration = 3; + */ + public Builder setFrozenDuration(long value) { + + frozenDuration_ = value; + onChanged(); + return this; + } + /** + * int64 frozen_duration = 3; + */ + public Builder clearFrozenDuration() { + + frozenDuration_ = 0L; + onChanged(); + return this; + } + + private int resource_ = 0; + /** + * .protocol.ResourceCode resource = 10; + */ + public int getResourceValue() { + return resource_; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public Builder setResourceValue(int value) { + resource_ = value; + onChanged(); + return this; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public org.tron.protos.Contract.ResourceCode getResource() { + org.tron.protos.Contract.ResourceCode result = org.tron.protos.Contract.ResourceCode.valueOf(resource_); + return result == null ? org.tron.protos.Contract.ResourceCode.UNRECOGNIZED : result; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public Builder setResource(org.tron.protos.Contract.ResourceCode value) { + if (value == null) { + throw new NullPointerException(); + } + + resource_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public Builder clearResource() { + + resource_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString receiverAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes receiver_address = 15; + */ + public com.google.protobuf.ByteString getReceiverAddress() { + return receiverAddress_; + } + /** + * bytes receiver_address = 15; + */ + public Builder setReceiverAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + receiverAddress_ = value; + onChanged(); + return this; + } + /** + * bytes receiver_address = 15; + */ + public Builder clearReceiverAddress() { + + receiverAddress_ = getDefaultInstance().getReceiverAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.FreezeBalanceContract) + } + + // @@protoc_insertion_point(class_scope:protocol.FreezeBalanceContract) + private static final org.tron.protos.Contract.FreezeBalanceContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.FreezeBalanceContract(); + } + + public static org.tron.protos.Contract.FreezeBalanceContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public FreezeBalanceContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new FreezeBalanceContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.FreezeBalanceContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface UnfreezeBalanceContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.UnfreezeBalanceContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * .protocol.ResourceCode resource = 10; + */ + int getResourceValue(); + /** + * .protocol.ResourceCode resource = 10; + */ + org.tron.protos.Contract.ResourceCode getResource(); + + /** + * bytes receiver_address = 15; + */ + com.google.protobuf.ByteString getReceiverAddress(); + } + /** + * Protobuf type {@code protocol.UnfreezeBalanceContract} + */ + public static final class UnfreezeBalanceContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.UnfreezeBalanceContract) + UnfreezeBalanceContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use UnfreezeBalanceContract.newBuilder() to construct. + private UnfreezeBalanceContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private UnfreezeBalanceContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + resource_ = 0; + receiverAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private UnfreezeBalanceContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 80: { + int rawValue = input.readEnum(); + + resource_ = rawValue; + break; + } + case 122: { + + receiverAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeBalanceContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeBalanceContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UnfreezeBalanceContract.class, org.tron.protos.Contract.UnfreezeBalanceContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int RESOURCE_FIELD_NUMBER = 10; + private int resource_; + /** + * .protocol.ResourceCode resource = 10; + */ + public int getResourceValue() { + return resource_; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public org.tron.protos.Contract.ResourceCode getResource() { + org.tron.protos.Contract.ResourceCode result = org.tron.protos.Contract.ResourceCode.valueOf(resource_); + return result == null ? org.tron.protos.Contract.ResourceCode.UNRECOGNIZED : result; + } + + public static final int RECEIVER_ADDRESS_FIELD_NUMBER = 15; + private com.google.protobuf.ByteString receiverAddress_; + /** + * bytes receiver_address = 15; + */ + public com.google.protobuf.ByteString getReceiverAddress() { + return receiverAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (resource_ != org.tron.protos.Contract.ResourceCode.BANDWIDTH.getNumber()) { + output.writeEnum(10, resource_); + } + if (!receiverAddress_.isEmpty()) { + output.writeBytes(15, receiverAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (resource_ != org.tron.protos.Contract.ResourceCode.BANDWIDTH.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(10, resource_); + } + if (!receiverAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(15, receiverAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.UnfreezeBalanceContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.UnfreezeBalanceContract other = (org.tron.protos.Contract.UnfreezeBalanceContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && resource_ == other.resource_; + result = result && getReceiverAddress() + .equals(other.getReceiverAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + RESOURCE_FIELD_NUMBER; + hash = (53 * hash) + resource_; + hash = (37 * hash) + RECEIVER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getReceiverAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UnfreezeBalanceContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.UnfreezeBalanceContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.UnfreezeBalanceContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.UnfreezeBalanceContract) + org.tron.protos.Contract.UnfreezeBalanceContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeBalanceContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeBalanceContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UnfreezeBalanceContract.class, org.tron.protos.Contract.UnfreezeBalanceContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.UnfreezeBalanceContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + resource_ = 0; + + receiverAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeBalanceContract_descriptor; + } + + public org.tron.protos.Contract.UnfreezeBalanceContract getDefaultInstanceForType() { + return org.tron.protos.Contract.UnfreezeBalanceContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.UnfreezeBalanceContract build() { + org.tron.protos.Contract.UnfreezeBalanceContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.UnfreezeBalanceContract buildPartial() { + org.tron.protos.Contract.UnfreezeBalanceContract result = new org.tron.protos.Contract.UnfreezeBalanceContract(this); + result.ownerAddress_ = ownerAddress_; + result.resource_ = resource_; + result.receiverAddress_ = receiverAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.UnfreezeBalanceContract) { + return mergeFrom((org.tron.protos.Contract.UnfreezeBalanceContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.UnfreezeBalanceContract other) { + if (other == org.tron.protos.Contract.UnfreezeBalanceContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.resource_ != 0) { + setResourceValue(other.getResourceValue()); + } + if (other.getReceiverAddress() != com.google.protobuf.ByteString.EMPTY) { + setReceiverAddress(other.getReceiverAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.UnfreezeBalanceContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.UnfreezeBalanceContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private int resource_ = 0; + /** + * .protocol.ResourceCode resource = 10; + */ + public int getResourceValue() { + return resource_; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public Builder setResourceValue(int value) { + resource_ = value; + onChanged(); + return this; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public org.tron.protos.Contract.ResourceCode getResource() { + org.tron.protos.Contract.ResourceCode result = org.tron.protos.Contract.ResourceCode.valueOf(resource_); + return result == null ? org.tron.protos.Contract.ResourceCode.UNRECOGNIZED : result; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public Builder setResource(org.tron.protos.Contract.ResourceCode value) { + if (value == null) { + throw new NullPointerException(); + } + + resource_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.ResourceCode resource = 10; + */ + public Builder clearResource() { + + resource_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString receiverAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes receiver_address = 15; + */ + public com.google.protobuf.ByteString getReceiverAddress() { + return receiverAddress_; + } + /** + * bytes receiver_address = 15; + */ + public Builder setReceiverAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + receiverAddress_ = value; + onChanged(); + return this; + } + /** + * bytes receiver_address = 15; + */ + public Builder clearReceiverAddress() { + + receiverAddress_ = getDefaultInstance().getReceiverAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.UnfreezeBalanceContract) + } + + // @@protoc_insertion_point(class_scope:protocol.UnfreezeBalanceContract) + private static final org.tron.protos.Contract.UnfreezeBalanceContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.UnfreezeBalanceContract(); + } + + public static org.tron.protos.Contract.UnfreezeBalanceContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public UnfreezeBalanceContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new UnfreezeBalanceContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.UnfreezeBalanceContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface UnfreezeAssetContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.UnfreezeAssetContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + } + /** + * Protobuf type {@code protocol.UnfreezeAssetContract} + */ + public static final class UnfreezeAssetContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.UnfreezeAssetContract) + UnfreezeAssetContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use UnfreezeAssetContract.newBuilder() to construct. + private UnfreezeAssetContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private UnfreezeAssetContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private UnfreezeAssetContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UnfreezeAssetContract.class, org.tron.protos.Contract.UnfreezeAssetContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.UnfreezeAssetContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.UnfreezeAssetContract other = (org.tron.protos.Contract.UnfreezeAssetContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UnfreezeAssetContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.UnfreezeAssetContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.UnfreezeAssetContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.UnfreezeAssetContract) + org.tron.protos.Contract.UnfreezeAssetContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UnfreezeAssetContract.class, org.tron.protos.Contract.UnfreezeAssetContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.UnfreezeAssetContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_UnfreezeAssetContract_descriptor; + } + + public org.tron.protos.Contract.UnfreezeAssetContract getDefaultInstanceForType() { + return org.tron.protos.Contract.UnfreezeAssetContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.UnfreezeAssetContract build() { + org.tron.protos.Contract.UnfreezeAssetContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.UnfreezeAssetContract buildPartial() { + org.tron.protos.Contract.UnfreezeAssetContract result = new org.tron.protos.Contract.UnfreezeAssetContract(this); + result.ownerAddress_ = ownerAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.UnfreezeAssetContract) { + return mergeFrom((org.tron.protos.Contract.UnfreezeAssetContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.UnfreezeAssetContract other) { + if (other == org.tron.protos.Contract.UnfreezeAssetContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.UnfreezeAssetContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.UnfreezeAssetContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.UnfreezeAssetContract) + } + + // @@protoc_insertion_point(class_scope:protocol.UnfreezeAssetContract) + private static final org.tron.protos.Contract.UnfreezeAssetContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.UnfreezeAssetContract(); + } + + public static org.tron.protos.Contract.UnfreezeAssetContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public UnfreezeAssetContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new UnfreezeAssetContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.UnfreezeAssetContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface WithdrawBalanceContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.WithdrawBalanceContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + } + /** + * Protobuf type {@code protocol.WithdrawBalanceContract} + */ + public static final class WithdrawBalanceContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.WithdrawBalanceContract) + WithdrawBalanceContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use WithdrawBalanceContract.newBuilder() to construct. + private WithdrawBalanceContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private WithdrawBalanceContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private WithdrawBalanceContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_WithdrawBalanceContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_WithdrawBalanceContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.WithdrawBalanceContract.class, org.tron.protos.Contract.WithdrawBalanceContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.WithdrawBalanceContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.WithdrawBalanceContract other = (org.tron.protos.Contract.WithdrawBalanceContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.WithdrawBalanceContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.WithdrawBalanceContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.WithdrawBalanceContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.WithdrawBalanceContract) + org.tron.protos.Contract.WithdrawBalanceContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_WithdrawBalanceContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_WithdrawBalanceContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.WithdrawBalanceContract.class, org.tron.protos.Contract.WithdrawBalanceContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.WithdrawBalanceContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_WithdrawBalanceContract_descriptor; + } + + public org.tron.protos.Contract.WithdrawBalanceContract getDefaultInstanceForType() { + return org.tron.protos.Contract.WithdrawBalanceContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.WithdrawBalanceContract build() { + org.tron.protos.Contract.WithdrawBalanceContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.WithdrawBalanceContract buildPartial() { + org.tron.protos.Contract.WithdrawBalanceContract result = new org.tron.protos.Contract.WithdrawBalanceContract(this); + result.ownerAddress_ = ownerAddress_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.WithdrawBalanceContract) { + return mergeFrom((org.tron.protos.Contract.WithdrawBalanceContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.WithdrawBalanceContract other) { + if (other == org.tron.protos.Contract.WithdrawBalanceContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.WithdrawBalanceContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.WithdrawBalanceContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.WithdrawBalanceContract) + } + + // @@protoc_insertion_point(class_scope:protocol.WithdrawBalanceContract) + private static final org.tron.protos.Contract.WithdrawBalanceContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.WithdrawBalanceContract(); + } + + public static org.tron.protos.Contract.WithdrawBalanceContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public WithdrawBalanceContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new WithdrawBalanceContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.WithdrawBalanceContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface UpdateAssetContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.UpdateAssetContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes description = 2; + */ + com.google.protobuf.ByteString getDescription(); + + /** + * bytes url = 3; + */ + com.google.protobuf.ByteString getUrl(); + + /** + * int64 new_limit = 4; + */ + long getNewLimit(); + + /** + * int64 new_public_limit = 5; + */ + long getNewPublicLimit(); + } + /** + * Protobuf type {@code protocol.UpdateAssetContract} + */ + public static final class UpdateAssetContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.UpdateAssetContract) + UpdateAssetContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use UpdateAssetContract.newBuilder() to construct. + private UpdateAssetContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private UpdateAssetContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + description_ = com.google.protobuf.ByteString.EMPTY; + url_ = com.google.protobuf.ByteString.EMPTY; + newLimit_ = 0L; + newPublicLimit_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private UpdateAssetContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + description_ = input.readBytes(); + break; + } + case 26: { + + url_ = input.readBytes(); + break; + } + case 32: { + + newLimit_ = input.readInt64(); + break; + } + case 40: { + + newPublicLimit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UpdateAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UpdateAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UpdateAssetContract.class, org.tron.protos.Contract.UpdateAssetContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int DESCRIPTION_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString description_; + /** + * bytes description = 2; + */ + public com.google.protobuf.ByteString getDescription() { + return description_; + } + + public static final int URL_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString url_; + /** + * bytes url = 3; + */ + public com.google.protobuf.ByteString getUrl() { + return url_; + } + + public static final int NEW_LIMIT_FIELD_NUMBER = 4; + private long newLimit_; + /** + * int64 new_limit = 4; + */ + public long getNewLimit() { + return newLimit_; + } + + public static final int NEW_PUBLIC_LIMIT_FIELD_NUMBER = 5; + private long newPublicLimit_; + /** + * int64 new_public_limit = 5; + */ + public long getNewPublicLimit() { + return newPublicLimit_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!description_.isEmpty()) { + output.writeBytes(2, description_); + } + if (!url_.isEmpty()) { + output.writeBytes(3, url_); + } + if (newLimit_ != 0L) { + output.writeInt64(4, newLimit_); + } + if (newPublicLimit_ != 0L) { + output.writeInt64(5, newPublicLimit_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!description_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, description_); + } + if (!url_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, url_); + } + if (newLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, newLimit_); + } + if (newPublicLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, newPublicLimit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.UpdateAssetContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.UpdateAssetContract other = (org.tron.protos.Contract.UpdateAssetContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getDescription() + .equals(other.getDescription()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && (getNewLimit() + == other.getNewLimit()); + result = result && (getNewPublicLimit() + == other.getNewPublicLimit()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER; + hash = (53 * hash) + getDescription().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (37 * hash) + NEW_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNewLimit()); + hash = (37 * hash) + NEW_PUBLIC_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNewPublicLimit()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateAssetContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateAssetContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.UpdateAssetContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.UpdateAssetContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.UpdateAssetContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.UpdateAssetContract) + org.tron.protos.Contract.UpdateAssetContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_UpdateAssetContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_UpdateAssetContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.UpdateAssetContract.class, org.tron.protos.Contract.UpdateAssetContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.UpdateAssetContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + description_ = com.google.protobuf.ByteString.EMPTY; + + url_ = com.google.protobuf.ByteString.EMPTY; + + newLimit_ = 0L; + + newPublicLimit_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_UpdateAssetContract_descriptor; + } + + public org.tron.protos.Contract.UpdateAssetContract getDefaultInstanceForType() { + return org.tron.protos.Contract.UpdateAssetContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.UpdateAssetContract build() { + org.tron.protos.Contract.UpdateAssetContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.UpdateAssetContract buildPartial() { + org.tron.protos.Contract.UpdateAssetContract result = new org.tron.protos.Contract.UpdateAssetContract(this); + result.ownerAddress_ = ownerAddress_; + result.description_ = description_; + result.url_ = url_; + result.newLimit_ = newLimit_; + result.newPublicLimit_ = newPublicLimit_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.UpdateAssetContract) { + return mergeFrom((org.tron.protos.Contract.UpdateAssetContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.UpdateAssetContract other) { + if (other == org.tron.protos.Contract.UpdateAssetContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getDescription() != com.google.protobuf.ByteString.EMPTY) { + setDescription(other.getDescription()); + } + if (other.getUrl() != com.google.protobuf.ByteString.EMPTY) { + setUrl(other.getUrl()); + } + if (other.getNewLimit() != 0L) { + setNewLimit(other.getNewLimit()); + } + if (other.getNewPublicLimit() != 0L) { + setNewPublicLimit(other.getNewPublicLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.UpdateAssetContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.UpdateAssetContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString description_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes description = 2; + */ + public com.google.protobuf.ByteString getDescription() { + return description_; + } + /** + * bytes description = 2; + */ + public Builder setDescription(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * bytes description = 2; + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString url_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes url = 3; + */ + public com.google.protobuf.ByteString getUrl() { + return url_; + } + /** + * bytes url = 3; + */ + public Builder setUrl(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * bytes url = 3; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + + private long newLimit_ ; + /** + * int64 new_limit = 4; + */ + public long getNewLimit() { + return newLimit_; + } + /** + * int64 new_limit = 4; + */ + public Builder setNewLimit(long value) { + + newLimit_ = value; + onChanged(); + return this; + } + /** + * int64 new_limit = 4; + */ + public Builder clearNewLimit() { + + newLimit_ = 0L; + onChanged(); + return this; + } + + private long newPublicLimit_ ; + /** + * int64 new_public_limit = 5; + */ + public long getNewPublicLimit() { + return newPublicLimit_; + } + /** + * int64 new_public_limit = 5; + */ + public Builder setNewPublicLimit(long value) { + + newPublicLimit_ = value; + onChanged(); + return this; + } + /** + * int64 new_public_limit = 5; + */ + public Builder clearNewPublicLimit() { + + newPublicLimit_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.UpdateAssetContract) + } + + // @@protoc_insertion_point(class_scope:protocol.UpdateAssetContract) + private static final org.tron.protos.Contract.UpdateAssetContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.UpdateAssetContract(); + } + + public static org.tron.protos.Contract.UpdateAssetContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public UpdateAssetContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new UpdateAssetContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.UpdateAssetContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ProposalCreateContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ProposalCreateContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * map<int64, int64> parameters = 2; + */ + int getParametersCount(); + /** + * map<int64, int64> parameters = 2; + */ + boolean containsParameters( + long key); + /** + * Use {@link #getParametersMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getParameters(); + /** + * map<int64, int64> parameters = 2; + */ + java.util.Map + getParametersMap(); + /** + * map<int64, int64> parameters = 2; + */ + + long getParametersOrDefault( + long key, + long defaultValue); + /** + * map<int64, int64> parameters = 2; + */ + + long getParametersOrThrow( + long key); + } + /** + * Protobuf type {@code protocol.ProposalCreateContract} + */ + public static final class ProposalCreateContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ProposalCreateContract) + ProposalCreateContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ProposalCreateContract.newBuilder() to construct. + private ProposalCreateContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ProposalCreateContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ProposalCreateContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + parameters_ = com.google.protobuf.MapField.newMapField( + ParametersDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000002; + } + com.google.protobuf.MapEntry + parameters__ = input.readMessage( + ParametersDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + parameters_.getMutableMap().put( + parameters__.getKey(), parameters__.getValue()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ProposalCreateContract_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 2: + return internalGetParameters(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ProposalCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ProposalCreateContract.class, org.tron.protos.Contract.ProposalCreateContract.Builder.class); + } + + private int bitField0_; + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int PARAMETERS_FIELD_NUMBER = 2; + private static final class ParametersDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.Long, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Contract.internal_static_protocol_ProposalCreateContract_ParametersEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.INT64, + 0L, + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.Long, java.lang.Long> parameters_; + private com.google.protobuf.MapField + internalGetParameters() { + if (parameters_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ParametersDefaultEntryHolder.defaultEntry); + } + return parameters_; + } + + public int getParametersCount() { + return internalGetParameters().getMap().size(); + } + /** + * map<int64, int64> parameters = 2; + */ + + public boolean containsParameters( + long key) { + + return internalGetParameters().getMap().containsKey(key); + } + /** + * Use {@link #getParametersMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getParameters() { + return getParametersMap(); + } + /** + * map<int64, int64> parameters = 2; + */ + + public java.util.Map getParametersMap() { + return internalGetParameters().getMap(); + } + /** + * map<int64, int64> parameters = 2; + */ + + public long getParametersOrDefault( + long key, + long defaultValue) { + + java.util.Map map = + internalGetParameters().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<int64, int64> parameters = 2; + */ + + public long getParametersOrThrow( + long key) { + + java.util.Map map = + internalGetParameters().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeLongMapTo( + output, + internalGetParameters(), + ParametersDefaultEntryHolder.defaultEntry, + 2); + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + for (java.util.Map.Entry entry + : internalGetParameters().getMap().entrySet()) { + com.google.protobuf.MapEntry + parameters__ = ParametersDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, parameters__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ProposalCreateContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ProposalCreateContract other = (org.tron.protos.Contract.ProposalCreateContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && internalGetParameters().equals( + other.internalGetParameters()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + if (!internalGetParameters().getMap().isEmpty()) { + hash = (37 * hash) + PARAMETERS_FIELD_NUMBER; + hash = (53 * hash) + internalGetParameters().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalCreateContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalCreateContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalCreateContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ProposalCreateContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ProposalCreateContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ProposalCreateContract) + org.tron.protos.Contract.ProposalCreateContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ProposalCreateContract_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 2: + return internalGetParameters(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 2: + return internalGetMutableParameters(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ProposalCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ProposalCreateContract.class, org.tron.protos.Contract.ProposalCreateContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ProposalCreateContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + internalGetMutableParameters().clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ProposalCreateContract_descriptor; + } + + public org.tron.protos.Contract.ProposalCreateContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ProposalCreateContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ProposalCreateContract build() { + org.tron.protos.Contract.ProposalCreateContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ProposalCreateContract buildPartial() { + org.tron.protos.Contract.ProposalCreateContract result = new org.tron.protos.Contract.ProposalCreateContract(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.ownerAddress_ = ownerAddress_; + result.parameters_ = internalGetParameters(); + result.parameters_.makeImmutable(); + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ProposalCreateContract) { + return mergeFrom((org.tron.protos.Contract.ProposalCreateContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ProposalCreateContract other) { + if (other == org.tron.protos.Contract.ProposalCreateContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + internalGetMutableParameters().mergeFrom( + other.internalGetParameters()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ProposalCreateContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ProposalCreateContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.Long, java.lang.Long> parameters_; + private com.google.protobuf.MapField + internalGetParameters() { + if (parameters_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ParametersDefaultEntryHolder.defaultEntry); + } + return parameters_; + } + private com.google.protobuf.MapField + internalGetMutableParameters() { + onChanged();; + if (parameters_ == null) { + parameters_ = com.google.protobuf.MapField.newMapField( + ParametersDefaultEntryHolder.defaultEntry); + } + if (!parameters_.isMutable()) { + parameters_ = parameters_.copy(); + } + return parameters_; + } + + public int getParametersCount() { + return internalGetParameters().getMap().size(); + } + /** + * map<int64, int64> parameters = 2; + */ + + public boolean containsParameters( + long key) { + + return internalGetParameters().getMap().containsKey(key); + } + /** + * Use {@link #getParametersMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getParameters() { + return getParametersMap(); + } + /** + * map<int64, int64> parameters = 2; + */ + + public java.util.Map getParametersMap() { + return internalGetParameters().getMap(); + } + /** + * map<int64, int64> parameters = 2; + */ + + public long getParametersOrDefault( + long key, + long defaultValue) { + + java.util.Map map = + internalGetParameters().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<int64, int64> parameters = 2; + */ + + public long getParametersOrThrow( + long key) { + + java.util.Map map = + internalGetParameters().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearParameters() { + internalGetMutableParameters().getMutableMap() + .clear(); + return this; + } + /** + * map<int64, int64> parameters = 2; + */ + + public Builder removeParameters( + long key) { + + internalGetMutableParameters().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableParameters() { + return internalGetMutableParameters().getMutableMap(); + } + /** + * map<int64, int64> parameters = 2; + */ + public Builder putParameters( + long key, + long value) { + + + internalGetMutableParameters().getMutableMap() + .put(key, value); + return this; + } + /** + * map<int64, int64> parameters = 2; + */ + + public Builder putAllParameters( + java.util.Map values) { + internalGetMutableParameters().getMutableMap() + .putAll(values); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ProposalCreateContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ProposalCreateContract) + private static final org.tron.protos.Contract.ProposalCreateContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ProposalCreateContract(); + } + + public static org.tron.protos.Contract.ProposalCreateContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ProposalCreateContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ProposalCreateContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ProposalCreateContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ProposalApproveContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ProposalApproveContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * int64 proposal_id = 2; + */ + long getProposalId(); + + /** + *
+     * add or remove approval
+     * 
+ * + * bool is_add_approval = 3; + */ + boolean getIsAddApproval(); + } + /** + * Protobuf type {@code protocol.ProposalApproveContract} + */ + public static final class ProposalApproveContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ProposalApproveContract) + ProposalApproveContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ProposalApproveContract.newBuilder() to construct. + private ProposalApproveContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ProposalApproveContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + proposalId_ = 0L; + isAddApproval_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ProposalApproveContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + proposalId_ = input.readInt64(); + break; + } + case 24: { + + isAddApproval_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ProposalApproveContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ProposalApproveContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ProposalApproveContract.class, org.tron.protos.Contract.ProposalApproveContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int PROPOSAL_ID_FIELD_NUMBER = 2; + private long proposalId_; + /** + * int64 proposal_id = 2; + */ + public long getProposalId() { + return proposalId_; + } + + public static final int IS_ADD_APPROVAL_FIELD_NUMBER = 3; + private boolean isAddApproval_; + /** + *
+     * add or remove approval
+     * 
+ * + * bool is_add_approval = 3; + */ + public boolean getIsAddApproval() { + return isAddApproval_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (proposalId_ != 0L) { + output.writeInt64(2, proposalId_); + } + if (isAddApproval_ != false) { + output.writeBool(3, isAddApproval_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (proposalId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, proposalId_); + } + if (isAddApproval_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, isAddApproval_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ProposalApproveContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ProposalApproveContract other = (org.tron.protos.Contract.ProposalApproveContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getProposalId() + == other.getProposalId()); + result = result && (getIsAddApproval() + == other.getIsAddApproval()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + PROPOSAL_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getProposalId()); + hash = (37 * hash) + IS_ADD_APPROVAL_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIsAddApproval()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalApproveContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalApproveContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalApproveContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ProposalApproveContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ProposalApproveContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ProposalApproveContract) + org.tron.protos.Contract.ProposalApproveContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ProposalApproveContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ProposalApproveContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ProposalApproveContract.class, org.tron.protos.Contract.ProposalApproveContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ProposalApproveContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + proposalId_ = 0L; + + isAddApproval_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ProposalApproveContract_descriptor; + } + + public org.tron.protos.Contract.ProposalApproveContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ProposalApproveContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ProposalApproveContract build() { + org.tron.protos.Contract.ProposalApproveContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ProposalApproveContract buildPartial() { + org.tron.protos.Contract.ProposalApproveContract result = new org.tron.protos.Contract.ProposalApproveContract(this); + result.ownerAddress_ = ownerAddress_; + result.proposalId_ = proposalId_; + result.isAddApproval_ = isAddApproval_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ProposalApproveContract) { + return mergeFrom((org.tron.protos.Contract.ProposalApproveContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ProposalApproveContract other) { + if (other == org.tron.protos.Contract.ProposalApproveContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getProposalId() != 0L) { + setProposalId(other.getProposalId()); + } + if (other.getIsAddApproval() != false) { + setIsAddApproval(other.getIsAddApproval()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ProposalApproveContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ProposalApproveContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long proposalId_ ; + /** + * int64 proposal_id = 2; + */ + public long getProposalId() { + return proposalId_; + } + /** + * int64 proposal_id = 2; + */ + public Builder setProposalId(long value) { + + proposalId_ = value; + onChanged(); + return this; + } + /** + * int64 proposal_id = 2; + */ + public Builder clearProposalId() { + + proposalId_ = 0L; + onChanged(); + return this; + } + + private boolean isAddApproval_ ; + /** + *
+       * add or remove approval
+       * 
+ * + * bool is_add_approval = 3; + */ + public boolean getIsAddApproval() { + return isAddApproval_; + } + /** + *
+       * add or remove approval
+       * 
+ * + * bool is_add_approval = 3; + */ + public Builder setIsAddApproval(boolean value) { + + isAddApproval_ = value; + onChanged(); + return this; + } + /** + *
+       * add or remove approval
+       * 
+ * + * bool is_add_approval = 3; + */ + public Builder clearIsAddApproval() { + + isAddApproval_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ProposalApproveContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ProposalApproveContract) + private static final org.tron.protos.Contract.ProposalApproveContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ProposalApproveContract(); + } + + public static org.tron.protos.Contract.ProposalApproveContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ProposalApproveContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ProposalApproveContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ProposalApproveContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ProposalDeleteContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ProposalDeleteContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * int64 proposal_id = 2; + */ + long getProposalId(); + } + /** + * Protobuf type {@code protocol.ProposalDeleteContract} + */ + public static final class ProposalDeleteContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ProposalDeleteContract) + ProposalDeleteContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ProposalDeleteContract.newBuilder() to construct. + private ProposalDeleteContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ProposalDeleteContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + proposalId_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ProposalDeleteContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + proposalId_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ProposalDeleteContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ProposalDeleteContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ProposalDeleteContract.class, org.tron.protos.Contract.ProposalDeleteContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int PROPOSAL_ID_FIELD_NUMBER = 2; + private long proposalId_; + /** + * int64 proposal_id = 2; + */ + public long getProposalId() { + return proposalId_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (proposalId_ != 0L) { + output.writeInt64(2, proposalId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (proposalId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, proposalId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ProposalDeleteContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ProposalDeleteContract other = (org.tron.protos.Contract.ProposalDeleteContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getProposalId() + == other.getProposalId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + PROPOSAL_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getProposalId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ProposalDeleteContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ProposalDeleteContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ProposalDeleteContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ProposalDeleteContract) + org.tron.protos.Contract.ProposalDeleteContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ProposalDeleteContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ProposalDeleteContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ProposalDeleteContract.class, org.tron.protos.Contract.ProposalDeleteContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ProposalDeleteContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + proposalId_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ProposalDeleteContract_descriptor; + } + + public org.tron.protos.Contract.ProposalDeleteContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ProposalDeleteContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ProposalDeleteContract build() { + org.tron.protos.Contract.ProposalDeleteContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ProposalDeleteContract buildPartial() { + org.tron.protos.Contract.ProposalDeleteContract result = new org.tron.protos.Contract.ProposalDeleteContract(this); + result.ownerAddress_ = ownerAddress_; + result.proposalId_ = proposalId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ProposalDeleteContract) { + return mergeFrom((org.tron.protos.Contract.ProposalDeleteContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ProposalDeleteContract other) { + if (other == org.tron.protos.Contract.ProposalDeleteContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getProposalId() != 0L) { + setProposalId(other.getProposalId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ProposalDeleteContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ProposalDeleteContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long proposalId_ ; + /** + * int64 proposal_id = 2; + */ + public long getProposalId() { + return proposalId_; + } + /** + * int64 proposal_id = 2; + */ + public Builder setProposalId(long value) { + + proposalId_ = value; + onChanged(); + return this; + } + /** + * int64 proposal_id = 2; + */ + public Builder clearProposalId() { + + proposalId_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ProposalDeleteContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ProposalDeleteContract) + private static final org.tron.protos.Contract.ProposalDeleteContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ProposalDeleteContract(); + } + + public static org.tron.protos.Contract.ProposalDeleteContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ProposalDeleteContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ProposalDeleteContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ProposalDeleteContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface CreateSmartContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.CreateSmartContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * .protocol.SmartContract new_contract = 2; + */ + boolean hasNewContract(); + /** + * .protocol.SmartContract new_contract = 2; + */ + org.tron.protos.Protocol.SmartContract getNewContract(); + /** + * .protocol.SmartContract new_contract = 2; + */ + org.tron.protos.Protocol.SmartContractOrBuilder getNewContractOrBuilder(); + + /** + * int64 call_token_value = 3; + */ + long getCallTokenValue(); + + /** + * int64 token_id = 4; + */ + long getTokenId(); + } + /** + * Protobuf type {@code protocol.CreateSmartContract} + */ + public static final class CreateSmartContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.CreateSmartContract) + CreateSmartContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use CreateSmartContract.newBuilder() to construct. + private CreateSmartContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private CreateSmartContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + callTokenValue_ = 0L; + tokenId_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CreateSmartContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + org.tron.protos.Protocol.SmartContract.Builder subBuilder = null; + if (newContract_ != null) { + subBuilder = newContract_.toBuilder(); + } + newContract_ = input.readMessage(org.tron.protos.Protocol.SmartContract.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(newContract_); + newContract_ = subBuilder.buildPartial(); + } + + break; + } + case 24: { + + callTokenValue_ = input.readInt64(); + break; + } + case 32: { + + tokenId_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_CreateSmartContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_CreateSmartContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.CreateSmartContract.class, org.tron.protos.Contract.CreateSmartContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int NEW_CONTRACT_FIELD_NUMBER = 2; + private org.tron.protos.Protocol.SmartContract newContract_; + /** + * .protocol.SmartContract new_contract = 2; + */ + public boolean hasNewContract() { + return newContract_ != null; + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public org.tron.protos.Protocol.SmartContract getNewContract() { + return newContract_ == null ? org.tron.protos.Protocol.SmartContract.getDefaultInstance() : newContract_; + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public org.tron.protos.Protocol.SmartContractOrBuilder getNewContractOrBuilder() { + return getNewContract(); + } + + public static final int CALL_TOKEN_VALUE_FIELD_NUMBER = 3; + private long callTokenValue_; + /** + * int64 call_token_value = 3; + */ + public long getCallTokenValue() { + return callTokenValue_; + } + + public static final int TOKEN_ID_FIELD_NUMBER = 4; + private long tokenId_; + /** + * int64 token_id = 4; + */ + public long getTokenId() { + return tokenId_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (newContract_ != null) { + output.writeMessage(2, getNewContract()); + } + if (callTokenValue_ != 0L) { + output.writeInt64(3, callTokenValue_); + } + if (tokenId_ != 0L) { + output.writeInt64(4, tokenId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (newContract_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getNewContract()); + } + if (callTokenValue_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, callTokenValue_); + } + if (tokenId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, tokenId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.CreateSmartContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.CreateSmartContract other = (org.tron.protos.Contract.CreateSmartContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (hasNewContract() == other.hasNewContract()); + if (hasNewContract()) { + result = result && getNewContract() + .equals(other.getNewContract()); + } + result = result && (getCallTokenValue() + == other.getCallTokenValue()); + result = result && (getTokenId() + == other.getTokenId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + if (hasNewContract()) { + hash = (37 * hash) + NEW_CONTRACT_FIELD_NUMBER; + hash = (53 * hash) + getNewContract().hashCode(); + } + hash = (37 * hash) + CALL_TOKEN_VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCallTokenValue()); + hash = (37 * hash) + TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTokenId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.CreateSmartContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.CreateSmartContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.CreateSmartContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.CreateSmartContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.CreateSmartContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.CreateSmartContract) + org.tron.protos.Contract.CreateSmartContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_CreateSmartContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_CreateSmartContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.CreateSmartContract.class, org.tron.protos.Contract.CreateSmartContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.CreateSmartContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + if (newContractBuilder_ == null) { + newContract_ = null; + } else { + newContract_ = null; + newContractBuilder_ = null; + } + callTokenValue_ = 0L; + + tokenId_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_CreateSmartContract_descriptor; + } + + public org.tron.protos.Contract.CreateSmartContract getDefaultInstanceForType() { + return org.tron.protos.Contract.CreateSmartContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.CreateSmartContract build() { + org.tron.protos.Contract.CreateSmartContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.CreateSmartContract buildPartial() { + org.tron.protos.Contract.CreateSmartContract result = new org.tron.protos.Contract.CreateSmartContract(this); + result.ownerAddress_ = ownerAddress_; + if (newContractBuilder_ == null) { + result.newContract_ = newContract_; + } else { + result.newContract_ = newContractBuilder_.build(); + } + result.callTokenValue_ = callTokenValue_; + result.tokenId_ = tokenId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.CreateSmartContract) { + return mergeFrom((org.tron.protos.Contract.CreateSmartContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.CreateSmartContract other) { + if (other == org.tron.protos.Contract.CreateSmartContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.hasNewContract()) { + mergeNewContract(other.getNewContract()); + } + if (other.getCallTokenValue() != 0L) { + setCallTokenValue(other.getCallTokenValue()); + } + if (other.getTokenId() != 0L) { + setTokenId(other.getTokenId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.CreateSmartContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.CreateSmartContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private org.tron.protos.Protocol.SmartContract newContract_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.SmartContract, org.tron.protos.Protocol.SmartContract.Builder, org.tron.protos.Protocol.SmartContractOrBuilder> newContractBuilder_; + /** + * .protocol.SmartContract new_contract = 2; + */ + public boolean hasNewContract() { + return newContractBuilder_ != null || newContract_ != null; + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public org.tron.protos.Protocol.SmartContract getNewContract() { + if (newContractBuilder_ == null) { + return newContract_ == null ? org.tron.protos.Protocol.SmartContract.getDefaultInstance() : newContract_; + } else { + return newContractBuilder_.getMessage(); + } + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public Builder setNewContract(org.tron.protos.Protocol.SmartContract value) { + if (newContractBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + newContract_ = value; + onChanged(); + } else { + newContractBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public Builder setNewContract( + org.tron.protos.Protocol.SmartContract.Builder builderForValue) { + if (newContractBuilder_ == null) { + newContract_ = builderForValue.build(); + onChanged(); + } else { + newContractBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public Builder mergeNewContract(org.tron.protos.Protocol.SmartContract value) { + if (newContractBuilder_ == null) { + if (newContract_ != null) { + newContract_ = + org.tron.protos.Protocol.SmartContract.newBuilder(newContract_).mergeFrom(value).buildPartial(); + } else { + newContract_ = value; + } + onChanged(); + } else { + newContractBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public Builder clearNewContract() { + if (newContractBuilder_ == null) { + newContract_ = null; + onChanged(); + } else { + newContract_ = null; + newContractBuilder_ = null; + } + + return this; + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public org.tron.protos.Protocol.SmartContract.Builder getNewContractBuilder() { + + onChanged(); + return getNewContractFieldBuilder().getBuilder(); + } + /** + * .protocol.SmartContract new_contract = 2; + */ + public org.tron.protos.Protocol.SmartContractOrBuilder getNewContractOrBuilder() { + if (newContractBuilder_ != null) { + return newContractBuilder_.getMessageOrBuilder(); + } else { + return newContract_ == null ? + org.tron.protos.Protocol.SmartContract.getDefaultInstance() : newContract_; + } + } + /** + * .protocol.SmartContract new_contract = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.SmartContract, org.tron.protos.Protocol.SmartContract.Builder, org.tron.protos.Protocol.SmartContractOrBuilder> + getNewContractFieldBuilder() { + if (newContractBuilder_ == null) { + newContractBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.SmartContract, org.tron.protos.Protocol.SmartContract.Builder, org.tron.protos.Protocol.SmartContractOrBuilder>( + getNewContract(), + getParentForChildren(), + isClean()); + newContract_ = null; + } + return newContractBuilder_; + } + + private long callTokenValue_ ; + /** + * int64 call_token_value = 3; + */ + public long getCallTokenValue() { + return callTokenValue_; + } + /** + * int64 call_token_value = 3; + */ + public Builder setCallTokenValue(long value) { + + callTokenValue_ = value; + onChanged(); + return this; + } + /** + * int64 call_token_value = 3; + */ + public Builder clearCallTokenValue() { + + callTokenValue_ = 0L; + onChanged(); + return this; + } + + private long tokenId_ ; + /** + * int64 token_id = 4; + */ + public long getTokenId() { + return tokenId_; + } + /** + * int64 token_id = 4; + */ + public Builder setTokenId(long value) { + + tokenId_ = value; + onChanged(); + return this; + } + /** + * int64 token_id = 4; + */ + public Builder clearTokenId() { + + tokenId_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.CreateSmartContract) + } + + // @@protoc_insertion_point(class_scope:protocol.CreateSmartContract) + private static final org.tron.protos.Contract.CreateSmartContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.CreateSmartContract(); + } + + public static org.tron.protos.Contract.CreateSmartContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CreateSmartContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CreateSmartContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.CreateSmartContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TriggerSmartContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TriggerSmartContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes contract_address = 2; + */ + com.google.protobuf.ByteString getContractAddress(); + + /** + * int64 call_value = 3; + */ + long getCallValue(); + + /** + * bytes data = 4; + */ + com.google.protobuf.ByteString getData(); + + /** + * int64 call_token_value = 5; + */ + long getCallTokenValue(); + + /** + * int64 token_id = 6; + */ + long getTokenId(); + } + /** + * Protobuf type {@code protocol.TriggerSmartContract} + */ + public static final class TriggerSmartContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TriggerSmartContract) + TriggerSmartContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use TriggerSmartContract.newBuilder() to construct. + private TriggerSmartContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TriggerSmartContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + callValue_ = 0L; + data_ = com.google.protobuf.ByteString.EMPTY; + callTokenValue_ = 0L; + tokenId_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TriggerSmartContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + contractAddress_ = input.readBytes(); + break; + } + case 24: { + + callValue_ = input.readInt64(); + break; + } + case 34: { + + data_ = input.readBytes(); + break; + } + case 40: { + + callTokenValue_ = input.readInt64(); + break; + } + case 48: { + + tokenId_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_TriggerSmartContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_TriggerSmartContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.TriggerSmartContract.class, org.tron.protos.Contract.TriggerSmartContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int CONTRACT_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString contractAddress_; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + + public static final int CALL_VALUE_FIELD_NUMBER = 3; + private long callValue_; + /** + * int64 call_value = 3; + */ + public long getCallValue() { + return callValue_; + } + + public static final int DATA_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString data_; + /** + * bytes data = 4; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + + public static final int CALL_TOKEN_VALUE_FIELD_NUMBER = 5; + private long callTokenValue_; + /** + * int64 call_token_value = 5; + */ + public long getCallTokenValue() { + return callTokenValue_; + } + + public static final int TOKEN_ID_FIELD_NUMBER = 6; + private long tokenId_; + /** + * int64 token_id = 6; + */ + public long getTokenId() { + return tokenId_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + output.writeBytes(2, contractAddress_); + } + if (callValue_ != 0L) { + output.writeInt64(3, callValue_); + } + if (!data_.isEmpty()) { + output.writeBytes(4, data_); + } + if (callTokenValue_ != 0L) { + output.writeInt64(5, callTokenValue_); + } + if (tokenId_ != 0L) { + output.writeInt64(6, tokenId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!contractAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, contractAddress_); + } + if (callValue_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, callValue_); + } + if (!data_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, data_); + } + if (callTokenValue_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, callTokenValue_); + } + if (tokenId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, tokenId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.TriggerSmartContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.TriggerSmartContract other = (org.tron.protos.Contract.TriggerSmartContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getContractAddress() + .equals(other.getContractAddress()); + result = result && (getCallValue() + == other.getCallValue()); + result = result && getData() + .equals(other.getData()); + result = result && (getCallTokenValue() + == other.getCallTokenValue()); + result = result && (getTokenId() + == other.getTokenId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + CONTRACT_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getContractAddress().hashCode(); + hash = (37 * hash) + CALL_VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCallValue()); + hash = (37 * hash) + DATA_FIELD_NUMBER; + hash = (53 * hash) + getData().hashCode(); + hash = (37 * hash) + CALL_TOKEN_VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCallTokenValue()); + hash = (37 * hash) + TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTokenId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.TriggerSmartContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TriggerSmartContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.TriggerSmartContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.TriggerSmartContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TriggerSmartContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TriggerSmartContract) + org.tron.protos.Contract.TriggerSmartContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_TriggerSmartContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_TriggerSmartContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.TriggerSmartContract.class, org.tron.protos.Contract.TriggerSmartContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.TriggerSmartContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + + callValue_ = 0L; + + data_ = com.google.protobuf.ByteString.EMPTY; + + callTokenValue_ = 0L; + + tokenId_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_TriggerSmartContract_descriptor; + } + + public org.tron.protos.Contract.TriggerSmartContract getDefaultInstanceForType() { + return org.tron.protos.Contract.TriggerSmartContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.TriggerSmartContract build() { + org.tron.protos.Contract.TriggerSmartContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.TriggerSmartContract buildPartial() { + org.tron.protos.Contract.TriggerSmartContract result = new org.tron.protos.Contract.TriggerSmartContract(this); + result.ownerAddress_ = ownerAddress_; + result.contractAddress_ = contractAddress_; + result.callValue_ = callValue_; + result.data_ = data_; + result.callTokenValue_ = callTokenValue_; + result.tokenId_ = tokenId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.TriggerSmartContract) { + return mergeFrom((org.tron.protos.Contract.TriggerSmartContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.TriggerSmartContract other) { + if (other == org.tron.protos.Contract.TriggerSmartContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getContractAddress() != com.google.protobuf.ByteString.EMPTY) { + setContractAddress(other.getContractAddress()); + } + if (other.getCallValue() != 0L) { + setCallValue(other.getCallValue()); + } + if (other.getData() != com.google.protobuf.ByteString.EMPTY) { + setData(other.getData()); + } + if (other.getCallTokenValue() != 0L) { + setCallTokenValue(other.getCallTokenValue()); + } + if (other.getTokenId() != 0L) { + setTokenId(other.getTokenId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.TriggerSmartContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.TriggerSmartContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString contractAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + /** + * bytes contract_address = 2; + */ + public Builder setContractAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + contractAddress_ = value; + onChanged(); + return this; + } + /** + * bytes contract_address = 2; + */ + public Builder clearContractAddress() { + + contractAddress_ = getDefaultInstance().getContractAddress(); + onChanged(); + return this; + } + + private long callValue_ ; + /** + * int64 call_value = 3; + */ + public long getCallValue() { + return callValue_; + } + /** + * int64 call_value = 3; + */ + public Builder setCallValue(long value) { + + callValue_ = value; + onChanged(); + return this; + } + /** + * int64 call_value = 3; + */ + public Builder clearCallValue() { + + callValue_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes data = 4; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + /** + * bytes data = 4; + */ + public Builder setData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + data_ = value; + onChanged(); + return this; + } + /** + * bytes data = 4; + */ + public Builder clearData() { + + data_ = getDefaultInstance().getData(); + onChanged(); + return this; + } + + private long callTokenValue_ ; + /** + * int64 call_token_value = 5; + */ + public long getCallTokenValue() { + return callTokenValue_; + } + /** + * int64 call_token_value = 5; + */ + public Builder setCallTokenValue(long value) { + + callTokenValue_ = value; + onChanged(); + return this; + } + /** + * int64 call_token_value = 5; + */ + public Builder clearCallTokenValue() { + + callTokenValue_ = 0L; + onChanged(); + return this; + } + + private long tokenId_ ; + /** + * int64 token_id = 6; + */ + public long getTokenId() { + return tokenId_; + } + /** + * int64 token_id = 6; + */ + public Builder setTokenId(long value) { + + tokenId_ = value; + onChanged(); + return this; + } + /** + * int64 token_id = 6; + */ + public Builder clearTokenId() { + + tokenId_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TriggerSmartContract) + } + + // @@protoc_insertion_point(class_scope:protocol.TriggerSmartContract) + private static final org.tron.protos.Contract.TriggerSmartContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.TriggerSmartContract(); + } + + public static org.tron.protos.Contract.TriggerSmartContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TriggerSmartContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TriggerSmartContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.TriggerSmartContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BuyStorageContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BuyStorageContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + *
+     * trx quantity for buy storage (sun)
+     * 
+ * + * int64 quant = 2; + */ + long getQuant(); + } + /** + * Protobuf type {@code protocol.BuyStorageContract} + */ + public static final class BuyStorageContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BuyStorageContract) + BuyStorageContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use BuyStorageContract.newBuilder() to construct. + private BuyStorageContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BuyStorageContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + quant_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BuyStorageContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + quant_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.BuyStorageContract.class, org.tron.protos.Contract.BuyStorageContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int QUANT_FIELD_NUMBER = 2; + private long quant_; + /** + *
+     * trx quantity for buy storage (sun)
+     * 
+ * + * int64 quant = 2; + */ + public long getQuant() { + return quant_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (quant_ != 0L) { + output.writeInt64(2, quant_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (quant_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, quant_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.BuyStorageContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.BuyStorageContract other = (org.tron.protos.Contract.BuyStorageContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getQuant() + == other.getQuant()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + QUANT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getQuant()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.BuyStorageContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.BuyStorageContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.BuyStorageContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BuyStorageContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BuyStorageContract) + org.tron.protos.Contract.BuyStorageContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.BuyStorageContract.class, org.tron.protos.Contract.BuyStorageContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.BuyStorageContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + quant_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageContract_descriptor; + } + + public org.tron.protos.Contract.BuyStorageContract getDefaultInstanceForType() { + return org.tron.protos.Contract.BuyStorageContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.BuyStorageContract build() { + org.tron.protos.Contract.BuyStorageContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.BuyStorageContract buildPartial() { + org.tron.protos.Contract.BuyStorageContract result = new org.tron.protos.Contract.BuyStorageContract(this); + result.ownerAddress_ = ownerAddress_; + result.quant_ = quant_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.BuyStorageContract) { + return mergeFrom((org.tron.protos.Contract.BuyStorageContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.BuyStorageContract other) { + if (other == org.tron.protos.Contract.BuyStorageContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getQuant() != 0L) { + setQuant(other.getQuant()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.BuyStorageContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.BuyStorageContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long quant_ ; + /** + *
+       * trx quantity for buy storage (sun)
+       * 
+ * + * int64 quant = 2; + */ + public long getQuant() { + return quant_; + } + /** + *
+       * trx quantity for buy storage (sun)
+       * 
+ * + * int64 quant = 2; + */ + public Builder setQuant(long value) { + + quant_ = value; + onChanged(); + return this; + } + /** + *
+       * trx quantity for buy storage (sun)
+       * 
+ * + * int64 quant = 2; + */ + public Builder clearQuant() { + + quant_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BuyStorageContract) + } + + // @@protoc_insertion_point(class_scope:protocol.BuyStorageContract) + private static final org.tron.protos.Contract.BuyStorageContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.BuyStorageContract(); + } + + public static org.tron.protos.Contract.BuyStorageContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BuyStorageContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BuyStorageContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.BuyStorageContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BuyStorageBytesContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BuyStorageBytesContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + *
+     * storage bytes for buy
+     * 
+ * + * int64 bytes = 2; + */ + long getBytes(); + } + /** + * Protobuf type {@code protocol.BuyStorageBytesContract} + */ + public static final class BuyStorageBytesContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BuyStorageBytesContract) + BuyStorageBytesContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use BuyStorageBytesContract.newBuilder() to construct. + private BuyStorageBytesContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BuyStorageBytesContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + bytes_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BuyStorageBytesContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + bytes_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageBytesContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageBytesContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.BuyStorageBytesContract.class, org.tron.protos.Contract.BuyStorageBytesContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int BYTES_FIELD_NUMBER = 2; + private long bytes_; + /** + *
+     * storage bytes for buy
+     * 
+ * + * int64 bytes = 2; + */ + public long getBytes() { + return bytes_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (bytes_ != 0L) { + output.writeInt64(2, bytes_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (bytes_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, bytes_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.BuyStorageBytesContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.BuyStorageBytesContract other = (org.tron.protos.Contract.BuyStorageBytesContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getBytes() + == other.getBytes()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + BYTES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBytes()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.BuyStorageBytesContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.BuyStorageBytesContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BuyStorageBytesContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BuyStorageBytesContract) + org.tron.protos.Contract.BuyStorageBytesContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageBytesContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageBytesContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.BuyStorageBytesContract.class, org.tron.protos.Contract.BuyStorageBytesContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.BuyStorageBytesContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + bytes_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_BuyStorageBytesContract_descriptor; + } + + public org.tron.protos.Contract.BuyStorageBytesContract getDefaultInstanceForType() { + return org.tron.protos.Contract.BuyStorageBytesContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.BuyStorageBytesContract build() { + org.tron.protos.Contract.BuyStorageBytesContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.BuyStorageBytesContract buildPartial() { + org.tron.protos.Contract.BuyStorageBytesContract result = new org.tron.protos.Contract.BuyStorageBytesContract(this); + result.ownerAddress_ = ownerAddress_; + result.bytes_ = bytes_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.BuyStorageBytesContract) { + return mergeFrom((org.tron.protos.Contract.BuyStorageBytesContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.BuyStorageBytesContract other) { + if (other == org.tron.protos.Contract.BuyStorageBytesContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getBytes() != 0L) { + setBytes(other.getBytes()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.BuyStorageBytesContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.BuyStorageBytesContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long bytes_ ; + /** + *
+       * storage bytes for buy
+       * 
+ * + * int64 bytes = 2; + */ + public long getBytes() { + return bytes_; + } + /** + *
+       * storage bytes for buy
+       * 
+ * + * int64 bytes = 2; + */ + public Builder setBytes(long value) { + + bytes_ = value; + onChanged(); + return this; + } + /** + *
+       * storage bytes for buy
+       * 
+ * + * int64 bytes = 2; + */ + public Builder clearBytes() { + + bytes_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BuyStorageBytesContract) + } + + // @@protoc_insertion_point(class_scope:protocol.BuyStorageBytesContract) + private static final org.tron.protos.Contract.BuyStorageBytesContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.BuyStorageBytesContract(); + } + + public static org.tron.protos.Contract.BuyStorageBytesContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BuyStorageBytesContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BuyStorageBytesContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.BuyStorageBytesContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SellStorageContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.SellStorageContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * int64 storage_bytes = 2; + */ + long getStorageBytes(); + } + /** + * Protobuf type {@code protocol.SellStorageContract} + */ + public static final class SellStorageContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.SellStorageContract) + SellStorageContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use SellStorageContract.newBuilder() to construct. + private SellStorageContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SellStorageContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + storageBytes_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SellStorageContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + storageBytes_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_SellStorageContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_SellStorageContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.SellStorageContract.class, org.tron.protos.Contract.SellStorageContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int STORAGE_BYTES_FIELD_NUMBER = 2; + private long storageBytes_; + /** + * int64 storage_bytes = 2; + */ + public long getStorageBytes() { + return storageBytes_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (storageBytes_ != 0L) { + output.writeInt64(2, storageBytes_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (storageBytes_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, storageBytes_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.SellStorageContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.SellStorageContract other = (org.tron.protos.Contract.SellStorageContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getStorageBytes() + == other.getStorageBytes()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + STORAGE_BYTES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getStorageBytes()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.SellStorageContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.SellStorageContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.SellStorageContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.SellStorageContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.SellStorageContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.SellStorageContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.SellStorageContract) + org.tron.protos.Contract.SellStorageContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_SellStorageContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_SellStorageContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.SellStorageContract.class, org.tron.protos.Contract.SellStorageContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.SellStorageContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + storageBytes_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_SellStorageContract_descriptor; + } + + public org.tron.protos.Contract.SellStorageContract getDefaultInstanceForType() { + return org.tron.protos.Contract.SellStorageContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.SellStorageContract build() { + org.tron.protos.Contract.SellStorageContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.SellStorageContract buildPartial() { + org.tron.protos.Contract.SellStorageContract result = new org.tron.protos.Contract.SellStorageContract(this); + result.ownerAddress_ = ownerAddress_; + result.storageBytes_ = storageBytes_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.SellStorageContract) { + return mergeFrom((org.tron.protos.Contract.SellStorageContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.SellStorageContract other) { + if (other == org.tron.protos.Contract.SellStorageContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getStorageBytes() != 0L) { + setStorageBytes(other.getStorageBytes()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.SellStorageContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.SellStorageContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long storageBytes_ ; + /** + * int64 storage_bytes = 2; + */ + public long getStorageBytes() { + return storageBytes_; + } + /** + * int64 storage_bytes = 2; + */ + public Builder setStorageBytes(long value) { + + storageBytes_ = value; + onChanged(); + return this; + } + /** + * int64 storage_bytes = 2; + */ + public Builder clearStorageBytes() { + + storageBytes_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.SellStorageContract) + } + + // @@protoc_insertion_point(class_scope:protocol.SellStorageContract) + private static final org.tron.protos.Contract.SellStorageContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.SellStorageContract(); + } + + public static org.tron.protos.Contract.SellStorageContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public SellStorageContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SellStorageContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.SellStorageContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ExchangeCreateContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ExchangeCreateContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * bytes first_token_id = 2; + */ + com.google.protobuf.ByteString getFirstTokenId(); + + /** + * int64 first_token_balance = 3; + */ + long getFirstTokenBalance(); + + /** + * bytes second_token_id = 4; + */ + com.google.protobuf.ByteString getSecondTokenId(); + + /** + * int64 second_token_balance = 5; + */ + long getSecondTokenBalance(); + } + /** + * Protobuf type {@code protocol.ExchangeCreateContract} + */ + public static final class ExchangeCreateContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ExchangeCreateContract) + ExchangeCreateContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExchangeCreateContract.newBuilder() to construct. + private ExchangeCreateContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExchangeCreateContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + firstTokenId_ = com.google.protobuf.ByteString.EMPTY; + firstTokenBalance_ = 0L; + secondTokenId_ = com.google.protobuf.ByteString.EMPTY; + secondTokenBalance_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExchangeCreateContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + + firstTokenId_ = input.readBytes(); + break; + } + case 24: { + + firstTokenBalance_ = input.readInt64(); + break; + } + case 34: { + + secondTokenId_ = input.readBytes(); + break; + } + case 40: { + + secondTokenBalance_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeCreateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeCreateContract.class, org.tron.protos.Contract.ExchangeCreateContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int FIRST_TOKEN_ID_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString firstTokenId_; + /** + * bytes first_token_id = 2; + */ + public com.google.protobuf.ByteString getFirstTokenId() { + return firstTokenId_; + } + + public static final int FIRST_TOKEN_BALANCE_FIELD_NUMBER = 3; + private long firstTokenBalance_; + /** + * int64 first_token_balance = 3; + */ + public long getFirstTokenBalance() { + return firstTokenBalance_; + } + + public static final int SECOND_TOKEN_ID_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString secondTokenId_; + /** + * bytes second_token_id = 4; + */ + public com.google.protobuf.ByteString getSecondTokenId() { + return secondTokenId_; + } + + public static final int SECOND_TOKEN_BALANCE_FIELD_NUMBER = 5; + private long secondTokenBalance_; + /** + * int64 second_token_balance = 5; + */ + public long getSecondTokenBalance() { + return secondTokenBalance_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (!firstTokenId_.isEmpty()) { + output.writeBytes(2, firstTokenId_); + } + if (firstTokenBalance_ != 0L) { + output.writeInt64(3, firstTokenBalance_); + } + if (!secondTokenId_.isEmpty()) { + output.writeBytes(4, secondTokenId_); + } + if (secondTokenBalance_ != 0L) { + output.writeInt64(5, secondTokenBalance_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (!firstTokenId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, firstTokenId_); + } + if (firstTokenBalance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, firstTokenBalance_); + } + if (!secondTokenId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, secondTokenId_); + } + if (secondTokenBalance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, secondTokenBalance_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ExchangeCreateContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ExchangeCreateContract other = (org.tron.protos.Contract.ExchangeCreateContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && getFirstTokenId() + .equals(other.getFirstTokenId()); + result = result && (getFirstTokenBalance() + == other.getFirstTokenBalance()); + result = result && getSecondTokenId() + .equals(other.getSecondTokenId()); + result = result && (getSecondTokenBalance() + == other.getSecondTokenBalance()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + FIRST_TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getFirstTokenId().hashCode(); + hash = (37 * hash) + FIRST_TOKEN_BALANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFirstTokenBalance()); + hash = (37 * hash) + SECOND_TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getSecondTokenId().hashCode(); + hash = (37 * hash) + SECOND_TOKEN_BALANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSecondTokenBalance()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeCreateContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ExchangeCreateContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ExchangeCreateContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ExchangeCreateContract) + org.tron.protos.Contract.ExchangeCreateContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeCreateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeCreateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeCreateContract.class, org.tron.protos.Contract.ExchangeCreateContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ExchangeCreateContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + firstTokenId_ = com.google.protobuf.ByteString.EMPTY; + + firstTokenBalance_ = 0L; + + secondTokenId_ = com.google.protobuf.ByteString.EMPTY; + + secondTokenBalance_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeCreateContract_descriptor; + } + + public org.tron.protos.Contract.ExchangeCreateContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ExchangeCreateContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ExchangeCreateContract build() { + org.tron.protos.Contract.ExchangeCreateContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ExchangeCreateContract buildPartial() { + org.tron.protos.Contract.ExchangeCreateContract result = new org.tron.protos.Contract.ExchangeCreateContract(this); + result.ownerAddress_ = ownerAddress_; + result.firstTokenId_ = firstTokenId_; + result.firstTokenBalance_ = firstTokenBalance_; + result.secondTokenId_ = secondTokenId_; + result.secondTokenBalance_ = secondTokenBalance_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ExchangeCreateContract) { + return mergeFrom((org.tron.protos.Contract.ExchangeCreateContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ExchangeCreateContract other) { + if (other == org.tron.protos.Contract.ExchangeCreateContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getFirstTokenId() != com.google.protobuf.ByteString.EMPTY) { + setFirstTokenId(other.getFirstTokenId()); + } + if (other.getFirstTokenBalance() != 0L) { + setFirstTokenBalance(other.getFirstTokenBalance()); + } + if (other.getSecondTokenId() != com.google.protobuf.ByteString.EMPTY) { + setSecondTokenId(other.getSecondTokenId()); + } + if (other.getSecondTokenBalance() != 0L) { + setSecondTokenBalance(other.getSecondTokenBalance()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ExchangeCreateContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ExchangeCreateContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString firstTokenId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes first_token_id = 2; + */ + public com.google.protobuf.ByteString getFirstTokenId() { + return firstTokenId_; + } + /** + * bytes first_token_id = 2; + */ + public Builder setFirstTokenId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + firstTokenId_ = value; + onChanged(); + return this; + } + /** + * bytes first_token_id = 2; + */ + public Builder clearFirstTokenId() { + + firstTokenId_ = getDefaultInstance().getFirstTokenId(); + onChanged(); + return this; + } + + private long firstTokenBalance_ ; + /** + * int64 first_token_balance = 3; + */ + public long getFirstTokenBalance() { + return firstTokenBalance_; + } + /** + * int64 first_token_balance = 3; + */ + public Builder setFirstTokenBalance(long value) { + + firstTokenBalance_ = value; + onChanged(); + return this; + } + /** + * int64 first_token_balance = 3; + */ + public Builder clearFirstTokenBalance() { + + firstTokenBalance_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString secondTokenId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes second_token_id = 4; + */ + public com.google.protobuf.ByteString getSecondTokenId() { + return secondTokenId_; + } + /** + * bytes second_token_id = 4; + */ + public Builder setSecondTokenId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + secondTokenId_ = value; + onChanged(); + return this; + } + /** + * bytes second_token_id = 4; + */ + public Builder clearSecondTokenId() { + + secondTokenId_ = getDefaultInstance().getSecondTokenId(); + onChanged(); + return this; + } + + private long secondTokenBalance_ ; + /** + * int64 second_token_balance = 5; + */ + public long getSecondTokenBalance() { + return secondTokenBalance_; + } + /** + * int64 second_token_balance = 5; + */ + public Builder setSecondTokenBalance(long value) { + + secondTokenBalance_ = value; + onChanged(); + return this; + } + /** + * int64 second_token_balance = 5; + */ + public Builder clearSecondTokenBalance() { + + secondTokenBalance_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ExchangeCreateContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ExchangeCreateContract) + private static final org.tron.protos.Contract.ExchangeCreateContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ExchangeCreateContract(); + } + + public static org.tron.protos.Contract.ExchangeCreateContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExchangeCreateContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExchangeCreateContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ExchangeCreateContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ExchangeInjectContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ExchangeInjectContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * int64 exchange_id = 2; + */ + long getExchangeId(); + + /** + * bytes token_id = 3; + */ + com.google.protobuf.ByteString getTokenId(); + + /** + * int64 quant = 4; + */ + long getQuant(); + } + /** + * Protobuf type {@code protocol.ExchangeInjectContract} + */ + public static final class ExchangeInjectContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ExchangeInjectContract) + ExchangeInjectContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExchangeInjectContract.newBuilder() to construct. + private ExchangeInjectContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExchangeInjectContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + exchangeId_ = 0L; + tokenId_ = com.google.protobuf.ByteString.EMPTY; + quant_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExchangeInjectContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + exchangeId_ = input.readInt64(); + break; + } + case 26: { + + tokenId_ = input.readBytes(); + break; + } + case 32: { + + quant_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeInjectContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeInjectContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeInjectContract.class, org.tron.protos.Contract.ExchangeInjectContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int EXCHANGE_ID_FIELD_NUMBER = 2; + private long exchangeId_; + /** + * int64 exchange_id = 2; + */ + public long getExchangeId() { + return exchangeId_; + } + + public static final int TOKEN_ID_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString tokenId_; + /** + * bytes token_id = 3; + */ + public com.google.protobuf.ByteString getTokenId() { + return tokenId_; + } + + public static final int QUANT_FIELD_NUMBER = 4; + private long quant_; + /** + * int64 quant = 4; + */ + public long getQuant() { + return quant_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (exchangeId_ != 0L) { + output.writeInt64(2, exchangeId_); + } + if (!tokenId_.isEmpty()) { + output.writeBytes(3, tokenId_); + } + if (quant_ != 0L) { + output.writeInt64(4, quant_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (exchangeId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, exchangeId_); + } + if (!tokenId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, tokenId_); + } + if (quant_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, quant_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ExchangeInjectContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ExchangeInjectContract other = (org.tron.protos.Contract.ExchangeInjectContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getExchangeId() + == other.getExchangeId()); + result = result && getTokenId() + .equals(other.getTokenId()); + result = result && (getQuant() + == other.getQuant()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + EXCHANGE_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeId()); + hash = (37 * hash) + TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getTokenId().hashCode(); + hash = (37 * hash) + QUANT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getQuant()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeInjectContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ExchangeInjectContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ExchangeInjectContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ExchangeInjectContract) + org.tron.protos.Contract.ExchangeInjectContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeInjectContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeInjectContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeInjectContract.class, org.tron.protos.Contract.ExchangeInjectContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ExchangeInjectContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + exchangeId_ = 0L; + + tokenId_ = com.google.protobuf.ByteString.EMPTY; + + quant_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeInjectContract_descriptor; + } + + public org.tron.protos.Contract.ExchangeInjectContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ExchangeInjectContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ExchangeInjectContract build() { + org.tron.protos.Contract.ExchangeInjectContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ExchangeInjectContract buildPartial() { + org.tron.protos.Contract.ExchangeInjectContract result = new org.tron.protos.Contract.ExchangeInjectContract(this); + result.ownerAddress_ = ownerAddress_; + result.exchangeId_ = exchangeId_; + result.tokenId_ = tokenId_; + result.quant_ = quant_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ExchangeInjectContract) { + return mergeFrom((org.tron.protos.Contract.ExchangeInjectContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ExchangeInjectContract other) { + if (other == org.tron.protos.Contract.ExchangeInjectContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getExchangeId() != 0L) { + setExchangeId(other.getExchangeId()); + } + if (other.getTokenId() != com.google.protobuf.ByteString.EMPTY) { + setTokenId(other.getTokenId()); + } + if (other.getQuant() != 0L) { + setQuant(other.getQuant()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ExchangeInjectContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ExchangeInjectContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long exchangeId_ ; + /** + * int64 exchange_id = 2; + */ + public long getExchangeId() { + return exchangeId_; + } + /** + * int64 exchange_id = 2; + */ + public Builder setExchangeId(long value) { + + exchangeId_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_id = 2; + */ + public Builder clearExchangeId() { + + exchangeId_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString tokenId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes token_id = 3; + */ + public com.google.protobuf.ByteString getTokenId() { + return tokenId_; + } + /** + * bytes token_id = 3; + */ + public Builder setTokenId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + tokenId_ = value; + onChanged(); + return this; + } + /** + * bytes token_id = 3; + */ + public Builder clearTokenId() { + + tokenId_ = getDefaultInstance().getTokenId(); + onChanged(); + return this; + } + + private long quant_ ; + /** + * int64 quant = 4; + */ + public long getQuant() { + return quant_; + } + /** + * int64 quant = 4; + */ + public Builder setQuant(long value) { + + quant_ = value; + onChanged(); + return this; + } + /** + * int64 quant = 4; + */ + public Builder clearQuant() { + + quant_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ExchangeInjectContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ExchangeInjectContract) + private static final org.tron.protos.Contract.ExchangeInjectContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ExchangeInjectContract(); + } + + public static org.tron.protos.Contract.ExchangeInjectContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExchangeInjectContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExchangeInjectContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ExchangeInjectContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ExchangeWithdrawContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ExchangeWithdrawContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * int64 exchange_id = 2; + */ + long getExchangeId(); + + /** + * bytes token_id = 3; + */ + com.google.protobuf.ByteString getTokenId(); + + /** + * int64 quant = 4; + */ + long getQuant(); + } + /** + * Protobuf type {@code protocol.ExchangeWithdrawContract} + */ + public static final class ExchangeWithdrawContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ExchangeWithdrawContract) + ExchangeWithdrawContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExchangeWithdrawContract.newBuilder() to construct. + private ExchangeWithdrawContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExchangeWithdrawContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + exchangeId_ = 0L; + tokenId_ = com.google.protobuf.ByteString.EMPTY; + quant_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExchangeWithdrawContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + exchangeId_ = input.readInt64(); + break; + } + case 26: { + + tokenId_ = input.readBytes(); + break; + } + case 32: { + + quant_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeWithdrawContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeWithdrawContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeWithdrawContract.class, org.tron.protos.Contract.ExchangeWithdrawContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int EXCHANGE_ID_FIELD_NUMBER = 2; + private long exchangeId_; + /** + * int64 exchange_id = 2; + */ + public long getExchangeId() { + return exchangeId_; + } + + public static final int TOKEN_ID_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString tokenId_; + /** + * bytes token_id = 3; + */ + public com.google.protobuf.ByteString getTokenId() { + return tokenId_; + } + + public static final int QUANT_FIELD_NUMBER = 4; + private long quant_; + /** + * int64 quant = 4; + */ + public long getQuant() { + return quant_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (exchangeId_ != 0L) { + output.writeInt64(2, exchangeId_); + } + if (!tokenId_.isEmpty()) { + output.writeBytes(3, tokenId_); + } + if (quant_ != 0L) { + output.writeInt64(4, quant_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (exchangeId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, exchangeId_); + } + if (!tokenId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, tokenId_); + } + if (quant_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, quant_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ExchangeWithdrawContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ExchangeWithdrawContract other = (org.tron.protos.Contract.ExchangeWithdrawContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getExchangeId() + == other.getExchangeId()); + result = result && getTokenId() + .equals(other.getTokenId()); + result = result && (getQuant() + == other.getQuant()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + EXCHANGE_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeId()); + hash = (37 * hash) + TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getTokenId().hashCode(); + hash = (37 * hash) + QUANT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getQuant()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeWithdrawContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ExchangeWithdrawContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ExchangeWithdrawContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ExchangeWithdrawContract) + org.tron.protos.Contract.ExchangeWithdrawContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeWithdrawContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeWithdrawContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeWithdrawContract.class, org.tron.protos.Contract.ExchangeWithdrawContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ExchangeWithdrawContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + exchangeId_ = 0L; + + tokenId_ = com.google.protobuf.ByteString.EMPTY; + + quant_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeWithdrawContract_descriptor; + } + + public org.tron.protos.Contract.ExchangeWithdrawContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ExchangeWithdrawContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ExchangeWithdrawContract build() { + org.tron.protos.Contract.ExchangeWithdrawContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ExchangeWithdrawContract buildPartial() { + org.tron.protos.Contract.ExchangeWithdrawContract result = new org.tron.protos.Contract.ExchangeWithdrawContract(this); + result.ownerAddress_ = ownerAddress_; + result.exchangeId_ = exchangeId_; + result.tokenId_ = tokenId_; + result.quant_ = quant_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ExchangeWithdrawContract) { + return mergeFrom((org.tron.protos.Contract.ExchangeWithdrawContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ExchangeWithdrawContract other) { + if (other == org.tron.protos.Contract.ExchangeWithdrawContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getExchangeId() != 0L) { + setExchangeId(other.getExchangeId()); + } + if (other.getTokenId() != com.google.protobuf.ByteString.EMPTY) { + setTokenId(other.getTokenId()); + } + if (other.getQuant() != 0L) { + setQuant(other.getQuant()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ExchangeWithdrawContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ExchangeWithdrawContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long exchangeId_ ; + /** + * int64 exchange_id = 2; + */ + public long getExchangeId() { + return exchangeId_; + } + /** + * int64 exchange_id = 2; + */ + public Builder setExchangeId(long value) { + + exchangeId_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_id = 2; + */ + public Builder clearExchangeId() { + + exchangeId_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString tokenId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes token_id = 3; + */ + public com.google.protobuf.ByteString getTokenId() { + return tokenId_; + } + /** + * bytes token_id = 3; + */ + public Builder setTokenId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + tokenId_ = value; + onChanged(); + return this; + } + /** + * bytes token_id = 3; + */ + public Builder clearTokenId() { + + tokenId_ = getDefaultInstance().getTokenId(); + onChanged(); + return this; + } + + private long quant_ ; + /** + * int64 quant = 4; + */ + public long getQuant() { + return quant_; + } + /** + * int64 quant = 4; + */ + public Builder setQuant(long value) { + + quant_ = value; + onChanged(); + return this; + } + /** + * int64 quant = 4; + */ + public Builder clearQuant() { + + quant_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ExchangeWithdrawContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ExchangeWithdrawContract) + private static final org.tron.protos.Contract.ExchangeWithdrawContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ExchangeWithdrawContract(); + } + + public static org.tron.protos.Contract.ExchangeWithdrawContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExchangeWithdrawContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExchangeWithdrawContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ExchangeWithdrawContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ExchangeTransactionContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ExchangeTransactionContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + * int64 exchange_id = 2; + */ + long getExchangeId(); + + /** + * bytes token_id = 3; + */ + com.google.protobuf.ByteString getTokenId(); + + /** + * int64 quant = 4; + */ + long getQuant(); + + /** + * int64 expected = 5; + */ + long getExpected(); + } + /** + * Protobuf type {@code protocol.ExchangeTransactionContract} + */ + public static final class ExchangeTransactionContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ExchangeTransactionContract) + ExchangeTransactionContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExchangeTransactionContract.newBuilder() to construct. + private ExchangeTransactionContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExchangeTransactionContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + exchangeId_ = 0L; + tokenId_ = com.google.protobuf.ByteString.EMPTY; + quant_ = 0L; + expected_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExchangeTransactionContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 16: { + + exchangeId_ = input.readInt64(); + break; + } + case 26: { + + tokenId_ = input.readBytes(); + break; + } + case 32: { + + quant_ = input.readInt64(); + break; + } + case 40: { + + expected_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeTransactionContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeTransactionContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeTransactionContract.class, org.tron.protos.Contract.ExchangeTransactionContract.Builder.class); + } + + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int EXCHANGE_ID_FIELD_NUMBER = 2; + private long exchangeId_; + /** + * int64 exchange_id = 2; + */ + public long getExchangeId() { + return exchangeId_; + } + + public static final int TOKEN_ID_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString tokenId_; + /** + * bytes token_id = 3; + */ + public com.google.protobuf.ByteString getTokenId() { + return tokenId_; + } + + public static final int QUANT_FIELD_NUMBER = 4; + private long quant_; + /** + * int64 quant = 4; + */ + public long getQuant() { + return quant_; + } + + public static final int EXPECTED_FIELD_NUMBER = 5; + private long expected_; + /** + * int64 expected = 5; + */ + public long getExpected() { + return expected_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (exchangeId_ != 0L) { + output.writeInt64(2, exchangeId_); + } + if (!tokenId_.isEmpty()) { + output.writeBytes(3, tokenId_); + } + if (quant_ != 0L) { + output.writeInt64(4, quant_); + } + if (expected_ != 0L) { + output.writeInt64(5, expected_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (exchangeId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, exchangeId_); + } + if (!tokenId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, tokenId_); + } + if (quant_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, quant_); + } + if (expected_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, expected_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.ExchangeTransactionContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.ExchangeTransactionContract other = (org.tron.protos.Contract.ExchangeTransactionContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (getExchangeId() + == other.getExchangeId()); + result = result && getTokenId() + .equals(other.getTokenId()); + result = result && (getQuant() + == other.getQuant()); + result = result && (getExpected() + == other.getExpected()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + hash = (37 * hash) + EXCHANGE_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeId()); + hash = (37 * hash) + TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getTokenId().hashCode(); + hash = (37 * hash) + QUANT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getQuant()); + hash = (37 * hash) + EXPECTED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExpected()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.ExchangeTransactionContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.ExchangeTransactionContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ExchangeTransactionContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ExchangeTransactionContract) + org.tron.protos.Contract.ExchangeTransactionContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeTransactionContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeTransactionContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.ExchangeTransactionContract.class, org.tron.protos.Contract.ExchangeTransactionContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.ExchangeTransactionContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + exchangeId_ = 0L; + + tokenId_ = com.google.protobuf.ByteString.EMPTY; + + quant_ = 0L; + + expected_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_ExchangeTransactionContract_descriptor; + } + + public org.tron.protos.Contract.ExchangeTransactionContract getDefaultInstanceForType() { + return org.tron.protos.Contract.ExchangeTransactionContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.ExchangeTransactionContract build() { + org.tron.protos.Contract.ExchangeTransactionContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.ExchangeTransactionContract buildPartial() { + org.tron.protos.Contract.ExchangeTransactionContract result = new org.tron.protos.Contract.ExchangeTransactionContract(this); + result.ownerAddress_ = ownerAddress_; + result.exchangeId_ = exchangeId_; + result.tokenId_ = tokenId_; + result.quant_ = quant_; + result.expected_ = expected_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.ExchangeTransactionContract) { + return mergeFrom((org.tron.protos.Contract.ExchangeTransactionContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.ExchangeTransactionContract other) { + if (other == org.tron.protos.Contract.ExchangeTransactionContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.getExchangeId() != 0L) { + setExchangeId(other.getExchangeId()); + } + if (other.getTokenId() != com.google.protobuf.ByteString.EMPTY) { + setTokenId(other.getTokenId()); + } + if (other.getQuant() != 0L) { + setQuant(other.getQuant()); + } + if (other.getExpected() != 0L) { + setExpected(other.getExpected()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.ExchangeTransactionContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.ExchangeTransactionContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private long exchangeId_ ; + /** + * int64 exchange_id = 2; + */ + public long getExchangeId() { + return exchangeId_; + } + /** + * int64 exchange_id = 2; + */ + public Builder setExchangeId(long value) { + + exchangeId_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_id = 2; + */ + public Builder clearExchangeId() { + + exchangeId_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString tokenId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes token_id = 3; + */ + public com.google.protobuf.ByteString getTokenId() { + return tokenId_; + } + /** + * bytes token_id = 3; + */ + public Builder setTokenId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + tokenId_ = value; + onChanged(); + return this; + } + /** + * bytes token_id = 3; + */ + public Builder clearTokenId() { + + tokenId_ = getDefaultInstance().getTokenId(); + onChanged(); + return this; + } + + private long quant_ ; + /** + * int64 quant = 4; + */ + public long getQuant() { + return quant_; + } + /** + * int64 quant = 4; + */ + public Builder setQuant(long value) { + + quant_ = value; + onChanged(); + return this; + } + /** + * int64 quant = 4; + */ + public Builder clearQuant() { + + quant_ = 0L; + onChanged(); + return this; + } + + private long expected_ ; + /** + * int64 expected = 5; + */ + public long getExpected() { + return expected_; + } + /** + * int64 expected = 5; + */ + public Builder setExpected(long value) { + + expected_ = value; + onChanged(); + return this; + } + /** + * int64 expected = 5; + */ + public Builder clearExpected() { + + expected_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ExchangeTransactionContract) + } + + // @@protoc_insertion_point(class_scope:protocol.ExchangeTransactionContract) + private static final org.tron.protos.Contract.ExchangeTransactionContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.ExchangeTransactionContract(); + } + + public static org.tron.protos.Contract.ExchangeTransactionContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExchangeTransactionContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExchangeTransactionContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.ExchangeTransactionContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AccountPermissionUpdateContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AccountPermissionUpdateContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes owner_address = 1; + */ + com.google.protobuf.ByteString getOwnerAddress(); + + /** + *
+     *Empty is invalidate
+     * 
+ * + * .protocol.Permission owner = 2; + */ + boolean hasOwner(); + /** + *
+     *Empty is invalidate
+     * 
+ * + * .protocol.Permission owner = 2; + */ + org.tron.protos.Protocol.Permission getOwner(); + /** + *
+     *Empty is invalidate
+     * 
+ * + * .protocol.Permission owner = 2; + */ + org.tron.protos.Protocol.PermissionOrBuilder getOwnerOrBuilder(); + + /** + *
+     *Can be empty
+     * 
+ * + * .protocol.Permission witness = 3; + */ + boolean hasWitness(); + /** + *
+     *Can be empty
+     * 
+ * + * .protocol.Permission witness = 3; + */ + org.tron.protos.Protocol.Permission getWitness(); + /** + *
+     *Can be empty
+     * 
+ * + * .protocol.Permission witness = 3; + */ + org.tron.protos.Protocol.PermissionOrBuilder getWitnessOrBuilder(); + + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + java.util.List + getActivesList(); + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + org.tron.protos.Protocol.Permission getActives(int index); + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + int getActivesCount(); + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + java.util.List + getActivesOrBuilderList(); + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + org.tron.protos.Protocol.PermissionOrBuilder getActivesOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.AccountPermissionUpdateContract} + */ + public static final class AccountPermissionUpdateContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AccountPermissionUpdateContract) + AccountPermissionUpdateContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountPermissionUpdateContract.newBuilder() to construct. + private AccountPermissionUpdateContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountPermissionUpdateContract() { + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + actives_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountPermissionUpdateContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + ownerAddress_ = input.readBytes(); + break; + } + case 18: { + org.tron.protos.Protocol.Permission.Builder subBuilder = null; + if (owner_ != null) { + subBuilder = owner_.toBuilder(); + } + owner_ = input.readMessage(org.tron.protos.Protocol.Permission.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(owner_); + owner_ = subBuilder.buildPartial(); + } + + break; + } + case 26: { + org.tron.protos.Protocol.Permission.Builder subBuilder = null; + if (witness_ != null) { + subBuilder = witness_.toBuilder(); + } + witness_ = input.readMessage(org.tron.protos.Protocol.Permission.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(witness_); + witness_ = subBuilder.buildPartial(); + } + + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + actives_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + actives_.add( + input.readMessage(org.tron.protos.Protocol.Permission.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + actives_ = java.util.Collections.unmodifiableList(actives_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AccountPermissionUpdateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AccountPermissionUpdateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AccountPermissionUpdateContract.class, org.tron.protos.Contract.AccountPermissionUpdateContract.Builder.class); + } + + private int bitField0_; + public static final int OWNER_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString ownerAddress_; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + + public static final int OWNER_FIELD_NUMBER = 2; + private org.tron.protos.Protocol.Permission owner_; + /** + *
+     *Empty is invalidate
+     * 
+ * + * .protocol.Permission owner = 2; + */ + public boolean hasOwner() { + return owner_ != null; + } + /** + *
+     *Empty is invalidate
+     * 
+ * + * .protocol.Permission owner = 2; + */ + public org.tron.protos.Protocol.Permission getOwner() { + return owner_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : owner_; + } + /** + *
+     *Empty is invalidate
+     * 
+ * + * .protocol.Permission owner = 2; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getOwnerOrBuilder() { + return getOwner(); + } + + public static final int WITNESS_FIELD_NUMBER = 3; + private org.tron.protos.Protocol.Permission witness_; + /** + *
+     *Can be empty
+     * 
+ * + * .protocol.Permission witness = 3; + */ + public boolean hasWitness() { + return witness_ != null; + } + /** + *
+     *Can be empty
+     * 
+ * + * .protocol.Permission witness = 3; + */ + public org.tron.protos.Protocol.Permission getWitness() { + return witness_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : witness_; + } + /** + *
+     *Can be empty
+     * 
+ * + * .protocol.Permission witness = 3; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getWitnessOrBuilder() { + return getWitness(); + } + + public static final int ACTIVES_FIELD_NUMBER = 4; + private java.util.List actives_; + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public java.util.List getActivesList() { + return actives_; + } + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public java.util.List + getActivesOrBuilderList() { + return actives_; + } + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public int getActivesCount() { + return actives_.size(); + } + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public org.tron.protos.Protocol.Permission getActives(int index) { + return actives_.get(index); + } + /** + *
+     *Empty is invalidate
+     * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getActivesOrBuilder( + int index) { + return actives_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!ownerAddress_.isEmpty()) { + output.writeBytes(1, ownerAddress_); + } + if (owner_ != null) { + output.writeMessage(2, getOwner()); + } + if (witness_ != null) { + output.writeMessage(3, getWitness()); + } + for (int i = 0; i < actives_.size(); i++) { + output.writeMessage(4, actives_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!ownerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, ownerAddress_); + } + if (owner_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getOwner()); + } + if (witness_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getWitness()); + } + for (int i = 0; i < actives_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, actives_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Contract.AccountPermissionUpdateContract)) { + return super.equals(obj); + } + org.tron.protos.Contract.AccountPermissionUpdateContract other = (org.tron.protos.Contract.AccountPermissionUpdateContract) obj; + + boolean result = true; + result = result && getOwnerAddress() + .equals(other.getOwnerAddress()); + result = result && (hasOwner() == other.hasOwner()); + if (hasOwner()) { + result = result && getOwner() + .equals(other.getOwner()); + } + result = result && (hasWitness() == other.hasWitness()); + if (hasWitness()) { + result = result && getWitness() + .equals(other.getWitness()); + } + result = result && getActivesList() + .equals(other.getActivesList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OWNER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOwnerAddress().hashCode(); + if (hasOwner()) { + hash = (37 * hash) + OWNER_FIELD_NUMBER; + hash = (53 * hash) + getOwner().hashCode(); + } + if (hasWitness()) { + hash = (37 * hash) + WITNESS_FIELD_NUMBER; + hash = (53 * hash) + getWitness().hashCode(); + } + if (getActivesCount() > 0) { + hash = (37 * hash) + ACTIVES_FIELD_NUMBER; + hash = (53 * hash) + getActivesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Contract.AccountPermissionUpdateContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Contract.AccountPermissionUpdateContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.AccountPermissionUpdateContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AccountPermissionUpdateContract) + org.tron.protos.Contract.AccountPermissionUpdateContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Contract.internal_static_protocol_AccountPermissionUpdateContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Contract.internal_static_protocol_AccountPermissionUpdateContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Contract.AccountPermissionUpdateContract.class, org.tron.protos.Contract.AccountPermissionUpdateContract.Builder.class); + } + + // Construct using org.tron.protos.Contract.AccountPermissionUpdateContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getActivesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + + if (ownerBuilder_ == null) { + owner_ = null; + } else { + owner_ = null; + ownerBuilder_ = null; + } + if (witnessBuilder_ == null) { + witness_ = null; + } else { + witness_ = null; + witnessBuilder_ = null; + } + if (activesBuilder_ == null) { + actives_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + activesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Contract.internal_static_protocol_AccountPermissionUpdateContract_descriptor; + } + + public org.tron.protos.Contract.AccountPermissionUpdateContract getDefaultInstanceForType() { + return org.tron.protos.Contract.AccountPermissionUpdateContract.getDefaultInstance(); + } + + public org.tron.protos.Contract.AccountPermissionUpdateContract build() { + org.tron.protos.Contract.AccountPermissionUpdateContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Contract.AccountPermissionUpdateContract buildPartial() { + org.tron.protos.Contract.AccountPermissionUpdateContract result = new org.tron.protos.Contract.AccountPermissionUpdateContract(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.ownerAddress_ = ownerAddress_; + if (ownerBuilder_ == null) { + result.owner_ = owner_; + } else { + result.owner_ = ownerBuilder_.build(); + } + if (witnessBuilder_ == null) { + result.witness_ = witness_; + } else { + result.witness_ = witnessBuilder_.build(); + } + if (activesBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + actives_ = java.util.Collections.unmodifiableList(actives_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.actives_ = actives_; + } else { + result.actives_ = activesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Contract.AccountPermissionUpdateContract) { + return mergeFrom((org.tron.protos.Contract.AccountPermissionUpdateContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Contract.AccountPermissionUpdateContract other) { + if (other == org.tron.protos.Contract.AccountPermissionUpdateContract.getDefaultInstance()) return this; + if (other.getOwnerAddress() != com.google.protobuf.ByteString.EMPTY) { + setOwnerAddress(other.getOwnerAddress()); + } + if (other.hasOwner()) { + mergeOwner(other.getOwner()); + } + if (other.hasWitness()) { + mergeWitness(other.getWitness()); + } + if (activesBuilder_ == null) { + if (!other.actives_.isEmpty()) { + if (actives_.isEmpty()) { + actives_ = other.actives_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureActivesIsMutable(); + actives_.addAll(other.actives_); + } + onChanged(); + } + } else { + if (!other.actives_.isEmpty()) { + if (activesBuilder_.isEmpty()) { + activesBuilder_.dispose(); + activesBuilder_ = null; + actives_ = other.actives_; + bitField0_ = (bitField0_ & ~0x00000008); + activesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getActivesFieldBuilder() : null; + } else { + activesBuilder_.addAllMessages(other.actives_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Contract.AccountPermissionUpdateContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Contract.AccountPermissionUpdateContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString ownerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes owner_address = 1; + */ + public com.google.protobuf.ByteString getOwnerAddress() { + return ownerAddress_; + } + /** + * bytes owner_address = 1; + */ + public Builder setOwnerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + ownerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes owner_address = 1; + */ + public Builder clearOwnerAddress() { + + ownerAddress_ = getDefaultInstance().getOwnerAddress(); + onChanged(); + return this; + } + + private org.tron.protos.Protocol.Permission owner_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> ownerBuilder_; + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public boolean hasOwner() { + return ownerBuilder_ != null || owner_ != null; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public org.tron.protos.Protocol.Permission getOwner() { + if (ownerBuilder_ == null) { + return owner_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : owner_; + } else { + return ownerBuilder_.getMessage(); + } + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public Builder setOwner(org.tron.protos.Protocol.Permission value) { + if (ownerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + owner_ = value; + onChanged(); + } else { + ownerBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public Builder setOwner( + org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (ownerBuilder_ == null) { + owner_ = builderForValue.build(); + onChanged(); + } else { + ownerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public Builder mergeOwner(org.tron.protos.Protocol.Permission value) { + if (ownerBuilder_ == null) { + if (owner_ != null) { + owner_ = + org.tron.protos.Protocol.Permission.newBuilder(owner_).mergeFrom(value).buildPartial(); + } else { + owner_ = value; + } + onChanged(); + } else { + ownerBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public Builder clearOwner() { + if (ownerBuilder_ == null) { + owner_ = null; + onChanged(); + } else { + owner_ = null; + ownerBuilder_ = null; + } + + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public org.tron.protos.Protocol.Permission.Builder getOwnerBuilder() { + + onChanged(); + return getOwnerFieldBuilder().getBuilder(); + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getOwnerOrBuilder() { + if (ownerBuilder_ != null) { + return ownerBuilder_.getMessageOrBuilder(); + } else { + return owner_ == null ? + org.tron.protos.Protocol.Permission.getDefaultInstance() : owner_; + } + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * .protocol.Permission owner = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> + getOwnerFieldBuilder() { + if (ownerBuilder_ == null) { + ownerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder>( + getOwner(), + getParentForChildren(), + isClean()); + owner_ = null; + } + return ownerBuilder_; + } + + private org.tron.protos.Protocol.Permission witness_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> witnessBuilder_; + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public boolean hasWitness() { + return witnessBuilder_ != null || witness_ != null; + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public org.tron.protos.Protocol.Permission getWitness() { + if (witnessBuilder_ == null) { + return witness_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : witness_; + } else { + return witnessBuilder_.getMessage(); + } + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public Builder setWitness(org.tron.protos.Protocol.Permission value) { + if (witnessBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + witness_ = value; + onChanged(); + } else { + witnessBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public Builder setWitness( + org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (witnessBuilder_ == null) { + witness_ = builderForValue.build(); + onChanged(); + } else { + witnessBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public Builder mergeWitness(org.tron.protos.Protocol.Permission value) { + if (witnessBuilder_ == null) { + if (witness_ != null) { + witness_ = + org.tron.protos.Protocol.Permission.newBuilder(witness_).mergeFrom(value).buildPartial(); + } else { + witness_ = value; + } + onChanged(); + } else { + witnessBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public Builder clearWitness() { + if (witnessBuilder_ == null) { + witness_ = null; + onChanged(); + } else { + witness_ = null; + witnessBuilder_ = null; + } + + return this; + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public org.tron.protos.Protocol.Permission.Builder getWitnessBuilder() { + + onChanged(); + return getWitnessFieldBuilder().getBuilder(); + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getWitnessOrBuilder() { + if (witnessBuilder_ != null) { + return witnessBuilder_.getMessageOrBuilder(); + } else { + return witness_ == null ? + org.tron.protos.Protocol.Permission.getDefaultInstance() : witness_; + } + } + /** + *
+       *Can be empty
+       * 
+ * + * .protocol.Permission witness = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> + getWitnessFieldBuilder() { + if (witnessBuilder_ == null) { + witnessBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder>( + getWitness(), + getParentForChildren(), + isClean()); + witness_ = null; + } + return witnessBuilder_; + } + + private java.util.List actives_ = + java.util.Collections.emptyList(); + private void ensureActivesIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + actives_ = new java.util.ArrayList(actives_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> activesBuilder_; + + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public java.util.List getActivesList() { + if (activesBuilder_ == null) { + return java.util.Collections.unmodifiableList(actives_); + } else { + return activesBuilder_.getMessageList(); + } + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public int getActivesCount() { + if (activesBuilder_ == null) { + return actives_.size(); + } else { + return activesBuilder_.getCount(); + } + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public org.tron.protos.Protocol.Permission getActives(int index) { + if (activesBuilder_ == null) { + return actives_.get(index); + } else { + return activesBuilder_.getMessage(index); + } + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder setActives( + int index, org.tron.protos.Protocol.Permission value) { + if (activesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActivesIsMutable(); + actives_.set(index, value); + onChanged(); + } else { + activesBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder setActives( + int index, org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (activesBuilder_ == null) { + ensureActivesIsMutable(); + actives_.set(index, builderForValue.build()); + onChanged(); + } else { + activesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder addActives(org.tron.protos.Protocol.Permission value) { + if (activesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActivesIsMutable(); + actives_.add(value); + onChanged(); + } else { + activesBuilder_.addMessage(value); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder addActives( + int index, org.tron.protos.Protocol.Permission value) { + if (activesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActivesIsMutable(); + actives_.add(index, value); + onChanged(); + } else { + activesBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder addActives( + org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (activesBuilder_ == null) { + ensureActivesIsMutable(); + actives_.add(builderForValue.build()); + onChanged(); + } else { + activesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder addActives( + int index, org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (activesBuilder_ == null) { + ensureActivesIsMutable(); + actives_.add(index, builderForValue.build()); + onChanged(); + } else { + activesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder addAllActives( + java.lang.Iterable values) { + if (activesBuilder_ == null) { + ensureActivesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, actives_); + onChanged(); + } else { + activesBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder clearActives() { + if (activesBuilder_ == null) { + actives_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + activesBuilder_.clear(); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public Builder removeActives(int index) { + if (activesBuilder_ == null) { + ensureActivesIsMutable(); + actives_.remove(index); + onChanged(); + } else { + activesBuilder_.remove(index); + } + return this; + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public org.tron.protos.Protocol.Permission.Builder getActivesBuilder( + int index) { + return getActivesFieldBuilder().getBuilder(index); + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getActivesOrBuilder( + int index) { + if (activesBuilder_ == null) { + return actives_.get(index); } else { + return activesBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public java.util.List + getActivesOrBuilderList() { + if (activesBuilder_ != null) { + return activesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(actives_); + } + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public org.tron.protos.Protocol.Permission.Builder addActivesBuilder() { + return getActivesFieldBuilder().addBuilder( + org.tron.protos.Protocol.Permission.getDefaultInstance()); + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public org.tron.protos.Protocol.Permission.Builder addActivesBuilder( + int index) { + return getActivesFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Permission.getDefaultInstance()); + } + /** + *
+       *Empty is invalidate
+       * 
+ * + * repeated .protocol.Permission actives = 4; + */ + public java.util.List + getActivesBuilderList() { + return getActivesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> + getActivesFieldBuilder() { + if (activesBuilder_ == null) { + activesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder>( + actives_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + actives_ = null; + } + return activesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AccountPermissionUpdateContract) + } + + // @@protoc_insertion_point(class_scope:protocol.AccountPermissionUpdateContract) + private static final org.tron.protos.Contract.AccountPermissionUpdateContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Contract.AccountPermissionUpdateContract(); + } + + public static org.tron.protos.Contract.AccountPermissionUpdateContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountPermissionUpdateContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountPermissionUpdateContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Contract.AccountPermissionUpdateContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountCreateContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountCreateContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountUpdateContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountUpdateContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_SetAccountIdContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_SetAccountIdContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransferContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransferContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransferAssetContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransferAssetContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_VoteAssetContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_VoteAssetContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_VoteWitnessContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_VoteWitnessContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_VoteWitnessContract_Vote_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_VoteWitnessContract_Vote_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_UpdateSettingContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_UpdateSettingContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_UpdateEnergyLimitContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_UpdateEnergyLimitContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ClearABIContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ClearABIContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_WitnessCreateContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_WitnessCreateContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_WitnessUpdateContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_WitnessUpdateContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AssetIssueContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AssetIssueContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AssetIssueContract_FrozenSupply_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AssetIssueContract_FrozenSupply_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ParticipateAssetIssueContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ParticipateAssetIssueContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_FreezeBalanceContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_FreezeBalanceContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_UnfreezeBalanceContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_UnfreezeBalanceContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_UnfreezeAssetContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_UnfreezeAssetContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_WithdrawBalanceContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_WithdrawBalanceContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_UpdateAssetContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_UpdateAssetContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ProposalCreateContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ProposalCreateContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ProposalCreateContract_ParametersEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ProposalCreateContract_ParametersEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ProposalApproveContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ProposalApproveContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ProposalDeleteContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ProposalDeleteContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_CreateSmartContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_CreateSmartContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TriggerSmartContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TriggerSmartContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BuyStorageContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BuyStorageContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BuyStorageBytesContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BuyStorageBytesContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_SellStorageContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_SellStorageContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ExchangeCreateContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ExchangeCreateContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ExchangeInjectContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ExchangeInjectContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ExchangeWithdrawContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ExchangeWithdrawContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ExchangeTransactionContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ExchangeTransactionContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountPermissionUpdateContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountPermissionUpdateContract_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\023core/Contract.proto\022\010protocol\032\017core/Tr" + + "on.proto\"l\n\025AccountCreateContract\022\025\n\rown" + + "er_address\030\001 \001(\014\022\027\n\017account_address\030\002 \001(" + + "\014\022#\n\004type\030\003 \001(\0162\025.protocol.AccountType\"D" + + "\n\025AccountUpdateContract\022\024\n\014account_name\030" + + "\001 \001(\014\022\025\n\rowner_address\030\002 \001(\014\"A\n\024SetAccou" + + "ntIdContract\022\022\n\naccount_id\030\001 \001(\014\022\025\n\rowne" + + "r_address\030\002 \001(\014\"M\n\020TransferContract\022\025\n\ro" + + "wner_address\030\001 \001(\014\022\022\n\nto_address\030\002 \001(\014\022\016" + + "\n\006amount\030\003 \001(\003\"f\n\025TransferAssetContract\022" + + "\022\n\nasset_name\030\001 \001(\014\022\025\n\rowner_address\030\002 \001" + + "(\014\022\022\n\nto_address\030\003 \001(\014\022\016\n\006amount\030\004 \001(\003\"`" + + "\n\021VoteAssetContract\022\025\n\rowner_address\030\001 \001" + + "(\014\022\024\n\014vote_address\030\002 \003(\014\022\017\n\007support\030\003 \001(" + + "\010\022\r\n\005count\030\005 \001(\005\"\242\001\n\023VoteWitnessContract" + + "\022\025\n\rowner_address\030\001 \001(\014\0221\n\005votes\030\002 \003(\0132\"" + + ".protocol.VoteWitnessContract.Vote\022\017\n\007su" + + "pport\030\003 \001(\010\0320\n\004Vote\022\024\n\014vote_address\030\001 \001(" + + "\014\022\022\n\nvote_count\030\002 \001(\003\"o\n\025UpdateSettingCo" + + "ntract\022\025\n\rowner_address\030\001 \001(\014\022\030\n\020contrac" + + "t_address\030\002 \001(\014\022%\n\035consume_user_resource" + + "_percent\030\003 \001(\003\"i\n\031UpdateEnergyLimitContr" + + "act\022\025\n\rowner_address\030\001 \001(\014\022\030\n\020contract_a" + + "ddress\030\002 \001(\014\022\033\n\023origin_energy_limit\030\003 \001(" + + "\003\"C\n\020ClearABIContract\022\025\n\rowner_address\030\001" + + " \001(\014\022\030\n\020contract_address\030\002 \001(\014\";\n\025Witnes" + + "sCreateContract\022\025\n\rowner_address\030\001 \001(\014\022\013" + + "\n\003url\030\002 \001(\014\"B\n\025WitnessUpdateContract\022\025\n\r" + + "owner_address\030\001 \001(\014\022\022\n\nupdate_url\030\014 \001(\014\"" + + "\220\004\n\022AssetIssueContract\022\n\n\002id\030) \001(\t\022\025\n\row" + + "ner_address\030\001 \001(\014\022\014\n\004name\030\002 \001(\014\022\014\n\004abbr\030" + + "\003 \001(\014\022\024\n\014total_supply\030\004 \001(\003\022@\n\rfrozen_su" + + "pply\030\005 \003(\0132).protocol.AssetIssueContract" + + ".FrozenSupply\022\017\n\007trx_num\030\006 \001(\005\022\021\n\tprecis" + + "ion\030\007 \001(\005\022\013\n\003num\030\010 \001(\005\022\022\n\nstart_time\030\t \001" + + "(\003\022\020\n\010end_time\030\n \001(\003\022\r\n\005order\030\013 \001(\003\022\022\n\nv" + + "ote_score\030\020 \001(\005\022\023\n\013description\030\024 \001(\014\022\013\n\003" + + "url\030\025 \001(\014\022\034\n\024free_asset_net_limit\030\026 \001(\003\022" + + "#\n\033public_free_asset_net_limit\030\027 \001(\003\022#\n\033" + + "public_free_asset_net_usage\030\030 \001(\003\022#\n\033pub" + + "lic_latest_free_net_time\030\031 \001(\003\032:\n\014Frozen" + + "Supply\022\025\n\rfrozen_amount\030\001 \001(\003\022\023\n\013frozen_" + + "days\030\002 \001(\003\"n\n\035ParticipateAssetIssueContr" + + "act\022\025\n\rowner_address\030\001 \001(\014\022\022\n\nto_address" + + "\030\002 \001(\014\022\022\n\nasset_name\030\003 \001(\014\022\016\n\006amount\030\004 \001" + + "(\003\"\243\001\n\025FreezeBalanceContract\022\025\n\rowner_ad" + + "dress\030\001 \001(\014\022\026\n\016frozen_balance\030\002 \001(\003\022\027\n\017f" + + "rozen_duration\030\003 \001(\003\022(\n\010resource\030\n \001(\0162\026" + + ".protocol.ResourceCode\022\030\n\020receiver_addre" + + "ss\030\017 \001(\014\"t\n\027UnfreezeBalanceContract\022\025\n\ro" + + "wner_address\030\001 \001(\014\022(\n\010resource\030\n \001(\0162\026.p" + + "rotocol.ResourceCode\022\030\n\020receiver_address" + + "\030\017 \001(\014\".\n\025UnfreezeAssetContract\022\025\n\rowner" + + "_address\030\001 \001(\014\"0\n\027WithdrawBalanceContrac" + + "t\022\025\n\rowner_address\030\001 \001(\014\"{\n\023UpdateAssetC" + + "ontract\022\025\n\rowner_address\030\001 \001(\014\022\023\n\013descri" + + "ption\030\002 \001(\014\022\013\n\003url\030\003 \001(\014\022\021\n\tnew_limit\030\004 " + + "\001(\003\022\030\n\020new_public_limit\030\005 \001(\003\"\250\001\n\026Propos" + + "alCreateContract\022\025\n\rowner_address\030\001 \001(\014\022" + + "D\n\nparameters\030\002 \003(\01320.protocol.ProposalC" + + "reateContract.ParametersEntry\0321\n\017Paramet" + + "ersEntry\022\013\n\003key\030\001 \001(\003\022\r\n\005value\030\002 \001(\003:\0028\001" + + "\"^\n\027ProposalApproveContract\022\025\n\rowner_add" + + "ress\030\001 \001(\014\022\023\n\013proposal_id\030\002 \001(\003\022\027\n\017is_ad" + + "d_approval\030\003 \001(\010\"D\n\026ProposalDeleteContra" + + "ct\022\025\n\rowner_address\030\001 \001(\014\022\023\n\013proposal_id" + + "\030\002 \001(\003\"\207\001\n\023CreateSmartContract\022\025\n\rowner_" + + "address\030\001 \001(\014\022-\n\014new_contract\030\002 \001(\0132\027.pr" + + "otocol.SmartContract\022\030\n\020call_token_value" + + "\030\003 \001(\003\022\020\n\010token_id\030\004 \001(\003\"\225\001\n\024TriggerSmar" + + "tContract\022\025\n\rowner_address\030\001 \001(\014\022\030\n\020cont" + + "ract_address\030\002 \001(\014\022\022\n\ncall_value\030\003 \001(\003\022\014" + + "\n\004data\030\004 \001(\014\022\030\n\020call_token_value\030\005 \001(\003\022\020" + + "\n\010token_id\030\006 \001(\003\":\n\022BuyStorageContract\022\025" + + "\n\rowner_address\030\001 \001(\014\022\r\n\005quant\030\002 \001(\003\"?\n\027" + + "BuyStorageBytesContract\022\025\n\rowner_address" + + "\030\001 \001(\014\022\r\n\005bytes\030\002 \001(\003\"C\n\023SellStorageCont" + + "ract\022\025\n\rowner_address\030\001 \001(\014\022\025\n\rstorage_b" + + "ytes\030\002 \001(\003\"\233\001\n\026ExchangeCreateContract\022\025\n" + + "\rowner_address\030\001 \001(\014\022\026\n\016first_token_id\030\002" + + " \001(\014\022\033\n\023first_token_balance\030\003 \001(\003\022\027\n\017sec" + + "ond_token_id\030\004 \001(\014\022\034\n\024second_token_balan" + + "ce\030\005 \001(\003\"e\n\026ExchangeInjectContract\022\025\n\row" + + "ner_address\030\001 \001(\014\022\023\n\013exchange_id\030\002 \001(\003\022\020" + + "\n\010token_id\030\003 \001(\014\022\r\n\005quant\030\004 \001(\003\"g\n\030Excha" + + "ngeWithdrawContract\022\025\n\rowner_address\030\001 \001" + + "(\014\022\023\n\013exchange_id\030\002 \001(\003\022\020\n\010token_id\030\003 \001(" + + "\014\022\r\n\005quant\030\004 \001(\003\"|\n\033ExchangeTransactionC" + + "ontract\022\025\n\rowner_address\030\001 \001(\014\022\023\n\013exchan" + + "ge_id\030\002 \001(\003\022\020\n\010token_id\030\003 \001(\014\022\r\n\005quant\030\004" + + " \001(\003\022\020\n\010expected\030\005 \001(\003\"\253\001\n\037AccountPermis" + + "sionUpdateContract\022\025\n\rowner_address\030\001 \001(" + + "\014\022#\n\005owner\030\002 \001(\0132\024.protocol.Permission\022%" + + "\n\007witness\030\003 \001(\0132\024.protocol.Permission\022%\n" + + "\007actives\030\004 \003(\0132\024.protocol.Permission*)\n\014" + + "ResourceCode\022\r\n\tBANDWIDTH\020\000\022\n\n\006ENERGY\020\001B" + + "F\n\017org.tron.protosB\010ContractZ)github.com" + + "/tronprotocol/grpc-gateway/coreb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + org.tron.protos.Protocol.getDescriptor(), + }, assigner); + internal_static_protocol_AccountCreateContract_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_protocol_AccountCreateContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountCreateContract_descriptor, + new java.lang.String[] { "OwnerAddress", "AccountAddress", "Type", }); + internal_static_protocol_AccountUpdateContract_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_protocol_AccountUpdateContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountUpdateContract_descriptor, + new java.lang.String[] { "AccountName", "OwnerAddress", }); + internal_static_protocol_SetAccountIdContract_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_protocol_SetAccountIdContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_SetAccountIdContract_descriptor, + new java.lang.String[] { "AccountId", "OwnerAddress", }); + internal_static_protocol_TransferContract_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_protocol_TransferContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransferContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ToAddress", "Amount", }); + internal_static_protocol_TransferAssetContract_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_protocol_TransferAssetContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransferAssetContract_descriptor, + new java.lang.String[] { "AssetName", "OwnerAddress", "ToAddress", "Amount", }); + internal_static_protocol_VoteAssetContract_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_protocol_VoteAssetContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_VoteAssetContract_descriptor, + new java.lang.String[] { "OwnerAddress", "VoteAddress", "Support", "Count", }); + internal_static_protocol_VoteWitnessContract_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_protocol_VoteWitnessContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_VoteWitnessContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Votes", "Support", }); + internal_static_protocol_VoteWitnessContract_Vote_descriptor = + internal_static_protocol_VoteWitnessContract_descriptor.getNestedTypes().get(0); + internal_static_protocol_VoteWitnessContract_Vote_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_VoteWitnessContract_Vote_descriptor, + new java.lang.String[] { "VoteAddress", "VoteCount", }); + internal_static_protocol_UpdateSettingContract_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_protocol_UpdateSettingContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_UpdateSettingContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ContractAddress", "ConsumeUserResourcePercent", }); + internal_static_protocol_UpdateEnergyLimitContract_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_protocol_UpdateEnergyLimitContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_UpdateEnergyLimitContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ContractAddress", "OriginEnergyLimit", }); + internal_static_protocol_ClearABIContract_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_protocol_ClearABIContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ClearABIContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ContractAddress", }); + internal_static_protocol_WitnessCreateContract_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_protocol_WitnessCreateContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_WitnessCreateContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Url", }); + internal_static_protocol_WitnessUpdateContract_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_protocol_WitnessUpdateContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_WitnessUpdateContract_descriptor, + new java.lang.String[] { "OwnerAddress", "UpdateUrl", }); + internal_static_protocol_AssetIssueContract_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_protocol_AssetIssueContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AssetIssueContract_descriptor, + new java.lang.String[] { "Id", "OwnerAddress", "Name", "Abbr", "TotalSupply", "FrozenSupply", "TrxNum", "Precision", "Num", "StartTime", "EndTime", "Order", "VoteScore", "Description", "Url", "FreeAssetNetLimit", "PublicFreeAssetNetLimit", "PublicFreeAssetNetUsage", "PublicLatestFreeNetTime", }); + internal_static_protocol_AssetIssueContract_FrozenSupply_descriptor = + internal_static_protocol_AssetIssueContract_descriptor.getNestedTypes().get(0); + internal_static_protocol_AssetIssueContract_FrozenSupply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AssetIssueContract_FrozenSupply_descriptor, + new java.lang.String[] { "FrozenAmount", "FrozenDays", }); + internal_static_protocol_ParticipateAssetIssueContract_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_protocol_ParticipateAssetIssueContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ParticipateAssetIssueContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ToAddress", "AssetName", "Amount", }); + internal_static_protocol_FreezeBalanceContract_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_protocol_FreezeBalanceContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_FreezeBalanceContract_descriptor, + new java.lang.String[] { "OwnerAddress", "FrozenBalance", "FrozenDuration", "Resource", "ReceiverAddress", }); + internal_static_protocol_UnfreezeBalanceContract_descriptor = + getDescriptor().getMessageTypes().get(15); + internal_static_protocol_UnfreezeBalanceContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_UnfreezeBalanceContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Resource", "ReceiverAddress", }); + internal_static_protocol_UnfreezeAssetContract_descriptor = + getDescriptor().getMessageTypes().get(16); + internal_static_protocol_UnfreezeAssetContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_UnfreezeAssetContract_descriptor, + new java.lang.String[] { "OwnerAddress", }); + internal_static_protocol_WithdrawBalanceContract_descriptor = + getDescriptor().getMessageTypes().get(17); + internal_static_protocol_WithdrawBalanceContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_WithdrawBalanceContract_descriptor, + new java.lang.String[] { "OwnerAddress", }); + internal_static_protocol_UpdateAssetContract_descriptor = + getDescriptor().getMessageTypes().get(18); + internal_static_protocol_UpdateAssetContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_UpdateAssetContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Description", "Url", "NewLimit", "NewPublicLimit", }); + internal_static_protocol_ProposalCreateContract_descriptor = + getDescriptor().getMessageTypes().get(19); + internal_static_protocol_ProposalCreateContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ProposalCreateContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Parameters", }); + internal_static_protocol_ProposalCreateContract_ParametersEntry_descriptor = + internal_static_protocol_ProposalCreateContract_descriptor.getNestedTypes().get(0); + internal_static_protocol_ProposalCreateContract_ParametersEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ProposalCreateContract_ParametersEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_ProposalApproveContract_descriptor = + getDescriptor().getMessageTypes().get(20); + internal_static_protocol_ProposalApproveContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ProposalApproveContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ProposalId", "IsAddApproval", }); + internal_static_protocol_ProposalDeleteContract_descriptor = + getDescriptor().getMessageTypes().get(21); + internal_static_protocol_ProposalDeleteContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ProposalDeleteContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ProposalId", }); + internal_static_protocol_CreateSmartContract_descriptor = + getDescriptor().getMessageTypes().get(22); + internal_static_protocol_CreateSmartContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_CreateSmartContract_descriptor, + new java.lang.String[] { "OwnerAddress", "NewContract", "CallTokenValue", "TokenId", }); + internal_static_protocol_TriggerSmartContract_descriptor = + getDescriptor().getMessageTypes().get(23); + internal_static_protocol_TriggerSmartContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TriggerSmartContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ContractAddress", "CallValue", "Data", "CallTokenValue", "TokenId", }); + internal_static_protocol_BuyStorageContract_descriptor = + getDescriptor().getMessageTypes().get(24); + internal_static_protocol_BuyStorageContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BuyStorageContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Quant", }); + internal_static_protocol_BuyStorageBytesContract_descriptor = + getDescriptor().getMessageTypes().get(25); + internal_static_protocol_BuyStorageBytesContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BuyStorageBytesContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Bytes", }); + internal_static_protocol_SellStorageContract_descriptor = + getDescriptor().getMessageTypes().get(26); + internal_static_protocol_SellStorageContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_SellStorageContract_descriptor, + new java.lang.String[] { "OwnerAddress", "StorageBytes", }); + internal_static_protocol_ExchangeCreateContract_descriptor = + getDescriptor().getMessageTypes().get(27); + internal_static_protocol_ExchangeCreateContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ExchangeCreateContract_descriptor, + new java.lang.String[] { "OwnerAddress", "FirstTokenId", "FirstTokenBalance", "SecondTokenId", "SecondTokenBalance", }); + internal_static_protocol_ExchangeInjectContract_descriptor = + getDescriptor().getMessageTypes().get(28); + internal_static_protocol_ExchangeInjectContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ExchangeInjectContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ExchangeId", "TokenId", "Quant", }); + internal_static_protocol_ExchangeWithdrawContract_descriptor = + getDescriptor().getMessageTypes().get(29); + internal_static_protocol_ExchangeWithdrawContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ExchangeWithdrawContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ExchangeId", "TokenId", "Quant", }); + internal_static_protocol_ExchangeTransactionContract_descriptor = + getDescriptor().getMessageTypes().get(30); + internal_static_protocol_ExchangeTransactionContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ExchangeTransactionContract_descriptor, + new java.lang.String[] { "OwnerAddress", "ExchangeId", "TokenId", "Quant", "Expected", }); + internal_static_protocol_AccountPermissionUpdateContract_descriptor = + getDescriptor().getMessageTypes().get(31); + internal_static_protocol_AccountPermissionUpdateContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountPermissionUpdateContract_descriptor, + new java.lang.String[] { "OwnerAddress", "Owner", "Witness", "Actives", }); + org.tron.protos.Protocol.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/framework/src/main/gen/org/tron/protos/Discover.java b/framework/src/main/gen/org/tron/protos/Discover.java new file mode 100644 index 00000000000..061b43c6297 --- /dev/null +++ b/framework/src/main/gen/org/tron/protos/Discover.java @@ -0,0 +1,4564 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: core/Discover.proto + +package org.tron.protos; + +public final class Discover { + private Discover() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface EndpointOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Endpoint) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes address = 1; + */ + com.google.protobuf.ByteString getAddress(); + + /** + * int32 port = 2; + */ + int getPort(); + + /** + * bytes nodeId = 3; + */ + com.google.protobuf.ByteString getNodeId(); + } + /** + * Protobuf type {@code protocol.Endpoint} + */ + public static final class Endpoint extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Endpoint) + EndpointOrBuilder { + private static final long serialVersionUID = 0L; + // Use Endpoint.newBuilder() to construct. + private Endpoint(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Endpoint() { + address_ = com.google.protobuf.ByteString.EMPTY; + port_ = 0; + nodeId_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Endpoint( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + address_ = input.readBytes(); + break; + } + case 16: { + + port_ = input.readInt32(); + break; + } + case 26: { + + nodeId_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_Endpoint_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_Endpoint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.Endpoint.class, org.tron.protos.Discover.Endpoint.Builder.class); + } + + public static final int ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString address_; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + + public static final int PORT_FIELD_NUMBER = 2; + private int port_; + /** + * int32 port = 2; + */ + public int getPort() { + return port_; + } + + public static final int NODEID_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString nodeId_; + /** + * bytes nodeId = 3; + */ + public com.google.protobuf.ByteString getNodeId() { + return nodeId_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!address_.isEmpty()) { + output.writeBytes(1, address_); + } + if (port_ != 0) { + output.writeInt32(2, port_); + } + if (!nodeId_.isEmpty()) { + output.writeBytes(3, nodeId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!address_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, address_); + } + if (port_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, port_); + } + if (!nodeId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, nodeId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Discover.Endpoint)) { + return super.equals(obj); + } + org.tron.protos.Discover.Endpoint other = (org.tron.protos.Discover.Endpoint) obj; + + boolean result = true; + result = result && getAddress() + .equals(other.getAddress()); + result = result && (getPort() + == other.getPort()); + result = result && getNodeId() + .equals(other.getNodeId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + hash = (37 * hash) + PORT_FIELD_NUMBER; + hash = (53 * hash) + getPort(); + hash = (37 * hash) + NODEID_FIELD_NUMBER; + hash = (53 * hash) + getNodeId().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Discover.Endpoint parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.Endpoint parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.Endpoint parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.Endpoint parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.Endpoint parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.Endpoint parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.Endpoint parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.Endpoint parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.Endpoint parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.Endpoint parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.Endpoint parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.Endpoint parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Discover.Endpoint prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Endpoint} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Endpoint) + org.tron.protos.Discover.EndpointOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_Endpoint_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_Endpoint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.Endpoint.class, org.tron.protos.Discover.Endpoint.Builder.class); + } + + // Construct using org.tron.protos.Discover.Endpoint.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + address_ = com.google.protobuf.ByteString.EMPTY; + + port_ = 0; + + nodeId_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Discover.internal_static_protocol_Endpoint_descriptor; + } + + public org.tron.protos.Discover.Endpoint getDefaultInstanceForType() { + return org.tron.protos.Discover.Endpoint.getDefaultInstance(); + } + + public org.tron.protos.Discover.Endpoint build() { + org.tron.protos.Discover.Endpoint result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Discover.Endpoint buildPartial() { + org.tron.protos.Discover.Endpoint result = new org.tron.protos.Discover.Endpoint(this); + result.address_ = address_; + result.port_ = port_; + result.nodeId_ = nodeId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Discover.Endpoint) { + return mergeFrom((org.tron.protos.Discover.Endpoint)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Discover.Endpoint other) { + if (other == org.tron.protos.Discover.Endpoint.getDefaultInstance()) return this; + if (other.getAddress() != com.google.protobuf.ByteString.EMPTY) { + setAddress(other.getAddress()); + } + if (other.getPort() != 0) { + setPort(other.getPort()); + } + if (other.getNodeId() != com.google.protobuf.ByteString.EMPTY) { + setNodeId(other.getNodeId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Discover.Endpoint parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Discover.Endpoint) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString address_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + /** + * bytes address = 1; + */ + public Builder setAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + * bytes address = 1; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + + private int port_ ; + /** + * int32 port = 2; + */ + public int getPort() { + return port_; + } + /** + * int32 port = 2; + */ + public Builder setPort(int value) { + + port_ = value; + onChanged(); + return this; + } + /** + * int32 port = 2; + */ + public Builder clearPort() { + + port_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString nodeId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes nodeId = 3; + */ + public com.google.protobuf.ByteString getNodeId() { + return nodeId_; + } + /** + * bytes nodeId = 3; + */ + public Builder setNodeId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + nodeId_ = value; + onChanged(); + return this; + } + /** + * bytes nodeId = 3; + */ + public Builder clearNodeId() { + + nodeId_ = getDefaultInstance().getNodeId(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Endpoint) + } + + // @@protoc_insertion_point(class_scope:protocol.Endpoint) + private static final org.tron.protos.Discover.Endpoint DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Discover.Endpoint(); + } + + public static org.tron.protos.Discover.Endpoint getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Endpoint parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Endpoint(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Discover.Endpoint getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface PingMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.PingMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Endpoint from = 1; + */ + boolean hasFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.Endpoint getFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder(); + + /** + * .protocol.Endpoint to = 2; + */ + boolean hasTo(); + /** + * .protocol.Endpoint to = 2; + */ + org.tron.protos.Discover.Endpoint getTo(); + /** + * .protocol.Endpoint to = 2; + */ + org.tron.protos.Discover.EndpointOrBuilder getToOrBuilder(); + + /** + * int32 version = 3; + */ + int getVersion(); + + /** + * int64 timestamp = 4; + */ + long getTimestamp(); + } + /** + * Protobuf type {@code protocol.PingMessage} + */ + public static final class PingMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.PingMessage) + PingMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use PingMessage.newBuilder() to construct. + private PingMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PingMessage() { + version_ = 0; + timestamp_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PingMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Discover.Endpoint.Builder subBuilder = null; + if (from_ != null) { + subBuilder = from_.toBuilder(); + } + from_ = input.readMessage(org.tron.protos.Discover.Endpoint.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(from_); + from_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + org.tron.protos.Discover.Endpoint.Builder subBuilder = null; + if (to_ != null) { + subBuilder = to_.toBuilder(); + } + to_ = input.readMessage(org.tron.protos.Discover.Endpoint.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(to_); + to_ = subBuilder.buildPartial(); + } + + break; + } + case 24: { + + version_ = input.readInt32(); + break; + } + case 32: { + + timestamp_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_PingMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_PingMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.PingMessage.class, org.tron.protos.Discover.PingMessage.Builder.class); + } + + public static final int FROM_FIELD_NUMBER = 1; + private org.tron.protos.Discover.Endpoint from_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + return getFrom(); + } + + public static final int TO_FIELD_NUMBER = 2; + private org.tron.protos.Discover.Endpoint to_; + /** + * .protocol.Endpoint to = 2; + */ + public boolean hasTo() { + return to_ != null; + } + /** + * .protocol.Endpoint to = 2; + */ + public org.tron.protos.Discover.Endpoint getTo() { + return to_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : to_; + } + /** + * .protocol.Endpoint to = 2; + */ + public org.tron.protos.Discover.EndpointOrBuilder getToOrBuilder() { + return getTo(); + } + + public static final int VERSION_FIELD_NUMBER = 3; + private int version_; + /** + * int32 version = 3; + */ + public int getVersion() { + return version_; + } + + public static final int TIMESTAMP_FIELD_NUMBER = 4; + private long timestamp_; + /** + * int64 timestamp = 4; + */ + public long getTimestamp() { + return timestamp_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (from_ != null) { + output.writeMessage(1, getFrom()); + } + if (to_ != null) { + output.writeMessage(2, getTo()); + } + if (version_ != 0) { + output.writeInt32(3, version_); + } + if (timestamp_ != 0L) { + output.writeInt64(4, timestamp_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (from_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getFrom()); + } + if (to_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getTo()); + } + if (version_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, version_); + } + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, timestamp_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Discover.PingMessage)) { + return super.equals(obj); + } + org.tron.protos.Discover.PingMessage other = (org.tron.protos.Discover.PingMessage) obj; + + boolean result = true; + result = result && (hasFrom() == other.hasFrom()); + if (hasFrom()) { + result = result && getFrom() + .equals(other.getFrom()); + } + result = result && (hasTo() == other.hasTo()); + if (hasTo()) { + result = result && getTo() + .equals(other.getTo()); + } + result = result && (getVersion() + == other.getVersion()); + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasFrom()) { + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFrom().hashCode(); + } + if (hasTo()) { + hash = (37 * hash) + TO_FIELD_NUMBER; + hash = (53 * hash) + getTo().hashCode(); + } + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Discover.PingMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.PingMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.PingMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.PingMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.PingMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.PingMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.PingMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.PingMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.PingMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.PingMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.PingMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.PingMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Discover.PingMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.PingMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.PingMessage) + org.tron.protos.Discover.PingMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_PingMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_PingMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.PingMessage.class, org.tron.protos.Discover.PingMessage.Builder.class); + } + + // Construct using org.tron.protos.Discover.PingMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (fromBuilder_ == null) { + from_ = null; + } else { + from_ = null; + fromBuilder_ = null; + } + if (toBuilder_ == null) { + to_ = null; + } else { + to_ = null; + toBuilder_ = null; + } + version_ = 0; + + timestamp_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Discover.internal_static_protocol_PingMessage_descriptor; + } + + public org.tron.protos.Discover.PingMessage getDefaultInstanceForType() { + return org.tron.protos.Discover.PingMessage.getDefaultInstance(); + } + + public org.tron.protos.Discover.PingMessage build() { + org.tron.protos.Discover.PingMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Discover.PingMessage buildPartial() { + org.tron.protos.Discover.PingMessage result = new org.tron.protos.Discover.PingMessage(this); + if (fromBuilder_ == null) { + result.from_ = from_; + } else { + result.from_ = fromBuilder_.build(); + } + if (toBuilder_ == null) { + result.to_ = to_; + } else { + result.to_ = toBuilder_.build(); + } + result.version_ = version_; + result.timestamp_ = timestamp_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Discover.PingMessage) { + return mergeFrom((org.tron.protos.Discover.PingMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Discover.PingMessage other) { + if (other == org.tron.protos.Discover.PingMessage.getDefaultInstance()) return this; + if (other.hasFrom()) { + mergeFrom(other.getFrom()); + } + if (other.hasTo()) { + mergeTo(other.getTo()); + } + if (other.getVersion() != 0) { + setVersion(other.getVersion()); + } + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Discover.PingMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Discover.PingMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Discover.Endpoint from_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> fromBuilder_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return fromBuilder_ != null || from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + if (fromBuilder_ == null) { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } else { + return fromBuilder_.getMessage(); + } + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + from_ = value; + onChanged(); + } else { + fromBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom( + org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (fromBuilder_ == null) { + from_ = builderForValue.build(); + onChanged(); + } else { + fromBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder mergeFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (from_ != null) { + from_ = + org.tron.protos.Discover.Endpoint.newBuilder(from_).mergeFrom(value).buildPartial(); + } else { + from_ = value; + } + onChanged(); + } else { + fromBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder clearFrom() { + if (fromBuilder_ == null) { + from_ = null; + onChanged(); + } else { + from_ = null; + fromBuilder_ = null; + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint.Builder getFromBuilder() { + + onChanged(); + return getFromFieldBuilder().getBuilder(); + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + if (fromBuilder_ != null) { + return fromBuilder_.getMessageOrBuilder(); + } else { + return from_ == null ? + org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + } + /** + * .protocol.Endpoint from = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> + getFromFieldBuilder() { + if (fromBuilder_ == null) { + fromBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder>( + getFrom(), + getParentForChildren(), + isClean()); + from_ = null; + } + return fromBuilder_; + } + + private org.tron.protos.Discover.Endpoint to_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> toBuilder_; + /** + * .protocol.Endpoint to = 2; + */ + public boolean hasTo() { + return toBuilder_ != null || to_ != null; + } + /** + * .protocol.Endpoint to = 2; + */ + public org.tron.protos.Discover.Endpoint getTo() { + if (toBuilder_ == null) { + return to_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : to_; + } else { + return toBuilder_.getMessage(); + } + } + /** + * .protocol.Endpoint to = 2; + */ + public Builder setTo(org.tron.protos.Discover.Endpoint value) { + if (toBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + to_ = value; + onChanged(); + } else { + toBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Endpoint to = 2; + */ + public Builder setTo( + org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (toBuilder_ == null) { + to_ = builderForValue.build(); + onChanged(); + } else { + toBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Endpoint to = 2; + */ + public Builder mergeTo(org.tron.protos.Discover.Endpoint value) { + if (toBuilder_ == null) { + if (to_ != null) { + to_ = + org.tron.protos.Discover.Endpoint.newBuilder(to_).mergeFrom(value).buildPartial(); + } else { + to_ = value; + } + onChanged(); + } else { + toBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Endpoint to = 2; + */ + public Builder clearTo() { + if (toBuilder_ == null) { + to_ = null; + onChanged(); + } else { + to_ = null; + toBuilder_ = null; + } + + return this; + } + /** + * .protocol.Endpoint to = 2; + */ + public org.tron.protos.Discover.Endpoint.Builder getToBuilder() { + + onChanged(); + return getToFieldBuilder().getBuilder(); + } + /** + * .protocol.Endpoint to = 2; + */ + public org.tron.protos.Discover.EndpointOrBuilder getToOrBuilder() { + if (toBuilder_ != null) { + return toBuilder_.getMessageOrBuilder(); + } else { + return to_ == null ? + org.tron.protos.Discover.Endpoint.getDefaultInstance() : to_; + } + } + /** + * .protocol.Endpoint to = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> + getToFieldBuilder() { + if (toBuilder_ == null) { + toBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder>( + getTo(), + getParentForChildren(), + isClean()); + to_ = null; + } + return toBuilder_; + } + + private int version_ ; + /** + * int32 version = 3; + */ + public int getVersion() { + return version_; + } + /** + * int32 version = 3; + */ + public Builder setVersion(int value) { + + version_ = value; + onChanged(); + return this; + } + /** + * int32 version = 3; + */ + public Builder clearVersion() { + + version_ = 0; + onChanged(); + return this; + } + + private long timestamp_ ; + /** + * int64 timestamp = 4; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 4; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 4; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.PingMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.PingMessage) + private static final org.tron.protos.Discover.PingMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Discover.PingMessage(); + } + + public static org.tron.protos.Discover.PingMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PingMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PingMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Discover.PingMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface PongMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.PongMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Endpoint from = 1; + */ + boolean hasFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.Endpoint getFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder(); + + /** + * int32 echo = 2; + */ + int getEcho(); + + /** + * int64 timestamp = 3; + */ + long getTimestamp(); + } + /** + * Protobuf type {@code protocol.PongMessage} + */ + public static final class PongMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.PongMessage) + PongMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use PongMessage.newBuilder() to construct. + private PongMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PongMessage() { + echo_ = 0; + timestamp_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PongMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Discover.Endpoint.Builder subBuilder = null; + if (from_ != null) { + subBuilder = from_.toBuilder(); + } + from_ = input.readMessage(org.tron.protos.Discover.Endpoint.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(from_); + from_ = subBuilder.buildPartial(); + } + + break; + } + case 16: { + + echo_ = input.readInt32(); + break; + } + case 24: { + + timestamp_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_PongMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_PongMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.PongMessage.class, org.tron.protos.Discover.PongMessage.Builder.class); + } + + public static final int FROM_FIELD_NUMBER = 1; + private org.tron.protos.Discover.Endpoint from_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + return getFrom(); + } + + public static final int ECHO_FIELD_NUMBER = 2; + private int echo_; + /** + * int32 echo = 2; + */ + public int getEcho() { + return echo_; + } + + public static final int TIMESTAMP_FIELD_NUMBER = 3; + private long timestamp_; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (from_ != null) { + output.writeMessage(1, getFrom()); + } + if (echo_ != 0) { + output.writeInt32(2, echo_); + } + if (timestamp_ != 0L) { + output.writeInt64(3, timestamp_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (from_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getFrom()); + } + if (echo_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, echo_); + } + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, timestamp_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Discover.PongMessage)) { + return super.equals(obj); + } + org.tron.protos.Discover.PongMessage other = (org.tron.protos.Discover.PongMessage) obj; + + boolean result = true; + result = result && (hasFrom() == other.hasFrom()); + if (hasFrom()) { + result = result && getFrom() + .equals(other.getFrom()); + } + result = result && (getEcho() + == other.getEcho()); + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasFrom()) { + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFrom().hashCode(); + } + hash = (37 * hash) + ECHO_FIELD_NUMBER; + hash = (53 * hash) + getEcho(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Discover.PongMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.PongMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.PongMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.PongMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.PongMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.PongMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.PongMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.PongMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.PongMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.PongMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.PongMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.PongMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Discover.PongMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.PongMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.PongMessage) + org.tron.protos.Discover.PongMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_PongMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_PongMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.PongMessage.class, org.tron.protos.Discover.PongMessage.Builder.class); + } + + // Construct using org.tron.protos.Discover.PongMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (fromBuilder_ == null) { + from_ = null; + } else { + from_ = null; + fromBuilder_ = null; + } + echo_ = 0; + + timestamp_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Discover.internal_static_protocol_PongMessage_descriptor; + } + + public org.tron.protos.Discover.PongMessage getDefaultInstanceForType() { + return org.tron.protos.Discover.PongMessage.getDefaultInstance(); + } + + public org.tron.protos.Discover.PongMessage build() { + org.tron.protos.Discover.PongMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Discover.PongMessage buildPartial() { + org.tron.protos.Discover.PongMessage result = new org.tron.protos.Discover.PongMessage(this); + if (fromBuilder_ == null) { + result.from_ = from_; + } else { + result.from_ = fromBuilder_.build(); + } + result.echo_ = echo_; + result.timestamp_ = timestamp_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Discover.PongMessage) { + return mergeFrom((org.tron.protos.Discover.PongMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Discover.PongMessage other) { + if (other == org.tron.protos.Discover.PongMessage.getDefaultInstance()) return this; + if (other.hasFrom()) { + mergeFrom(other.getFrom()); + } + if (other.getEcho() != 0) { + setEcho(other.getEcho()); + } + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Discover.PongMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Discover.PongMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Discover.Endpoint from_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> fromBuilder_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return fromBuilder_ != null || from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + if (fromBuilder_ == null) { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } else { + return fromBuilder_.getMessage(); + } + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + from_ = value; + onChanged(); + } else { + fromBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom( + org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (fromBuilder_ == null) { + from_ = builderForValue.build(); + onChanged(); + } else { + fromBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder mergeFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (from_ != null) { + from_ = + org.tron.protos.Discover.Endpoint.newBuilder(from_).mergeFrom(value).buildPartial(); + } else { + from_ = value; + } + onChanged(); + } else { + fromBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder clearFrom() { + if (fromBuilder_ == null) { + from_ = null; + onChanged(); + } else { + from_ = null; + fromBuilder_ = null; + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint.Builder getFromBuilder() { + + onChanged(); + return getFromFieldBuilder().getBuilder(); + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + if (fromBuilder_ != null) { + return fromBuilder_.getMessageOrBuilder(); + } else { + return from_ == null ? + org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + } + /** + * .protocol.Endpoint from = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> + getFromFieldBuilder() { + if (fromBuilder_ == null) { + fromBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder>( + getFrom(), + getParentForChildren(), + isClean()); + from_ = null; + } + return fromBuilder_; + } + + private int echo_ ; + /** + * int32 echo = 2; + */ + public int getEcho() { + return echo_; + } + /** + * int32 echo = 2; + */ + public Builder setEcho(int value) { + + echo_ = value; + onChanged(); + return this; + } + /** + * int32 echo = 2; + */ + public Builder clearEcho() { + + echo_ = 0; + onChanged(); + return this; + } + + private long timestamp_ ; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 3; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 3; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.PongMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.PongMessage) + private static final org.tron.protos.Discover.PongMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Discover.PongMessage(); + } + + public static org.tron.protos.Discover.PongMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PongMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PongMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Discover.PongMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface FindNeighboursOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.FindNeighbours) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Endpoint from = 1; + */ + boolean hasFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.Endpoint getFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder(); + + /** + * bytes targetId = 2; + */ + com.google.protobuf.ByteString getTargetId(); + + /** + * int64 timestamp = 3; + */ + long getTimestamp(); + } + /** + * Protobuf type {@code protocol.FindNeighbours} + */ + public static final class FindNeighbours extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.FindNeighbours) + FindNeighboursOrBuilder { + private static final long serialVersionUID = 0L; + // Use FindNeighbours.newBuilder() to construct. + private FindNeighbours(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private FindNeighbours() { + targetId_ = com.google.protobuf.ByteString.EMPTY; + timestamp_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private FindNeighbours( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Discover.Endpoint.Builder subBuilder = null; + if (from_ != null) { + subBuilder = from_.toBuilder(); + } + from_ = input.readMessage(org.tron.protos.Discover.Endpoint.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(from_); + from_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + + targetId_ = input.readBytes(); + break; + } + case 24: { + + timestamp_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_FindNeighbours_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_FindNeighbours_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.FindNeighbours.class, org.tron.protos.Discover.FindNeighbours.Builder.class); + } + + public static final int FROM_FIELD_NUMBER = 1; + private org.tron.protos.Discover.Endpoint from_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + return getFrom(); + } + + public static final int TARGETID_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString targetId_; + /** + * bytes targetId = 2; + */ + public com.google.protobuf.ByteString getTargetId() { + return targetId_; + } + + public static final int TIMESTAMP_FIELD_NUMBER = 3; + private long timestamp_; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (from_ != null) { + output.writeMessage(1, getFrom()); + } + if (!targetId_.isEmpty()) { + output.writeBytes(2, targetId_); + } + if (timestamp_ != 0L) { + output.writeInt64(3, timestamp_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (from_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getFrom()); + } + if (!targetId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, targetId_); + } + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, timestamp_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Discover.FindNeighbours)) { + return super.equals(obj); + } + org.tron.protos.Discover.FindNeighbours other = (org.tron.protos.Discover.FindNeighbours) obj; + + boolean result = true; + result = result && (hasFrom() == other.hasFrom()); + if (hasFrom()) { + result = result && getFrom() + .equals(other.getFrom()); + } + result = result && getTargetId() + .equals(other.getTargetId()); + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasFrom()) { + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFrom().hashCode(); + } + hash = (37 * hash) + TARGETID_FIELD_NUMBER; + hash = (53 * hash) + getTargetId().hashCode(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Discover.FindNeighbours parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.FindNeighbours parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.FindNeighbours parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.FindNeighbours parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Discover.FindNeighbours prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.FindNeighbours} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.FindNeighbours) + org.tron.protos.Discover.FindNeighboursOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_FindNeighbours_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_FindNeighbours_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.FindNeighbours.class, org.tron.protos.Discover.FindNeighbours.Builder.class); + } + + // Construct using org.tron.protos.Discover.FindNeighbours.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (fromBuilder_ == null) { + from_ = null; + } else { + from_ = null; + fromBuilder_ = null; + } + targetId_ = com.google.protobuf.ByteString.EMPTY; + + timestamp_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Discover.internal_static_protocol_FindNeighbours_descriptor; + } + + public org.tron.protos.Discover.FindNeighbours getDefaultInstanceForType() { + return org.tron.protos.Discover.FindNeighbours.getDefaultInstance(); + } + + public org.tron.protos.Discover.FindNeighbours build() { + org.tron.protos.Discover.FindNeighbours result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Discover.FindNeighbours buildPartial() { + org.tron.protos.Discover.FindNeighbours result = new org.tron.protos.Discover.FindNeighbours(this); + if (fromBuilder_ == null) { + result.from_ = from_; + } else { + result.from_ = fromBuilder_.build(); + } + result.targetId_ = targetId_; + result.timestamp_ = timestamp_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Discover.FindNeighbours) { + return mergeFrom((org.tron.protos.Discover.FindNeighbours)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Discover.FindNeighbours other) { + if (other == org.tron.protos.Discover.FindNeighbours.getDefaultInstance()) return this; + if (other.hasFrom()) { + mergeFrom(other.getFrom()); + } + if (other.getTargetId() != com.google.protobuf.ByteString.EMPTY) { + setTargetId(other.getTargetId()); + } + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Discover.FindNeighbours parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Discover.FindNeighbours) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Discover.Endpoint from_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> fromBuilder_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return fromBuilder_ != null || from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + if (fromBuilder_ == null) { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } else { + return fromBuilder_.getMessage(); + } + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + from_ = value; + onChanged(); + } else { + fromBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom( + org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (fromBuilder_ == null) { + from_ = builderForValue.build(); + onChanged(); + } else { + fromBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder mergeFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (from_ != null) { + from_ = + org.tron.protos.Discover.Endpoint.newBuilder(from_).mergeFrom(value).buildPartial(); + } else { + from_ = value; + } + onChanged(); + } else { + fromBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder clearFrom() { + if (fromBuilder_ == null) { + from_ = null; + onChanged(); + } else { + from_ = null; + fromBuilder_ = null; + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint.Builder getFromBuilder() { + + onChanged(); + return getFromFieldBuilder().getBuilder(); + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + if (fromBuilder_ != null) { + return fromBuilder_.getMessageOrBuilder(); + } else { + return from_ == null ? + org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + } + /** + * .protocol.Endpoint from = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> + getFromFieldBuilder() { + if (fromBuilder_ == null) { + fromBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder>( + getFrom(), + getParentForChildren(), + isClean()); + from_ = null; + } + return fromBuilder_; + } + + private com.google.protobuf.ByteString targetId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes targetId = 2; + */ + public com.google.protobuf.ByteString getTargetId() { + return targetId_; + } + /** + * bytes targetId = 2; + */ + public Builder setTargetId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + targetId_ = value; + onChanged(); + return this; + } + /** + * bytes targetId = 2; + */ + public Builder clearTargetId() { + + targetId_ = getDefaultInstance().getTargetId(); + onChanged(); + return this; + } + + private long timestamp_ ; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 3; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 3; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.FindNeighbours) + } + + // @@protoc_insertion_point(class_scope:protocol.FindNeighbours) + private static final org.tron.protos.Discover.FindNeighbours DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Discover.FindNeighbours(); + } + + public static org.tron.protos.Discover.FindNeighbours getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public FindNeighbours parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new FindNeighbours(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Discover.FindNeighbours getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface NeighboursOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Neighbours) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Endpoint from = 1; + */ + boolean hasFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.Endpoint getFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder(); + + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + java.util.List + getNeighboursList(); + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + org.tron.protos.Discover.Endpoint getNeighbours(int index); + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + int getNeighboursCount(); + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + java.util.List + getNeighboursOrBuilderList(); + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + org.tron.protos.Discover.EndpointOrBuilder getNeighboursOrBuilder( + int index); + + /** + * int64 timestamp = 3; + */ + long getTimestamp(); + } + /** + * Protobuf type {@code protocol.Neighbours} + */ + public static final class Neighbours extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Neighbours) + NeighboursOrBuilder { + private static final long serialVersionUID = 0L; + // Use Neighbours.newBuilder() to construct. + private Neighbours(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Neighbours() { + neighbours_ = java.util.Collections.emptyList(); + timestamp_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Neighbours( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Discover.Endpoint.Builder subBuilder = null; + if (from_ != null) { + subBuilder = from_.toBuilder(); + } + from_ = input.readMessage(org.tron.protos.Discover.Endpoint.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(from_); + from_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + neighbours_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + neighbours_.add( + input.readMessage(org.tron.protos.Discover.Endpoint.parser(), extensionRegistry)); + break; + } + case 24: { + + timestamp_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + neighbours_ = java.util.Collections.unmodifiableList(neighbours_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_Neighbours_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_Neighbours_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.Neighbours.class, org.tron.protos.Discover.Neighbours.Builder.class); + } + + private int bitField0_; + public static final int FROM_FIELD_NUMBER = 1; + private org.tron.protos.Discover.Endpoint from_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + return getFrom(); + } + + public static final int NEIGHBOURS_FIELD_NUMBER = 2; + private java.util.List neighbours_; + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public java.util.List getNeighboursList() { + return neighbours_; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public java.util.List + getNeighboursOrBuilderList() { + return neighbours_; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public int getNeighboursCount() { + return neighbours_.size(); + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public org.tron.protos.Discover.Endpoint getNeighbours(int index) { + return neighbours_.get(index); + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public org.tron.protos.Discover.EndpointOrBuilder getNeighboursOrBuilder( + int index) { + return neighbours_.get(index); + } + + public static final int TIMESTAMP_FIELD_NUMBER = 3; + private long timestamp_; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (from_ != null) { + output.writeMessage(1, getFrom()); + } + for (int i = 0; i < neighbours_.size(); i++) { + output.writeMessage(2, neighbours_.get(i)); + } + if (timestamp_ != 0L) { + output.writeInt64(3, timestamp_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (from_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getFrom()); + } + for (int i = 0; i < neighbours_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, neighbours_.get(i)); + } + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, timestamp_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Discover.Neighbours)) { + return super.equals(obj); + } + org.tron.protos.Discover.Neighbours other = (org.tron.protos.Discover.Neighbours) obj; + + boolean result = true; + result = result && (hasFrom() == other.hasFrom()); + if (hasFrom()) { + result = result && getFrom() + .equals(other.getFrom()); + } + result = result && getNeighboursList() + .equals(other.getNeighboursList()); + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasFrom()) { + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFrom().hashCode(); + } + if (getNeighboursCount() > 0) { + hash = (37 * hash) + NEIGHBOURS_FIELD_NUMBER; + hash = (53 * hash) + getNeighboursList().hashCode(); + } + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Discover.Neighbours parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.Neighbours parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.Neighbours parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.Neighbours parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.Neighbours parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.Neighbours parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.Neighbours parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.Neighbours parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.Neighbours parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.Neighbours parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.Neighbours parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.Neighbours parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Discover.Neighbours prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Neighbours} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Neighbours) + org.tron.protos.Discover.NeighboursOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_Neighbours_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_Neighbours_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.Neighbours.class, org.tron.protos.Discover.Neighbours.Builder.class); + } + + // Construct using org.tron.protos.Discover.Neighbours.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getNeighboursFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (fromBuilder_ == null) { + from_ = null; + } else { + from_ = null; + fromBuilder_ = null; + } + if (neighboursBuilder_ == null) { + neighbours_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + neighboursBuilder_.clear(); + } + timestamp_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Discover.internal_static_protocol_Neighbours_descriptor; + } + + public org.tron.protos.Discover.Neighbours getDefaultInstanceForType() { + return org.tron.protos.Discover.Neighbours.getDefaultInstance(); + } + + public org.tron.protos.Discover.Neighbours build() { + org.tron.protos.Discover.Neighbours result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Discover.Neighbours buildPartial() { + org.tron.protos.Discover.Neighbours result = new org.tron.protos.Discover.Neighbours(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (fromBuilder_ == null) { + result.from_ = from_; + } else { + result.from_ = fromBuilder_.build(); + } + if (neighboursBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + neighbours_ = java.util.Collections.unmodifiableList(neighbours_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.neighbours_ = neighbours_; + } else { + result.neighbours_ = neighboursBuilder_.build(); + } + result.timestamp_ = timestamp_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Discover.Neighbours) { + return mergeFrom((org.tron.protos.Discover.Neighbours)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Discover.Neighbours other) { + if (other == org.tron.protos.Discover.Neighbours.getDefaultInstance()) return this; + if (other.hasFrom()) { + mergeFrom(other.getFrom()); + } + if (neighboursBuilder_ == null) { + if (!other.neighbours_.isEmpty()) { + if (neighbours_.isEmpty()) { + neighbours_ = other.neighbours_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureNeighboursIsMutable(); + neighbours_.addAll(other.neighbours_); + } + onChanged(); + } + } else { + if (!other.neighbours_.isEmpty()) { + if (neighboursBuilder_.isEmpty()) { + neighboursBuilder_.dispose(); + neighboursBuilder_ = null; + neighbours_ = other.neighbours_; + bitField0_ = (bitField0_ & ~0x00000002); + neighboursBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getNeighboursFieldBuilder() : null; + } else { + neighboursBuilder_.addAllMessages(other.neighbours_); + } + } + } + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Discover.Neighbours parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Discover.Neighbours) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private org.tron.protos.Discover.Endpoint from_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> fromBuilder_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return fromBuilder_ != null || from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + if (fromBuilder_ == null) { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } else { + return fromBuilder_.getMessage(); + } + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + from_ = value; + onChanged(); + } else { + fromBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom( + org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (fromBuilder_ == null) { + from_ = builderForValue.build(); + onChanged(); + } else { + fromBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder mergeFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (from_ != null) { + from_ = + org.tron.protos.Discover.Endpoint.newBuilder(from_).mergeFrom(value).buildPartial(); + } else { + from_ = value; + } + onChanged(); + } else { + fromBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder clearFrom() { + if (fromBuilder_ == null) { + from_ = null; + onChanged(); + } else { + from_ = null; + fromBuilder_ = null; + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint.Builder getFromBuilder() { + + onChanged(); + return getFromFieldBuilder().getBuilder(); + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + if (fromBuilder_ != null) { + return fromBuilder_.getMessageOrBuilder(); + } else { + return from_ == null ? + org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + } + /** + * .protocol.Endpoint from = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> + getFromFieldBuilder() { + if (fromBuilder_ == null) { + fromBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder>( + getFrom(), + getParentForChildren(), + isClean()); + from_ = null; + } + return fromBuilder_; + } + + private java.util.List neighbours_ = + java.util.Collections.emptyList(); + private void ensureNeighboursIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + neighbours_ = new java.util.ArrayList(neighbours_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> neighboursBuilder_; + + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public java.util.List getNeighboursList() { + if (neighboursBuilder_ == null) { + return java.util.Collections.unmodifiableList(neighbours_); + } else { + return neighboursBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public int getNeighboursCount() { + if (neighboursBuilder_ == null) { + return neighbours_.size(); + } else { + return neighboursBuilder_.getCount(); + } + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public org.tron.protos.Discover.Endpoint getNeighbours(int index) { + if (neighboursBuilder_ == null) { + return neighbours_.get(index); + } else { + return neighboursBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder setNeighbours( + int index, org.tron.protos.Discover.Endpoint value) { + if (neighboursBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNeighboursIsMutable(); + neighbours_.set(index, value); + onChanged(); + } else { + neighboursBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder setNeighbours( + int index, org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (neighboursBuilder_ == null) { + ensureNeighboursIsMutable(); + neighbours_.set(index, builderForValue.build()); + onChanged(); + } else { + neighboursBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder addNeighbours(org.tron.protos.Discover.Endpoint value) { + if (neighboursBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNeighboursIsMutable(); + neighbours_.add(value); + onChanged(); + } else { + neighboursBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder addNeighbours( + int index, org.tron.protos.Discover.Endpoint value) { + if (neighboursBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNeighboursIsMutable(); + neighbours_.add(index, value); + onChanged(); + } else { + neighboursBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder addNeighbours( + org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (neighboursBuilder_ == null) { + ensureNeighboursIsMutable(); + neighbours_.add(builderForValue.build()); + onChanged(); + } else { + neighboursBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder addNeighbours( + int index, org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (neighboursBuilder_ == null) { + ensureNeighboursIsMutable(); + neighbours_.add(index, builderForValue.build()); + onChanged(); + } else { + neighboursBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder addAllNeighbours( + java.lang.Iterable values) { + if (neighboursBuilder_ == null) { + ensureNeighboursIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, neighbours_); + onChanged(); + } else { + neighboursBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder clearNeighbours() { + if (neighboursBuilder_ == null) { + neighbours_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + neighboursBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public Builder removeNeighbours(int index) { + if (neighboursBuilder_ == null) { + ensureNeighboursIsMutable(); + neighbours_.remove(index); + onChanged(); + } else { + neighboursBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public org.tron.protos.Discover.Endpoint.Builder getNeighboursBuilder( + int index) { + return getNeighboursFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public org.tron.protos.Discover.EndpointOrBuilder getNeighboursOrBuilder( + int index) { + if (neighboursBuilder_ == null) { + return neighbours_.get(index); } else { + return neighboursBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public java.util.List + getNeighboursOrBuilderList() { + if (neighboursBuilder_ != null) { + return neighboursBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(neighbours_); + } + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public org.tron.protos.Discover.Endpoint.Builder addNeighboursBuilder() { + return getNeighboursFieldBuilder().addBuilder( + org.tron.protos.Discover.Endpoint.getDefaultInstance()); + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public org.tron.protos.Discover.Endpoint.Builder addNeighboursBuilder( + int index) { + return getNeighboursFieldBuilder().addBuilder( + index, org.tron.protos.Discover.Endpoint.getDefaultInstance()); + } + /** + * repeated .protocol.Endpoint neighbours = 2; + */ + public java.util.List + getNeighboursBuilderList() { + return getNeighboursFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> + getNeighboursFieldBuilder() { + if (neighboursBuilder_ == null) { + neighboursBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder>( + neighbours_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + neighbours_ = null; + } + return neighboursBuilder_; + } + + private long timestamp_ ; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 3; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 3; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Neighbours) + } + + // @@protoc_insertion_point(class_scope:protocol.Neighbours) + private static final org.tron.protos.Discover.Neighbours DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Discover.Neighbours(); + } + + public static org.tron.protos.Discover.Neighbours getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Neighbours parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Neighbours(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Discover.Neighbours getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BackupMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BackupMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * bool flag = 1; + */ + boolean getFlag(); + + /** + * int32 priority = 2; + */ + int getPriority(); + } + /** + * Protobuf type {@code protocol.BackupMessage} + */ + public static final class BackupMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BackupMessage) + BackupMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use BackupMessage.newBuilder() to construct. + private BackupMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BackupMessage() { + flag_ = false; + priority_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BackupMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + flag_ = input.readBool(); + break; + } + case 16: { + + priority_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_BackupMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_BackupMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.BackupMessage.class, org.tron.protos.Discover.BackupMessage.Builder.class); + } + + public static final int FLAG_FIELD_NUMBER = 1; + private boolean flag_; + /** + * bool flag = 1; + */ + public boolean getFlag() { + return flag_; + } + + public static final int PRIORITY_FIELD_NUMBER = 2; + private int priority_; + /** + * int32 priority = 2; + */ + public int getPriority() { + return priority_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (flag_ != false) { + output.writeBool(1, flag_); + } + if (priority_ != 0) { + output.writeInt32(2, priority_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (flag_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, flag_); + } + if (priority_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, priority_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Discover.BackupMessage)) { + return super.equals(obj); + } + org.tron.protos.Discover.BackupMessage other = (org.tron.protos.Discover.BackupMessage) obj; + + boolean result = true; + result = result && (getFlag() + == other.getFlag()); + result = result && (getPriority() + == other.getPriority()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FLAG_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getFlag()); + hash = (37 * hash) + PRIORITY_FIELD_NUMBER; + hash = (53 * hash) + getPriority(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Discover.BackupMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.BackupMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.BackupMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.BackupMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.BackupMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Discover.BackupMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Discover.BackupMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.BackupMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.BackupMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.BackupMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Discover.BackupMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Discover.BackupMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Discover.BackupMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BackupMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BackupMessage) + org.tron.protos.Discover.BackupMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Discover.internal_static_protocol_BackupMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Discover.internal_static_protocol_BackupMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Discover.BackupMessage.class, org.tron.protos.Discover.BackupMessage.Builder.class); + } + + // Construct using org.tron.protos.Discover.BackupMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + flag_ = false; + + priority_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Discover.internal_static_protocol_BackupMessage_descriptor; + } + + public org.tron.protos.Discover.BackupMessage getDefaultInstanceForType() { + return org.tron.protos.Discover.BackupMessage.getDefaultInstance(); + } + + public org.tron.protos.Discover.BackupMessage build() { + org.tron.protos.Discover.BackupMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Discover.BackupMessage buildPartial() { + org.tron.protos.Discover.BackupMessage result = new org.tron.protos.Discover.BackupMessage(this); + result.flag_ = flag_; + result.priority_ = priority_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Discover.BackupMessage) { + return mergeFrom((org.tron.protos.Discover.BackupMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Discover.BackupMessage other) { + if (other == org.tron.protos.Discover.BackupMessage.getDefaultInstance()) return this; + if (other.getFlag() != false) { + setFlag(other.getFlag()); + } + if (other.getPriority() != 0) { + setPriority(other.getPriority()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Discover.BackupMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Discover.BackupMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean flag_ ; + /** + * bool flag = 1; + */ + public boolean getFlag() { + return flag_; + } + /** + * bool flag = 1; + */ + public Builder setFlag(boolean value) { + + flag_ = value; + onChanged(); + return this; + } + /** + * bool flag = 1; + */ + public Builder clearFlag() { + + flag_ = false; + onChanged(); + return this; + } + + private int priority_ ; + /** + * int32 priority = 2; + */ + public int getPriority() { + return priority_; + } + /** + * int32 priority = 2; + */ + public Builder setPriority(int value) { + + priority_ = value; + onChanged(); + return this; + } + /** + * int32 priority = 2; + */ + public Builder clearPriority() { + + priority_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BackupMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.BackupMessage) + private static final org.tron.protos.Discover.BackupMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Discover.BackupMessage(); + } + + public static org.tron.protos.Discover.BackupMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BackupMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BackupMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Discover.BackupMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Endpoint_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Endpoint_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_PingMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_PingMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_PongMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_PongMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_FindNeighbours_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_FindNeighbours_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Neighbours_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Neighbours_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BackupMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BackupMessage_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\023core/Discover.proto\022\010protocol\"9\n\010Endpo" + + "int\022\017\n\007address\030\001 \001(\014\022\014\n\004port\030\002 \001(\005\022\016\n\006no" + + "deId\030\003 \001(\014\"s\n\013PingMessage\022 \n\004from\030\001 \001(\0132" + + "\022.protocol.Endpoint\022\036\n\002to\030\002 \001(\0132\022.protoc" + + "ol.Endpoint\022\017\n\007version\030\003 \001(\005\022\021\n\ttimestam" + + "p\030\004 \001(\003\"P\n\013PongMessage\022 \n\004from\030\001 \001(\0132\022.p" + + "rotocol.Endpoint\022\014\n\004echo\030\002 \001(\005\022\021\n\ttimest" + + "amp\030\003 \001(\003\"W\n\016FindNeighbours\022 \n\004from\030\001 \001(" + + "\0132\022.protocol.Endpoint\022\020\n\010targetId\030\002 \001(\014\022" + + "\021\n\ttimestamp\030\003 \001(\003\"i\n\nNeighbours\022 \n\004from" + + "\030\001 \001(\0132\022.protocol.Endpoint\022&\n\nneighbours" + + "\030\002 \003(\0132\022.protocol.Endpoint\022\021\n\ttimestamp\030" + + "\003 \001(\003\"/\n\rBackupMessage\022\014\n\004flag\030\001 \001(\010\022\020\n\010" + + "priority\030\002 \001(\005BF\n\017org.tron.protosB\010Disco" + + "verZ)github.com/tronprotocol/grpc-gatewa" + + "y/coreb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_protocol_Endpoint_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_protocol_Endpoint_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Endpoint_descriptor, + new java.lang.String[] { "Address", "Port", "NodeId", }); + internal_static_protocol_PingMessage_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_protocol_PingMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_PingMessage_descriptor, + new java.lang.String[] { "From", "To", "Version", "Timestamp", }); + internal_static_protocol_PongMessage_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_protocol_PongMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_PongMessage_descriptor, + new java.lang.String[] { "From", "Echo", "Timestamp", }); + internal_static_protocol_FindNeighbours_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_protocol_FindNeighbours_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_FindNeighbours_descriptor, + new java.lang.String[] { "From", "TargetId", "Timestamp", }); + internal_static_protocol_Neighbours_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_protocol_Neighbours_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Neighbours_descriptor, + new java.lang.String[] { "From", "Neighbours", "Timestamp", }); + internal_static_protocol_BackupMessage_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_protocol_BackupMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BackupMessage_descriptor, + new java.lang.String[] { "Flag", "Priority", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/framework/src/main/gen/org/tron/protos/Protocol.java b/framework/src/main/gen/org/tron/protos/Protocol.java new file mode 100644 index 00000000000..a137476108f --- /dev/null +++ b/framework/src/main/gen/org/tron/protos/Protocol.java @@ -0,0 +1,62209 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: core/Tron.proto + +package org.tron.protos; + +public final class Protocol { + private Protocol() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + /** + * Protobuf enum {@code protocol.AccountType} + */ + public enum AccountType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * Normal = 0; + */ + Normal(0), + /** + * AssetIssue = 1; + */ + AssetIssue(1), + /** + * Contract = 2; + */ + Contract(2), + UNRECOGNIZED(-1), + ; + + /** + * Normal = 0; + */ + public static final int Normal_VALUE = 0; + /** + * AssetIssue = 1; + */ + public static final int AssetIssue_VALUE = 1; + /** + * Contract = 2; + */ + public static final int Contract_VALUE = 2; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static AccountType valueOf(int value) { + return forNumber(value); + } + + public static AccountType forNumber(int value) { + switch (value) { + case 0: return Normal; + case 1: return AssetIssue; + case 2: return Contract; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + AccountType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public AccountType findValueByNumber(int number) { + return AccountType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.getDescriptor().getEnumTypes().get(0); + } + + private static final AccountType[] VALUES = values(); + + public static AccountType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private AccountType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.AccountType) + } + + /** + * Protobuf enum {@code protocol.ReasonCode} + */ + public enum ReasonCode + implements com.google.protobuf.ProtocolMessageEnum { + /** + * REQUESTED = 0; + */ + REQUESTED(0), + /** + * BAD_PROTOCOL = 2; + */ + BAD_PROTOCOL(2), + /** + * TOO_MANY_PEERS = 4; + */ + TOO_MANY_PEERS(4), + /** + * DUPLICATE_PEER = 5; + */ + DUPLICATE_PEER(5), + /** + * INCOMPATIBLE_PROTOCOL = 6; + */ + INCOMPATIBLE_PROTOCOL(6), + /** + * NULL_IDENTITY = 7; + */ + NULL_IDENTITY(7), + /** + * PEER_QUITING = 8; + */ + PEER_QUITING(8), + /** + * UNEXPECTED_IDENTITY = 9; + */ + UNEXPECTED_IDENTITY(9), + /** + * LOCAL_IDENTITY = 10; + */ + LOCAL_IDENTITY(10), + /** + * PING_TIMEOUT = 11; + */ + PING_TIMEOUT(11), + /** + * USER_REASON = 16; + */ + USER_REASON(16), + /** + * RESET = 17; + */ + RESET(17), + /** + * SYNC_FAIL = 18; + */ + SYNC_FAIL(18), + /** + * FETCH_FAIL = 19; + */ + FETCH_FAIL(19), + /** + * BAD_TX = 20; + */ + BAD_TX(20), + /** + * BAD_BLOCK = 21; + */ + BAD_BLOCK(21), + /** + * FORKED = 22; + */ + FORKED(22), + /** + * UNLINKABLE = 23; + */ + UNLINKABLE(23), + /** + * INCOMPATIBLE_VERSION = 24; + */ + INCOMPATIBLE_VERSION(24), + /** + * INCOMPATIBLE_CHAIN = 25; + */ + INCOMPATIBLE_CHAIN(25), + /** + * TIME_OUT = 32; + */ + TIME_OUT(32), + /** + * CONNECT_FAIL = 33; + */ + CONNECT_FAIL(33), + /** + * TOO_MANY_PEERS_WITH_SAME_IP = 34; + */ + TOO_MANY_PEERS_WITH_SAME_IP(34), + /** + * UNKNOWN = 255; + */ + UNKNOWN(255), + UNRECOGNIZED(-1), + ; + + /** + * REQUESTED = 0; + */ + public static final int REQUESTED_VALUE = 0; + /** + * BAD_PROTOCOL = 2; + */ + public static final int BAD_PROTOCOL_VALUE = 2; + /** + * TOO_MANY_PEERS = 4; + */ + public static final int TOO_MANY_PEERS_VALUE = 4; + /** + * DUPLICATE_PEER = 5; + */ + public static final int DUPLICATE_PEER_VALUE = 5; + /** + * INCOMPATIBLE_PROTOCOL = 6; + */ + public static final int INCOMPATIBLE_PROTOCOL_VALUE = 6; + /** + * NULL_IDENTITY = 7; + */ + public static final int NULL_IDENTITY_VALUE = 7; + /** + * PEER_QUITING = 8; + */ + public static final int PEER_QUITING_VALUE = 8; + /** + * UNEXPECTED_IDENTITY = 9; + */ + public static final int UNEXPECTED_IDENTITY_VALUE = 9; + /** + * LOCAL_IDENTITY = 10; + */ + public static final int LOCAL_IDENTITY_VALUE = 10; + /** + * PING_TIMEOUT = 11; + */ + public static final int PING_TIMEOUT_VALUE = 11; + /** + * USER_REASON = 16; + */ + public static final int USER_REASON_VALUE = 16; + /** + * RESET = 17; + */ + public static final int RESET_VALUE = 17; + /** + * SYNC_FAIL = 18; + */ + public static final int SYNC_FAIL_VALUE = 18; + /** + * FETCH_FAIL = 19; + */ + public static final int FETCH_FAIL_VALUE = 19; + /** + * BAD_TX = 20; + */ + public static final int BAD_TX_VALUE = 20; + /** + * BAD_BLOCK = 21; + */ + public static final int BAD_BLOCK_VALUE = 21; + /** + * FORKED = 22; + */ + public static final int FORKED_VALUE = 22; + /** + * UNLINKABLE = 23; + */ + public static final int UNLINKABLE_VALUE = 23; + /** + * INCOMPATIBLE_VERSION = 24; + */ + public static final int INCOMPATIBLE_VERSION_VALUE = 24; + /** + * INCOMPATIBLE_CHAIN = 25; + */ + public static final int INCOMPATIBLE_CHAIN_VALUE = 25; + /** + * TIME_OUT = 32; + */ + public static final int TIME_OUT_VALUE = 32; + /** + * CONNECT_FAIL = 33; + */ + public static final int CONNECT_FAIL_VALUE = 33; + /** + * TOO_MANY_PEERS_WITH_SAME_IP = 34; + */ + public static final int TOO_MANY_PEERS_WITH_SAME_IP_VALUE = 34; + /** + * UNKNOWN = 255; + */ + public static final int UNKNOWN_VALUE = 255; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ReasonCode valueOf(int value) { + return forNumber(value); + } + + public static ReasonCode forNumber(int value) { + switch (value) { + case 0: return REQUESTED; + case 2: return BAD_PROTOCOL; + case 4: return TOO_MANY_PEERS; + case 5: return DUPLICATE_PEER; + case 6: return INCOMPATIBLE_PROTOCOL; + case 7: return NULL_IDENTITY; + case 8: return PEER_QUITING; + case 9: return UNEXPECTED_IDENTITY; + case 10: return LOCAL_IDENTITY; + case 11: return PING_TIMEOUT; + case 16: return USER_REASON; + case 17: return RESET; + case 18: return SYNC_FAIL; + case 19: return FETCH_FAIL; + case 20: return BAD_TX; + case 21: return BAD_BLOCK; + case 22: return FORKED; + case 23: return UNLINKABLE; + case 24: return INCOMPATIBLE_VERSION; + case 25: return INCOMPATIBLE_CHAIN; + case 32: return TIME_OUT; + case 33: return CONNECT_FAIL; + case 34: return TOO_MANY_PEERS_WITH_SAME_IP; + case 255: return UNKNOWN; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + ReasonCode> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ReasonCode findValueByNumber(int number) { + return ReasonCode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.getDescriptor().getEnumTypes().get(1); + } + + private static final ReasonCode[] VALUES = values(); + + public static ReasonCode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ReasonCode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.ReasonCode) + } + + public interface AccountIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.AccountId) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes name = 1; + */ + com.google.protobuf.ByteString getName(); + + /** + * bytes address = 2; + */ + com.google.protobuf.ByteString getAddress(); + } + /** + *
+   * AccountId, (name, address) use name, (null, address) use address, (name, null) use name,
+   * 
+ * + * Protobuf type {@code protocol.AccountId} + */ + public static final class AccountId extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.AccountId) + AccountIdOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountId.newBuilder() to construct. + private AccountId(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountId() { + name_ = com.google.protobuf.ByteString.EMPTY; + address_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountId( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + name_ = input.readBytes(); + break; + } + case 18: { + + address_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_AccountId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_AccountId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.AccountId.class, org.tron.protos.Protocol.AccountId.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString name_; + /** + * bytes name = 1; + */ + public com.google.protobuf.ByteString getName() { + return name_; + } + + public static final int ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString address_; + /** + * bytes address = 2; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!name_.isEmpty()) { + output.writeBytes(1, name_); + } + if (!address_.isEmpty()) { + output.writeBytes(2, address_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!name_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, name_); + } + if (!address_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, address_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.AccountId)) { + return super.equals(obj); + } + org.tron.protos.Protocol.AccountId other = (org.tron.protos.Protocol.AccountId) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && getAddress() + .equals(other.getAddress()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.AccountId parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.AccountId parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.AccountId parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.AccountId parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.AccountId parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.AccountId parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.AccountId parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.AccountId parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.AccountId parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.AccountId parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.AccountId parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.AccountId parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.AccountId prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * AccountId, (name, address) use name, (null, address) use address, (name, null) use name,
+     * 
+ * + * Protobuf type {@code protocol.AccountId} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.AccountId) + org.tron.protos.Protocol.AccountIdOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_AccountId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_AccountId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.AccountId.class, org.tron.protos.Protocol.AccountId.Builder.class); + } + + // Construct using org.tron.protos.Protocol.AccountId.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = com.google.protobuf.ByteString.EMPTY; + + address_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_AccountId_descriptor; + } + + public org.tron.protos.Protocol.AccountId getDefaultInstanceForType() { + return org.tron.protos.Protocol.AccountId.getDefaultInstance(); + } + + public org.tron.protos.Protocol.AccountId build() { + org.tron.protos.Protocol.AccountId result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.AccountId buildPartial() { + org.tron.protos.Protocol.AccountId result = new org.tron.protos.Protocol.AccountId(this); + result.name_ = name_; + result.address_ = address_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.AccountId) { + return mergeFrom((org.tron.protos.Protocol.AccountId)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.AccountId other) { + if (other == org.tron.protos.Protocol.AccountId.getDefaultInstance()) return this; + if (other.getName() != com.google.protobuf.ByteString.EMPTY) { + setName(other.getName()); + } + if (other.getAddress() != com.google.protobuf.ByteString.EMPTY) { + setAddress(other.getAddress()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.AccountId parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.AccountId) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString name_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes name = 1; + */ + public com.google.protobuf.ByteString getName() { + return name_; + } + /** + * bytes name = 1; + */ + public Builder setName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * bytes name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString address_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes address = 2; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + /** + * bytes address = 2; + */ + public Builder setAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + * bytes address = 2; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.AccountId) + } + + // @@protoc_insertion_point(class_scope:protocol.AccountId) + private static final org.tron.protos.Protocol.AccountId DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.AccountId(); + } + + public static org.tron.protos.Protocol.AccountId getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountId parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountId(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.AccountId getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface VoteOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Vote) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * the super rep address
+     * 
+ * + * bytes vote_address = 1; + */ + com.google.protobuf.ByteString getVoteAddress(); + + /** + *
+     * the vote num to this super rep.
+     * 
+ * + * int64 vote_count = 2; + */ + long getVoteCount(); + } + /** + *
+   * vote message
+   * 
+ * + * Protobuf type {@code protocol.Vote} + */ + public static final class Vote extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Vote) + VoteOrBuilder { + private static final long serialVersionUID = 0L; + // Use Vote.newBuilder() to construct. + private Vote(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Vote() { + voteAddress_ = com.google.protobuf.ByteString.EMPTY; + voteCount_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Vote( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + voteAddress_ = input.readBytes(); + break; + } + case 16: { + + voteCount_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Vote_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Vote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Vote.class, org.tron.protos.Protocol.Vote.Builder.class); + } + + public static final int VOTE_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString voteAddress_; + /** + *
+     * the super rep address
+     * 
+ * + * bytes vote_address = 1; + */ + public com.google.protobuf.ByteString getVoteAddress() { + return voteAddress_; + } + + public static final int VOTE_COUNT_FIELD_NUMBER = 2; + private long voteCount_; + /** + *
+     * the vote num to this super rep.
+     * 
+ * + * int64 vote_count = 2; + */ + public long getVoteCount() { + return voteCount_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!voteAddress_.isEmpty()) { + output.writeBytes(1, voteAddress_); + } + if (voteCount_ != 0L) { + output.writeInt64(2, voteCount_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!voteAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, voteAddress_); + } + if (voteCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, voteCount_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Vote)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Vote other = (org.tron.protos.Protocol.Vote) obj; + + boolean result = true; + result = result && getVoteAddress() + .equals(other.getVoteAddress()); + result = result && (getVoteCount() + == other.getVoteCount()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + VOTE_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getVoteAddress().hashCode(); + hash = (37 * hash) + VOTE_COUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getVoteCount()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Vote parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Vote parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Vote parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Vote parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Vote parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Vote parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Vote parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Vote parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Vote parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Vote parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Vote parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Vote parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Vote prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * vote message
+     * 
+ * + * Protobuf type {@code protocol.Vote} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Vote) + org.tron.protos.Protocol.VoteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Vote_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Vote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Vote.class, org.tron.protos.Protocol.Vote.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Vote.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + voteAddress_ = com.google.protobuf.ByteString.EMPTY; + + voteCount_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Vote_descriptor; + } + + public org.tron.protos.Protocol.Vote getDefaultInstanceForType() { + return org.tron.protos.Protocol.Vote.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Vote build() { + org.tron.protos.Protocol.Vote result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Vote buildPartial() { + org.tron.protos.Protocol.Vote result = new org.tron.protos.Protocol.Vote(this); + result.voteAddress_ = voteAddress_; + result.voteCount_ = voteCount_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Vote) { + return mergeFrom((org.tron.protos.Protocol.Vote)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Vote other) { + if (other == org.tron.protos.Protocol.Vote.getDefaultInstance()) return this; + if (other.getVoteAddress() != com.google.protobuf.ByteString.EMPTY) { + setVoteAddress(other.getVoteAddress()); + } + if (other.getVoteCount() != 0L) { + setVoteCount(other.getVoteCount()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Vote parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Vote) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString voteAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * the super rep address
+       * 
+ * + * bytes vote_address = 1; + */ + public com.google.protobuf.ByteString getVoteAddress() { + return voteAddress_; + } + /** + *
+       * the super rep address
+       * 
+ * + * bytes vote_address = 1; + */ + public Builder setVoteAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + voteAddress_ = value; + onChanged(); + return this; + } + /** + *
+       * the super rep address
+       * 
+ * + * bytes vote_address = 1; + */ + public Builder clearVoteAddress() { + + voteAddress_ = getDefaultInstance().getVoteAddress(); + onChanged(); + return this; + } + + private long voteCount_ ; + /** + *
+       * the vote num to this super rep.
+       * 
+ * + * int64 vote_count = 2; + */ + public long getVoteCount() { + return voteCount_; + } + /** + *
+       * the vote num to this super rep.
+       * 
+ * + * int64 vote_count = 2; + */ + public Builder setVoteCount(long value) { + + voteCount_ = value; + onChanged(); + return this; + } + /** + *
+       * the vote num to this super rep.
+       * 
+ * + * int64 vote_count = 2; + */ + public Builder clearVoteCount() { + + voteCount_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Vote) + } + + // @@protoc_insertion_point(class_scope:protocol.Vote) + private static final org.tron.protos.Protocol.Vote DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Vote(); + } + + public static org.tron.protos.Protocol.Vote getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Vote parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Vote(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Vote getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ProposalOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Proposal) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 proposal_id = 1; + */ + long getProposalId(); + + /** + * bytes proposer_address = 2; + */ + com.google.protobuf.ByteString getProposerAddress(); + + /** + * map<int64, int64> parameters = 3; + */ + int getParametersCount(); + /** + * map<int64, int64> parameters = 3; + */ + boolean containsParameters( + long key); + /** + * Use {@link #getParametersMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getParameters(); + /** + * map<int64, int64> parameters = 3; + */ + java.util.Map + getParametersMap(); + /** + * map<int64, int64> parameters = 3; + */ + + long getParametersOrDefault( + long key, + long defaultValue); + /** + * map<int64, int64> parameters = 3; + */ + + long getParametersOrThrow( + long key); + + /** + * int64 expiration_time = 4; + */ + long getExpirationTime(); + + /** + * int64 create_time = 5; + */ + long getCreateTime(); + + /** + * repeated bytes approvals = 6; + */ + java.util.List getApprovalsList(); + /** + * repeated bytes approvals = 6; + */ + int getApprovalsCount(); + /** + * repeated bytes approvals = 6; + */ + com.google.protobuf.ByteString getApprovals(int index); + + /** + * .protocol.Proposal.State state = 7; + */ + int getStateValue(); + /** + * .protocol.Proposal.State state = 7; + */ + org.tron.protos.Protocol.Proposal.State getState(); + } + /** + *
+   * Proposal
+   * 
+ * + * Protobuf type {@code protocol.Proposal} + */ + public static final class Proposal extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Proposal) + ProposalOrBuilder { + private static final long serialVersionUID = 0L; + // Use Proposal.newBuilder() to construct. + private Proposal(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Proposal() { + proposalId_ = 0L; + proposerAddress_ = com.google.protobuf.ByteString.EMPTY; + expirationTime_ = 0L; + createTime_ = 0L; + approvals_ = java.util.Collections.emptyList(); + state_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Proposal( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + proposalId_ = input.readInt64(); + break; + } + case 18: { + + proposerAddress_ = input.readBytes(); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + parameters_ = com.google.protobuf.MapField.newMapField( + ParametersDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000004; + } + com.google.protobuf.MapEntry + parameters__ = input.readMessage( + ParametersDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + parameters_.getMutableMap().put( + parameters__.getKey(), parameters__.getValue()); + break; + } + case 32: { + + expirationTime_ = input.readInt64(); + break; + } + case 40: { + + createTime_ = input.readInt64(); + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + approvals_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + approvals_.add(input.readBytes()); + break; + } + case 56: { + int rawValue = input.readEnum(); + + state_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + approvals_ = java.util.Collections.unmodifiableList(approvals_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Proposal_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 3: + return internalGetParameters(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Proposal_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Proposal.class, org.tron.protos.Protocol.Proposal.Builder.class); + } + + /** + * Protobuf enum {@code protocol.Proposal.State} + */ + public enum State + implements com.google.protobuf.ProtocolMessageEnum { + /** + * PENDING = 0; + */ + PENDING(0), + /** + * DISAPPROVED = 1; + */ + DISAPPROVED(1), + /** + * APPROVED = 2; + */ + APPROVED(2), + /** + * CANCELED = 3; + */ + CANCELED(3), + UNRECOGNIZED(-1), + ; + + /** + * PENDING = 0; + */ + public static final int PENDING_VALUE = 0; + /** + * DISAPPROVED = 1; + */ + public static final int DISAPPROVED_VALUE = 1; + /** + * APPROVED = 2; + */ + public static final int APPROVED_VALUE = 2; + /** + * CANCELED = 3; + */ + public static final int CANCELED_VALUE = 3; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static State valueOf(int value) { + return forNumber(value); + } + + public static State forNumber(int value) { + switch (value) { + case 0: return PENDING; + case 1: return DISAPPROVED; + case 2: return APPROVED; + case 3: return CANCELED; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + State> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.Proposal.getDescriptor().getEnumTypes().get(0); + } + + private static final State[] VALUES = values(); + + public static State valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private State(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Proposal.State) + } + + private int bitField0_; + public static final int PROPOSAL_ID_FIELD_NUMBER = 1; + private long proposalId_; + /** + * int64 proposal_id = 1; + */ + public long getProposalId() { + return proposalId_; + } + + public static final int PROPOSER_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString proposerAddress_; + /** + * bytes proposer_address = 2; + */ + public com.google.protobuf.ByteString getProposerAddress() { + return proposerAddress_; + } + + public static final int PARAMETERS_FIELD_NUMBER = 3; + private static final class ParametersDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.Long, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_Proposal_ParametersEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.INT64, + 0L, + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.Long, java.lang.Long> parameters_; + private com.google.protobuf.MapField + internalGetParameters() { + if (parameters_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ParametersDefaultEntryHolder.defaultEntry); + } + return parameters_; + } + + public int getParametersCount() { + return internalGetParameters().getMap().size(); + } + /** + * map<int64, int64> parameters = 3; + */ + + public boolean containsParameters( + long key) { + + return internalGetParameters().getMap().containsKey(key); + } + /** + * Use {@link #getParametersMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getParameters() { + return getParametersMap(); + } + /** + * map<int64, int64> parameters = 3; + */ + + public java.util.Map getParametersMap() { + return internalGetParameters().getMap(); + } + /** + * map<int64, int64> parameters = 3; + */ + + public long getParametersOrDefault( + long key, + long defaultValue) { + + java.util.Map map = + internalGetParameters().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<int64, int64> parameters = 3; + */ + + public long getParametersOrThrow( + long key) { + + java.util.Map map = + internalGetParameters().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int EXPIRATION_TIME_FIELD_NUMBER = 4; + private long expirationTime_; + /** + * int64 expiration_time = 4; + */ + public long getExpirationTime() { + return expirationTime_; + } + + public static final int CREATE_TIME_FIELD_NUMBER = 5; + private long createTime_; + /** + * int64 create_time = 5; + */ + public long getCreateTime() { + return createTime_; + } + + public static final int APPROVALS_FIELD_NUMBER = 6; + private java.util.List approvals_; + /** + * repeated bytes approvals = 6; + */ + public java.util.List + getApprovalsList() { + return approvals_; + } + /** + * repeated bytes approvals = 6; + */ + public int getApprovalsCount() { + return approvals_.size(); + } + /** + * repeated bytes approvals = 6; + */ + public com.google.protobuf.ByteString getApprovals(int index) { + return approvals_.get(index); + } + + public static final int STATE_FIELD_NUMBER = 7; + private int state_; + /** + * .protocol.Proposal.State state = 7; + */ + public int getStateValue() { + return state_; + } + /** + * .protocol.Proposal.State state = 7; + */ + public org.tron.protos.Protocol.Proposal.State getState() { + org.tron.protos.Protocol.Proposal.State result = org.tron.protos.Protocol.Proposal.State.valueOf(state_); + return result == null ? org.tron.protos.Protocol.Proposal.State.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (proposalId_ != 0L) { + output.writeInt64(1, proposalId_); + } + if (!proposerAddress_.isEmpty()) { + output.writeBytes(2, proposerAddress_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeLongMapTo( + output, + internalGetParameters(), + ParametersDefaultEntryHolder.defaultEntry, + 3); + if (expirationTime_ != 0L) { + output.writeInt64(4, expirationTime_); + } + if (createTime_ != 0L) { + output.writeInt64(5, createTime_); + } + for (int i = 0; i < approvals_.size(); i++) { + output.writeBytes(6, approvals_.get(i)); + } + if (state_ != org.tron.protos.Protocol.Proposal.State.PENDING.getNumber()) { + output.writeEnum(7, state_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (proposalId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, proposalId_); + } + if (!proposerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, proposerAddress_); + } + for (java.util.Map.Entry entry + : internalGetParameters().getMap().entrySet()) { + com.google.protobuf.MapEntry + parameters__ = ParametersDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, parameters__); + } + if (expirationTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, expirationTime_); + } + if (createTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, createTime_); + } + { + int dataSize = 0; + for (int i = 0; i < approvals_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(approvals_.get(i)); + } + size += dataSize; + size += 1 * getApprovalsList().size(); + } + if (state_ != org.tron.protos.Protocol.Proposal.State.PENDING.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(7, state_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Proposal)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Proposal other = (org.tron.protos.Protocol.Proposal) obj; + + boolean result = true; + result = result && (getProposalId() + == other.getProposalId()); + result = result && getProposerAddress() + .equals(other.getProposerAddress()); + result = result && internalGetParameters().equals( + other.internalGetParameters()); + result = result && (getExpirationTime() + == other.getExpirationTime()); + result = result && (getCreateTime() + == other.getCreateTime()); + result = result && getApprovalsList() + .equals(other.getApprovalsList()); + result = result && state_ == other.state_; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PROPOSAL_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getProposalId()); + hash = (37 * hash) + PROPOSER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getProposerAddress().hashCode(); + if (!internalGetParameters().getMap().isEmpty()) { + hash = (37 * hash) + PARAMETERS_FIELD_NUMBER; + hash = (53 * hash) + internalGetParameters().hashCode(); + } + hash = (37 * hash) + EXPIRATION_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExpirationTime()); + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCreateTime()); + if (getApprovalsCount() > 0) { + hash = (37 * hash) + APPROVALS_FIELD_NUMBER; + hash = (53 * hash) + getApprovalsList().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Proposal parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Proposal parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Proposal parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Proposal parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Proposal parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Proposal parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Proposal parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Proposal parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Proposal parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Proposal parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Proposal parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Proposal parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Proposal prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Proposal
+     * 
+ * + * Protobuf type {@code protocol.Proposal} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Proposal) + org.tron.protos.Protocol.ProposalOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Proposal_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 3: + return internalGetParameters(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 3: + return internalGetMutableParameters(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Proposal_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Proposal.class, org.tron.protos.Protocol.Proposal.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Proposal.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + proposalId_ = 0L; + + proposerAddress_ = com.google.protobuf.ByteString.EMPTY; + + internalGetMutableParameters().clear(); + expirationTime_ = 0L; + + createTime_ = 0L; + + approvals_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + state_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Proposal_descriptor; + } + + public org.tron.protos.Protocol.Proposal getDefaultInstanceForType() { + return org.tron.protos.Protocol.Proposal.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Proposal build() { + org.tron.protos.Protocol.Proposal result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Proposal buildPartial() { + org.tron.protos.Protocol.Proposal result = new org.tron.protos.Protocol.Proposal(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.proposalId_ = proposalId_; + result.proposerAddress_ = proposerAddress_; + result.parameters_ = internalGetParameters(); + result.parameters_.makeImmutable(); + result.expirationTime_ = expirationTime_; + result.createTime_ = createTime_; + if (((bitField0_ & 0x00000020) == 0x00000020)) { + approvals_ = java.util.Collections.unmodifiableList(approvals_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.approvals_ = approvals_; + result.state_ = state_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Proposal) { + return mergeFrom((org.tron.protos.Protocol.Proposal)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Proposal other) { + if (other == org.tron.protos.Protocol.Proposal.getDefaultInstance()) return this; + if (other.getProposalId() != 0L) { + setProposalId(other.getProposalId()); + } + if (other.getProposerAddress() != com.google.protobuf.ByteString.EMPTY) { + setProposerAddress(other.getProposerAddress()); + } + internalGetMutableParameters().mergeFrom( + other.internalGetParameters()); + if (other.getExpirationTime() != 0L) { + setExpirationTime(other.getExpirationTime()); + } + if (other.getCreateTime() != 0L) { + setCreateTime(other.getCreateTime()); + } + if (!other.approvals_.isEmpty()) { + if (approvals_.isEmpty()) { + approvals_ = other.approvals_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureApprovalsIsMutable(); + approvals_.addAll(other.approvals_); + } + onChanged(); + } + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Proposal parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Proposal) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long proposalId_ ; + /** + * int64 proposal_id = 1; + */ + public long getProposalId() { + return proposalId_; + } + /** + * int64 proposal_id = 1; + */ + public Builder setProposalId(long value) { + + proposalId_ = value; + onChanged(); + return this; + } + /** + * int64 proposal_id = 1; + */ + public Builder clearProposalId() { + + proposalId_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString proposerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes proposer_address = 2; + */ + public com.google.protobuf.ByteString getProposerAddress() { + return proposerAddress_; + } + /** + * bytes proposer_address = 2; + */ + public Builder setProposerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + proposerAddress_ = value; + onChanged(); + return this; + } + /** + * bytes proposer_address = 2; + */ + public Builder clearProposerAddress() { + + proposerAddress_ = getDefaultInstance().getProposerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.Long, java.lang.Long> parameters_; + private com.google.protobuf.MapField + internalGetParameters() { + if (parameters_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ParametersDefaultEntryHolder.defaultEntry); + } + return parameters_; + } + private com.google.protobuf.MapField + internalGetMutableParameters() { + onChanged();; + if (parameters_ == null) { + parameters_ = com.google.protobuf.MapField.newMapField( + ParametersDefaultEntryHolder.defaultEntry); + } + if (!parameters_.isMutable()) { + parameters_ = parameters_.copy(); + } + return parameters_; + } + + public int getParametersCount() { + return internalGetParameters().getMap().size(); + } + /** + * map<int64, int64> parameters = 3; + */ + + public boolean containsParameters( + long key) { + + return internalGetParameters().getMap().containsKey(key); + } + /** + * Use {@link #getParametersMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getParameters() { + return getParametersMap(); + } + /** + * map<int64, int64> parameters = 3; + */ + + public java.util.Map getParametersMap() { + return internalGetParameters().getMap(); + } + /** + * map<int64, int64> parameters = 3; + */ + + public long getParametersOrDefault( + long key, + long defaultValue) { + + java.util.Map map = + internalGetParameters().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<int64, int64> parameters = 3; + */ + + public long getParametersOrThrow( + long key) { + + java.util.Map map = + internalGetParameters().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearParameters() { + internalGetMutableParameters().getMutableMap() + .clear(); + return this; + } + /** + * map<int64, int64> parameters = 3; + */ + + public Builder removeParameters( + long key) { + + internalGetMutableParameters().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableParameters() { + return internalGetMutableParameters().getMutableMap(); + } + /** + * map<int64, int64> parameters = 3; + */ + public Builder putParameters( + long key, + long value) { + + + internalGetMutableParameters().getMutableMap() + .put(key, value); + return this; + } + /** + * map<int64, int64> parameters = 3; + */ + + public Builder putAllParameters( + java.util.Map values) { + internalGetMutableParameters().getMutableMap() + .putAll(values); + return this; + } + + private long expirationTime_ ; + /** + * int64 expiration_time = 4; + */ + public long getExpirationTime() { + return expirationTime_; + } + /** + * int64 expiration_time = 4; + */ + public Builder setExpirationTime(long value) { + + expirationTime_ = value; + onChanged(); + return this; + } + /** + * int64 expiration_time = 4; + */ + public Builder clearExpirationTime() { + + expirationTime_ = 0L; + onChanged(); + return this; + } + + private long createTime_ ; + /** + * int64 create_time = 5; + */ + public long getCreateTime() { + return createTime_; + } + /** + * int64 create_time = 5; + */ + public Builder setCreateTime(long value) { + + createTime_ = value; + onChanged(); + return this; + } + /** + * int64 create_time = 5; + */ + public Builder clearCreateTime() { + + createTime_ = 0L; + onChanged(); + return this; + } + + private java.util.List approvals_ = java.util.Collections.emptyList(); + private void ensureApprovalsIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + approvals_ = new java.util.ArrayList(approvals_); + bitField0_ |= 0x00000020; + } + } + /** + * repeated bytes approvals = 6; + */ + public java.util.List + getApprovalsList() { + return java.util.Collections.unmodifiableList(approvals_); + } + /** + * repeated bytes approvals = 6; + */ + public int getApprovalsCount() { + return approvals_.size(); + } + /** + * repeated bytes approvals = 6; + */ + public com.google.protobuf.ByteString getApprovals(int index) { + return approvals_.get(index); + } + /** + * repeated bytes approvals = 6; + */ + public Builder setApprovals( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureApprovalsIsMutable(); + approvals_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes approvals = 6; + */ + public Builder addApprovals(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureApprovalsIsMutable(); + approvals_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes approvals = 6; + */ + public Builder addAllApprovals( + java.lang.Iterable values) { + ensureApprovalsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, approvals_); + onChanged(); + return this; + } + /** + * repeated bytes approvals = 6; + */ + public Builder clearApprovals() { + approvals_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + + private int state_ = 0; + /** + * .protocol.Proposal.State state = 7; + */ + public int getStateValue() { + return state_; + } + /** + * .protocol.Proposal.State state = 7; + */ + public Builder setStateValue(int value) { + state_ = value; + onChanged(); + return this; + } + /** + * .protocol.Proposal.State state = 7; + */ + public org.tron.protos.Protocol.Proposal.State getState() { + org.tron.protos.Protocol.Proposal.State result = org.tron.protos.Protocol.Proposal.State.valueOf(state_); + return result == null ? org.tron.protos.Protocol.Proposal.State.UNRECOGNIZED : result; + } + /** + * .protocol.Proposal.State state = 7; + */ + public Builder setState(org.tron.protos.Protocol.Proposal.State value) { + if (value == null) { + throw new NullPointerException(); + } + + state_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Proposal.State state = 7; + */ + public Builder clearState() { + + state_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Proposal) + } + + // @@protoc_insertion_point(class_scope:protocol.Proposal) + private static final org.tron.protos.Protocol.Proposal DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Proposal(); + } + + public static org.tron.protos.Protocol.Proposal getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Proposal parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Proposal(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Proposal getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ExchangeOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Exchange) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 exchange_id = 1; + */ + long getExchangeId(); + + /** + * bytes creator_address = 2; + */ + com.google.protobuf.ByteString getCreatorAddress(); + + /** + * int64 create_time = 3; + */ + long getCreateTime(); + + /** + * bytes first_token_id = 6; + */ + com.google.protobuf.ByteString getFirstTokenId(); + + /** + * int64 first_token_balance = 7; + */ + long getFirstTokenBalance(); + + /** + * bytes second_token_id = 8; + */ + com.google.protobuf.ByteString getSecondTokenId(); + + /** + * int64 second_token_balance = 9; + */ + long getSecondTokenBalance(); + } + /** + *
+   * Exchange
+   * 
+ * + * Protobuf type {@code protocol.Exchange} + */ + public static final class Exchange extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Exchange) + ExchangeOrBuilder { + private static final long serialVersionUID = 0L; + // Use Exchange.newBuilder() to construct. + private Exchange(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Exchange() { + exchangeId_ = 0L; + creatorAddress_ = com.google.protobuf.ByteString.EMPTY; + createTime_ = 0L; + firstTokenId_ = com.google.protobuf.ByteString.EMPTY; + firstTokenBalance_ = 0L; + secondTokenId_ = com.google.protobuf.ByteString.EMPTY; + secondTokenBalance_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Exchange( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + exchangeId_ = input.readInt64(); + break; + } + case 18: { + + creatorAddress_ = input.readBytes(); + break; + } + case 24: { + + createTime_ = input.readInt64(); + break; + } + case 50: { + + firstTokenId_ = input.readBytes(); + break; + } + case 56: { + + firstTokenBalance_ = input.readInt64(); + break; + } + case 66: { + + secondTokenId_ = input.readBytes(); + break; + } + case 72: { + + secondTokenBalance_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Exchange_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Exchange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Exchange.class, org.tron.protos.Protocol.Exchange.Builder.class); + } + + public static final int EXCHANGE_ID_FIELD_NUMBER = 1; + private long exchangeId_; + /** + * int64 exchange_id = 1; + */ + public long getExchangeId() { + return exchangeId_; + } + + public static final int CREATOR_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString creatorAddress_; + /** + * bytes creator_address = 2; + */ + public com.google.protobuf.ByteString getCreatorAddress() { + return creatorAddress_; + } + + public static final int CREATE_TIME_FIELD_NUMBER = 3; + private long createTime_; + /** + * int64 create_time = 3; + */ + public long getCreateTime() { + return createTime_; + } + + public static final int FIRST_TOKEN_ID_FIELD_NUMBER = 6; + private com.google.protobuf.ByteString firstTokenId_; + /** + * bytes first_token_id = 6; + */ + public com.google.protobuf.ByteString getFirstTokenId() { + return firstTokenId_; + } + + public static final int FIRST_TOKEN_BALANCE_FIELD_NUMBER = 7; + private long firstTokenBalance_; + /** + * int64 first_token_balance = 7; + */ + public long getFirstTokenBalance() { + return firstTokenBalance_; + } + + public static final int SECOND_TOKEN_ID_FIELD_NUMBER = 8; + private com.google.protobuf.ByteString secondTokenId_; + /** + * bytes second_token_id = 8; + */ + public com.google.protobuf.ByteString getSecondTokenId() { + return secondTokenId_; + } + + public static final int SECOND_TOKEN_BALANCE_FIELD_NUMBER = 9; + private long secondTokenBalance_; + /** + * int64 second_token_balance = 9; + */ + public long getSecondTokenBalance() { + return secondTokenBalance_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (exchangeId_ != 0L) { + output.writeInt64(1, exchangeId_); + } + if (!creatorAddress_.isEmpty()) { + output.writeBytes(2, creatorAddress_); + } + if (createTime_ != 0L) { + output.writeInt64(3, createTime_); + } + if (!firstTokenId_.isEmpty()) { + output.writeBytes(6, firstTokenId_); + } + if (firstTokenBalance_ != 0L) { + output.writeInt64(7, firstTokenBalance_); + } + if (!secondTokenId_.isEmpty()) { + output.writeBytes(8, secondTokenId_); + } + if (secondTokenBalance_ != 0L) { + output.writeInt64(9, secondTokenBalance_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (exchangeId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, exchangeId_); + } + if (!creatorAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, creatorAddress_); + } + if (createTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, createTime_); + } + if (!firstTokenId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(6, firstTokenId_); + } + if (firstTokenBalance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, firstTokenBalance_); + } + if (!secondTokenId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(8, secondTokenId_); + } + if (secondTokenBalance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(9, secondTokenBalance_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Exchange)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Exchange other = (org.tron.protos.Protocol.Exchange) obj; + + boolean result = true; + result = result && (getExchangeId() + == other.getExchangeId()); + result = result && getCreatorAddress() + .equals(other.getCreatorAddress()); + result = result && (getCreateTime() + == other.getCreateTime()); + result = result && getFirstTokenId() + .equals(other.getFirstTokenId()); + result = result && (getFirstTokenBalance() + == other.getFirstTokenBalance()); + result = result && getSecondTokenId() + .equals(other.getSecondTokenId()); + result = result && (getSecondTokenBalance() + == other.getSecondTokenBalance()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + EXCHANGE_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeId()); + hash = (37 * hash) + CREATOR_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getCreatorAddress().hashCode(); + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCreateTime()); + hash = (37 * hash) + FIRST_TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getFirstTokenId().hashCode(); + hash = (37 * hash) + FIRST_TOKEN_BALANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFirstTokenBalance()); + hash = (37 * hash) + SECOND_TOKEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getSecondTokenId().hashCode(); + hash = (37 * hash) + SECOND_TOKEN_BALANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSecondTokenBalance()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Exchange parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Exchange parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Exchange parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Exchange parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Exchange parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Exchange parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Exchange parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Exchange parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Exchange parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Exchange parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Exchange parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Exchange parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Exchange prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Exchange
+     * 
+ * + * Protobuf type {@code protocol.Exchange} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Exchange) + org.tron.protos.Protocol.ExchangeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Exchange_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Exchange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Exchange.class, org.tron.protos.Protocol.Exchange.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Exchange.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + exchangeId_ = 0L; + + creatorAddress_ = com.google.protobuf.ByteString.EMPTY; + + createTime_ = 0L; + + firstTokenId_ = com.google.protobuf.ByteString.EMPTY; + + firstTokenBalance_ = 0L; + + secondTokenId_ = com.google.protobuf.ByteString.EMPTY; + + secondTokenBalance_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Exchange_descriptor; + } + + public org.tron.protos.Protocol.Exchange getDefaultInstanceForType() { + return org.tron.protos.Protocol.Exchange.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Exchange build() { + org.tron.protos.Protocol.Exchange result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Exchange buildPartial() { + org.tron.protos.Protocol.Exchange result = new org.tron.protos.Protocol.Exchange(this); + result.exchangeId_ = exchangeId_; + result.creatorAddress_ = creatorAddress_; + result.createTime_ = createTime_; + result.firstTokenId_ = firstTokenId_; + result.firstTokenBalance_ = firstTokenBalance_; + result.secondTokenId_ = secondTokenId_; + result.secondTokenBalance_ = secondTokenBalance_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Exchange) { + return mergeFrom((org.tron.protos.Protocol.Exchange)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Exchange other) { + if (other == org.tron.protos.Protocol.Exchange.getDefaultInstance()) return this; + if (other.getExchangeId() != 0L) { + setExchangeId(other.getExchangeId()); + } + if (other.getCreatorAddress() != com.google.protobuf.ByteString.EMPTY) { + setCreatorAddress(other.getCreatorAddress()); + } + if (other.getCreateTime() != 0L) { + setCreateTime(other.getCreateTime()); + } + if (other.getFirstTokenId() != com.google.protobuf.ByteString.EMPTY) { + setFirstTokenId(other.getFirstTokenId()); + } + if (other.getFirstTokenBalance() != 0L) { + setFirstTokenBalance(other.getFirstTokenBalance()); + } + if (other.getSecondTokenId() != com.google.protobuf.ByteString.EMPTY) { + setSecondTokenId(other.getSecondTokenId()); + } + if (other.getSecondTokenBalance() != 0L) { + setSecondTokenBalance(other.getSecondTokenBalance()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Exchange parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Exchange) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long exchangeId_ ; + /** + * int64 exchange_id = 1; + */ + public long getExchangeId() { + return exchangeId_; + } + /** + * int64 exchange_id = 1; + */ + public Builder setExchangeId(long value) { + + exchangeId_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_id = 1; + */ + public Builder clearExchangeId() { + + exchangeId_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString creatorAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes creator_address = 2; + */ + public com.google.protobuf.ByteString getCreatorAddress() { + return creatorAddress_; + } + /** + * bytes creator_address = 2; + */ + public Builder setCreatorAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + creatorAddress_ = value; + onChanged(); + return this; + } + /** + * bytes creator_address = 2; + */ + public Builder clearCreatorAddress() { + + creatorAddress_ = getDefaultInstance().getCreatorAddress(); + onChanged(); + return this; + } + + private long createTime_ ; + /** + * int64 create_time = 3; + */ + public long getCreateTime() { + return createTime_; + } + /** + * int64 create_time = 3; + */ + public Builder setCreateTime(long value) { + + createTime_ = value; + onChanged(); + return this; + } + /** + * int64 create_time = 3; + */ + public Builder clearCreateTime() { + + createTime_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString firstTokenId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes first_token_id = 6; + */ + public com.google.protobuf.ByteString getFirstTokenId() { + return firstTokenId_; + } + /** + * bytes first_token_id = 6; + */ + public Builder setFirstTokenId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + firstTokenId_ = value; + onChanged(); + return this; + } + /** + * bytes first_token_id = 6; + */ + public Builder clearFirstTokenId() { + + firstTokenId_ = getDefaultInstance().getFirstTokenId(); + onChanged(); + return this; + } + + private long firstTokenBalance_ ; + /** + * int64 first_token_balance = 7; + */ + public long getFirstTokenBalance() { + return firstTokenBalance_; + } + /** + * int64 first_token_balance = 7; + */ + public Builder setFirstTokenBalance(long value) { + + firstTokenBalance_ = value; + onChanged(); + return this; + } + /** + * int64 first_token_balance = 7; + */ + public Builder clearFirstTokenBalance() { + + firstTokenBalance_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString secondTokenId_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes second_token_id = 8; + */ + public com.google.protobuf.ByteString getSecondTokenId() { + return secondTokenId_; + } + /** + * bytes second_token_id = 8; + */ + public Builder setSecondTokenId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + secondTokenId_ = value; + onChanged(); + return this; + } + /** + * bytes second_token_id = 8; + */ + public Builder clearSecondTokenId() { + + secondTokenId_ = getDefaultInstance().getSecondTokenId(); + onChanged(); + return this; + } + + private long secondTokenBalance_ ; + /** + * int64 second_token_balance = 9; + */ + public long getSecondTokenBalance() { + return secondTokenBalance_; + } + /** + * int64 second_token_balance = 9; + */ + public Builder setSecondTokenBalance(long value) { + + secondTokenBalance_ = value; + onChanged(); + return this; + } + /** + * int64 second_token_balance = 9; + */ + public Builder clearSecondTokenBalance() { + + secondTokenBalance_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Exchange) + } + + // @@protoc_insertion_point(class_scope:protocol.Exchange) + private static final org.tron.protos.Protocol.Exchange DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Exchange(); + } + + public static org.tron.protos.Protocol.Exchange getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Exchange parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Exchange(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Exchange getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ChainParametersOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ChainParameters) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + java.util.List + getChainParameterList(); + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + org.tron.protos.Protocol.ChainParameters.ChainParameter getChainParameter(int index); + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + int getChainParameterCount(); + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + java.util.List + getChainParameterOrBuilderList(); + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + org.tron.protos.Protocol.ChainParameters.ChainParameterOrBuilder getChainParameterOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.ChainParameters} + */ + public static final class ChainParameters extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ChainParameters) + ChainParametersOrBuilder { + private static final long serialVersionUID = 0L; + // Use ChainParameters.newBuilder() to construct. + private ChainParameters(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ChainParameters() { + chainParameter_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ChainParameters( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + chainParameter_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + chainParameter_.add( + input.readMessage(org.tron.protos.Protocol.ChainParameters.ChainParameter.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + chainParameter_ = java.util.Collections.unmodifiableList(chainParameter_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainParameters.class, org.tron.protos.Protocol.ChainParameters.Builder.class); + } + + public interface ChainParameterOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ChainParameters.ChainParameter) + com.google.protobuf.MessageOrBuilder { + + /** + * string key = 1; + */ + java.lang.String getKey(); + /** + * string key = 1; + */ + com.google.protobuf.ByteString + getKeyBytes(); + + /** + * int64 value = 2; + */ + long getValue(); + } + /** + * Protobuf type {@code protocol.ChainParameters.ChainParameter} + */ + public static final class ChainParameter extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ChainParameters.ChainParameter) + ChainParameterOrBuilder { + private static final long serialVersionUID = 0L; + // Use ChainParameter.newBuilder() to construct. + private ChainParameter(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ChainParameter() { + key_ = ""; + value_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ChainParameter( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + key_ = s; + break; + } + case 16: { + + value_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_ChainParameter_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_ChainParameter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainParameters.ChainParameter.class, org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder.class); + } + + public static final int KEY_FIELD_NUMBER = 1; + private volatile java.lang.Object key_; + /** + * string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } + } + /** + * string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUE_FIELD_NUMBER = 2; + private long value_; + /** + * int64 value = 2; + */ + public long getValue() { + return value_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getKeyBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); + } + if (value_ != 0L) { + output.writeInt64(2, value_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getKeyBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); + } + if (value_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, value_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.ChainParameters.ChainParameter)) { + return super.equals(obj); + } + org.tron.protos.Protocol.ChainParameters.ChainParameter other = (org.tron.protos.Protocol.ChainParameters.ChainParameter) obj; + + boolean result = true; + result = result && getKey() + .equals(other.getKey()); + result = result && (getValue() + == other.getValue()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getValue()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainParameters.ChainParameter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.ChainParameters.ChainParameter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ChainParameters.ChainParameter} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ChainParameters.ChainParameter) + org.tron.protos.Protocol.ChainParameters.ChainParameterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_ChainParameter_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_ChainParameter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainParameters.ChainParameter.class, org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder.class); + } + + // Construct using org.tron.protos.Protocol.ChainParameters.ChainParameter.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + key_ = ""; + + value_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_ChainParameter_descriptor; + } + + public org.tron.protos.Protocol.ChainParameters.ChainParameter getDefaultInstanceForType() { + return org.tron.protos.Protocol.ChainParameters.ChainParameter.getDefaultInstance(); + } + + public org.tron.protos.Protocol.ChainParameters.ChainParameter build() { + org.tron.protos.Protocol.ChainParameters.ChainParameter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.ChainParameters.ChainParameter buildPartial() { + org.tron.protos.Protocol.ChainParameters.ChainParameter result = new org.tron.protos.Protocol.ChainParameters.ChainParameter(this); + result.key_ = key_; + result.value_ = value_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.ChainParameters.ChainParameter) { + return mergeFrom((org.tron.protos.Protocol.ChainParameters.ChainParameter)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.ChainParameters.ChainParameter other) { + if (other == org.tron.protos.Protocol.ChainParameters.ChainParameter.getDefaultInstance()) return this; + if (!other.getKey().isEmpty()) { + key_ = other.key_; + onChanged(); + } + if (other.getValue() != 0L) { + setValue(other.getValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.ChainParameters.ChainParameter parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.ChainParameters.ChainParameter) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object key_ = ""; + /** + * string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string key = 1; + */ + public Builder setKey( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + key_ = value; + onChanged(); + return this; + } + /** + * string key = 1; + */ + public Builder clearKey() { + + key_ = getDefaultInstance().getKey(); + onChanged(); + return this; + } + /** + * string key = 1; + */ + public Builder setKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + key_ = value; + onChanged(); + return this; + } + + private long value_ ; + /** + * int64 value = 2; + */ + public long getValue() { + return value_; + } + /** + * int64 value = 2; + */ + public Builder setValue(long value) { + + value_ = value; + onChanged(); + return this; + } + /** + * int64 value = 2; + */ + public Builder clearValue() { + + value_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ChainParameters.ChainParameter) + } + + // @@protoc_insertion_point(class_scope:protocol.ChainParameters.ChainParameter) + private static final org.tron.protos.Protocol.ChainParameters.ChainParameter DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.ChainParameters.ChainParameter(); + } + + public static org.tron.protos.Protocol.ChainParameters.ChainParameter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ChainParameter parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ChainParameter(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.ChainParameters.ChainParameter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int CHAINPARAMETER_FIELD_NUMBER = 1; + private java.util.List chainParameter_; + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public java.util.List getChainParameterList() { + return chainParameter_; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public java.util.List + getChainParameterOrBuilderList() { + return chainParameter_; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public int getChainParameterCount() { + return chainParameter_.size(); + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public org.tron.protos.Protocol.ChainParameters.ChainParameter getChainParameter(int index) { + return chainParameter_.get(index); + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public org.tron.protos.Protocol.ChainParameters.ChainParameterOrBuilder getChainParameterOrBuilder( + int index) { + return chainParameter_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < chainParameter_.size(); i++) { + output.writeMessage(1, chainParameter_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < chainParameter_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, chainParameter_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.ChainParameters)) { + return super.equals(obj); + } + org.tron.protos.Protocol.ChainParameters other = (org.tron.protos.Protocol.ChainParameters) obj; + + boolean result = true; + result = result && getChainParameterList() + .equals(other.getChainParameterList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getChainParameterCount() > 0) { + hash = (37 * hash) + CHAINPARAMETER_FIELD_NUMBER; + hash = (53 * hash) + getChainParameterList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.ChainParameters parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainParameters parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainParameters parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.ChainParameters prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ChainParameters} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ChainParameters) + org.tron.protos.Protocol.ChainParametersOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainParameters.class, org.tron.protos.Protocol.ChainParameters.Builder.class); + } + + // Construct using org.tron.protos.Protocol.ChainParameters.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getChainParameterFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (chainParameterBuilder_ == null) { + chainParameter_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + chainParameterBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_ChainParameters_descriptor; + } + + public org.tron.protos.Protocol.ChainParameters getDefaultInstanceForType() { + return org.tron.protos.Protocol.ChainParameters.getDefaultInstance(); + } + + public org.tron.protos.Protocol.ChainParameters build() { + org.tron.protos.Protocol.ChainParameters result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.ChainParameters buildPartial() { + org.tron.protos.Protocol.ChainParameters result = new org.tron.protos.Protocol.ChainParameters(this); + int from_bitField0_ = bitField0_; + if (chainParameterBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + chainParameter_ = java.util.Collections.unmodifiableList(chainParameter_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.chainParameter_ = chainParameter_; + } else { + result.chainParameter_ = chainParameterBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.ChainParameters) { + return mergeFrom((org.tron.protos.Protocol.ChainParameters)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.ChainParameters other) { + if (other == org.tron.protos.Protocol.ChainParameters.getDefaultInstance()) return this; + if (chainParameterBuilder_ == null) { + if (!other.chainParameter_.isEmpty()) { + if (chainParameter_.isEmpty()) { + chainParameter_ = other.chainParameter_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureChainParameterIsMutable(); + chainParameter_.addAll(other.chainParameter_); + } + onChanged(); + } + } else { + if (!other.chainParameter_.isEmpty()) { + if (chainParameterBuilder_.isEmpty()) { + chainParameterBuilder_.dispose(); + chainParameterBuilder_ = null; + chainParameter_ = other.chainParameter_; + bitField0_ = (bitField0_ & ~0x00000001); + chainParameterBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getChainParameterFieldBuilder() : null; + } else { + chainParameterBuilder_.addAllMessages(other.chainParameter_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.ChainParameters parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.ChainParameters) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List chainParameter_ = + java.util.Collections.emptyList(); + private void ensureChainParameterIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + chainParameter_ = new java.util.ArrayList(chainParameter_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.ChainParameters.ChainParameter, org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder, org.tron.protos.Protocol.ChainParameters.ChainParameterOrBuilder> chainParameterBuilder_; + + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public java.util.List getChainParameterList() { + if (chainParameterBuilder_ == null) { + return java.util.Collections.unmodifiableList(chainParameter_); + } else { + return chainParameterBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public int getChainParameterCount() { + if (chainParameterBuilder_ == null) { + return chainParameter_.size(); + } else { + return chainParameterBuilder_.getCount(); + } + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public org.tron.protos.Protocol.ChainParameters.ChainParameter getChainParameter(int index) { + if (chainParameterBuilder_ == null) { + return chainParameter_.get(index); + } else { + return chainParameterBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder setChainParameter( + int index, org.tron.protos.Protocol.ChainParameters.ChainParameter value) { + if (chainParameterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChainParameterIsMutable(); + chainParameter_.set(index, value); + onChanged(); + } else { + chainParameterBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder setChainParameter( + int index, org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder builderForValue) { + if (chainParameterBuilder_ == null) { + ensureChainParameterIsMutable(); + chainParameter_.set(index, builderForValue.build()); + onChanged(); + } else { + chainParameterBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder addChainParameter(org.tron.protos.Protocol.ChainParameters.ChainParameter value) { + if (chainParameterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChainParameterIsMutable(); + chainParameter_.add(value); + onChanged(); + } else { + chainParameterBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder addChainParameter( + int index, org.tron.protos.Protocol.ChainParameters.ChainParameter value) { + if (chainParameterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChainParameterIsMutable(); + chainParameter_.add(index, value); + onChanged(); + } else { + chainParameterBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder addChainParameter( + org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder builderForValue) { + if (chainParameterBuilder_ == null) { + ensureChainParameterIsMutable(); + chainParameter_.add(builderForValue.build()); + onChanged(); + } else { + chainParameterBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder addChainParameter( + int index, org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder builderForValue) { + if (chainParameterBuilder_ == null) { + ensureChainParameterIsMutable(); + chainParameter_.add(index, builderForValue.build()); + onChanged(); + } else { + chainParameterBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder addAllChainParameter( + java.lang.Iterable values) { + if (chainParameterBuilder_ == null) { + ensureChainParameterIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, chainParameter_); + onChanged(); + } else { + chainParameterBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder clearChainParameter() { + if (chainParameterBuilder_ == null) { + chainParameter_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + chainParameterBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public Builder removeChainParameter(int index) { + if (chainParameterBuilder_ == null) { + ensureChainParameterIsMutable(); + chainParameter_.remove(index); + onChanged(); + } else { + chainParameterBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder getChainParameterBuilder( + int index) { + return getChainParameterFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public org.tron.protos.Protocol.ChainParameters.ChainParameterOrBuilder getChainParameterOrBuilder( + int index) { + if (chainParameterBuilder_ == null) { + return chainParameter_.get(index); } else { + return chainParameterBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public java.util.List + getChainParameterOrBuilderList() { + if (chainParameterBuilder_ != null) { + return chainParameterBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(chainParameter_); + } + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder addChainParameterBuilder() { + return getChainParameterFieldBuilder().addBuilder( + org.tron.protos.Protocol.ChainParameters.ChainParameter.getDefaultInstance()); + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder addChainParameterBuilder( + int index) { + return getChainParameterFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.ChainParameters.ChainParameter.getDefaultInstance()); + } + /** + * repeated .protocol.ChainParameters.ChainParameter chainParameter = 1; + */ + public java.util.List + getChainParameterBuilderList() { + return getChainParameterFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.ChainParameters.ChainParameter, org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder, org.tron.protos.Protocol.ChainParameters.ChainParameterOrBuilder> + getChainParameterFieldBuilder() { + if (chainParameterBuilder_ == null) { + chainParameterBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.ChainParameters.ChainParameter, org.tron.protos.Protocol.ChainParameters.ChainParameter.Builder, org.tron.protos.Protocol.ChainParameters.ChainParameterOrBuilder>( + chainParameter_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + chainParameter_ = null; + } + return chainParameterBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ChainParameters) + } + + // @@protoc_insertion_point(class_scope:protocol.ChainParameters) + private static final org.tron.protos.Protocol.ChainParameters DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.ChainParameters(); + } + + public static org.tron.protos.Protocol.ChainParameters getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ChainParameters parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ChainParameters(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.ChainParameters getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AccountOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Account) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * account nick name
+     * 
+ * + * bytes account_name = 1; + */ + com.google.protobuf.ByteString getAccountName(); + + /** + * .protocol.AccountType type = 2; + */ + int getTypeValue(); + /** + * .protocol.AccountType type = 2; + */ + org.tron.protos.Protocol.AccountType getType(); + + /** + *
+     * the create address
+     * 
+ * + * bytes address = 3; + */ + com.google.protobuf.ByteString getAddress(); + + /** + *
+     * the trx balance
+     * 
+ * + * int64 balance = 4; + */ + long getBalance(); + + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + java.util.List + getVotesList(); + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + org.tron.protos.Protocol.Vote getVotes(int index); + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + int getVotesCount(); + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + java.util.List + getVotesOrBuilderList(); + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + org.tron.protos.Protocol.VoteOrBuilder getVotesOrBuilder( + int index); + + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + int getAssetCount(); + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + boolean containsAsset( + java.lang.String key); + /** + * Use {@link #getAssetMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getAsset(); + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + java.util.Map + getAssetMap(); + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + + long getAssetOrDefault( + java.lang.String key, + long defaultValue); + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + + long getAssetOrThrow( + java.lang.String key); + + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + int getAssetV2Count(); + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + boolean containsAssetV2( + java.lang.String key); + /** + * Use {@link #getAssetV2Map()} instead. + */ + @java.lang.Deprecated + java.util.Map + getAssetV2(); + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + java.util.Map + getAssetV2Map(); + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + + long getAssetV2OrDefault( + java.lang.String key, + long defaultValue); + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + + long getAssetV2OrThrow( + java.lang.String key); + + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + java.util.List + getFrozenList(); + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + org.tron.protos.Protocol.Account.Frozen getFrozen(int index); + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + int getFrozenCount(); + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + java.util.List + getFrozenOrBuilderList(); + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenOrBuilder( + int index); + + /** + *
+     * bandwidth, get from frozen
+     * 
+ * + * int64 net_usage = 8; + */ + long getNetUsage(); + + /** + *
+     *Frozen balance provided by other accounts to this account
+     * 
+ * + * int64 acquired_delegated_frozen_balance_for_bandwidth = 41; + */ + long getAcquiredDelegatedFrozenBalanceForBandwidth(); + + /** + *
+     *Freeze and provide balances to other accounts
+     * 
+ * + * int64 delegated_frozen_balance_for_bandwidth = 42; + */ + long getDelegatedFrozenBalanceForBandwidth(); + + /** + *
+     * this account create time
+     * 
+ * + * int64 create_time = 9; + */ + long getCreateTime(); + + /** + *
+     * this last operation time, including transfer, voting and so on. //FIXME fix grammar
+     * 
+ * + * int64 latest_opration_time = 10; + */ + long getLatestOprationTime(); + + /** + *
+     * witness block producing allowance
+     * 
+ * + * int64 allowance = 11; + */ + long getAllowance(); + + /** + *
+     * last withdraw time
+     * 
+ * + * int64 latest_withdraw_time = 12; + */ + long getLatestWithdrawTime(); + + /** + *
+     * not used so far
+     * 
+ * + * bytes code = 13; + */ + com.google.protobuf.ByteString getCode(); + + /** + * bool is_witness = 14; + */ + boolean getIsWitness(); + + /** + * bool is_committee = 15; + */ + boolean getIsCommittee(); + + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + java.util.List + getFrozenSupplyList(); + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + org.tron.protos.Protocol.Account.Frozen getFrozenSupply(int index); + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + int getFrozenSupplyCount(); + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + java.util.List + getFrozenSupplyOrBuilderList(); + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenSupplyOrBuilder( + int index); + + /** + *
+     * asset_issued_name
+     * 
+ * + * bytes asset_issued_name = 17; + */ + com.google.protobuf.ByteString getAssetIssuedName(); + + /** + * bytes asset_issued_ID = 57; + */ + com.google.protobuf.ByteString getAssetIssuedID(); + + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + int getLatestAssetOperationTimeCount(); + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + boolean containsLatestAssetOperationTime( + java.lang.String key); + /** + * Use {@link #getLatestAssetOperationTimeMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getLatestAssetOperationTime(); + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + java.util.Map + getLatestAssetOperationTimeMap(); + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + long getLatestAssetOperationTimeOrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + long getLatestAssetOperationTimeOrThrow( + java.lang.String key); + + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + int getLatestAssetOperationTimeV2Count(); + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + boolean containsLatestAssetOperationTimeV2( + java.lang.String key); + /** + * Use {@link #getLatestAssetOperationTimeV2Map()} instead. + */ + @java.lang.Deprecated + java.util.Map + getLatestAssetOperationTimeV2(); + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + java.util.Map + getLatestAssetOperationTimeV2Map(); + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + long getLatestAssetOperationTimeV2OrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + long getLatestAssetOperationTimeV2OrThrow( + java.lang.String key); + + /** + * int64 free_net_usage = 19; + */ + long getFreeNetUsage(); + + /** + * map<string, int64> free_asset_net_usage = 20; + */ + int getFreeAssetNetUsageCount(); + /** + * map<string, int64> free_asset_net_usage = 20; + */ + boolean containsFreeAssetNetUsage( + java.lang.String key); + /** + * Use {@link #getFreeAssetNetUsageMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getFreeAssetNetUsage(); + /** + * map<string, int64> free_asset_net_usage = 20; + */ + java.util.Map + getFreeAssetNetUsageMap(); + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + long getFreeAssetNetUsageOrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + long getFreeAssetNetUsageOrThrow( + java.lang.String key); + + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + int getFreeAssetNetUsageV2Count(); + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + boolean containsFreeAssetNetUsageV2( + java.lang.String key); + /** + * Use {@link #getFreeAssetNetUsageV2Map()} instead. + */ + @java.lang.Deprecated + java.util.Map + getFreeAssetNetUsageV2(); + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + java.util.Map + getFreeAssetNetUsageV2Map(); + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + long getFreeAssetNetUsageV2OrDefault( + java.lang.String key, + long defaultValue); + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + long getFreeAssetNetUsageV2OrThrow( + java.lang.String key); + + /** + * int64 latest_consume_time = 21; + */ + long getLatestConsumeTime(); + + /** + * int64 latest_consume_free_time = 22; + */ + long getLatestConsumeFreeTime(); + + /** + *
+     * the identity of this account, case insensitive
+     * 
+ * + * bytes account_id = 23; + */ + com.google.protobuf.ByteString getAccountId(); + + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + boolean hasAccountResource(); + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + org.tron.protos.Protocol.Account.AccountResource getAccountResource(); + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + org.tron.protos.Protocol.Account.AccountResourceOrBuilder getAccountResourceOrBuilder(); + + /** + * bytes codeHash = 30; + */ + com.google.protobuf.ByteString getCodeHash(); + + /** + * .protocol.Permission owner_permission = 31; + */ + boolean hasOwnerPermission(); + /** + * .protocol.Permission owner_permission = 31; + */ + org.tron.protos.Protocol.Permission getOwnerPermission(); + /** + * .protocol.Permission owner_permission = 31; + */ + org.tron.protos.Protocol.PermissionOrBuilder getOwnerPermissionOrBuilder(); + + /** + * .protocol.Permission witness_permission = 32; + */ + boolean hasWitnessPermission(); + /** + * .protocol.Permission witness_permission = 32; + */ + org.tron.protos.Protocol.Permission getWitnessPermission(); + /** + * .protocol.Permission witness_permission = 32; + */ + org.tron.protos.Protocol.PermissionOrBuilder getWitnessPermissionOrBuilder(); + + /** + * repeated .protocol.Permission active_permission = 33; + */ + java.util.List + getActivePermissionList(); + /** + * repeated .protocol.Permission active_permission = 33; + */ + org.tron.protos.Protocol.Permission getActivePermission(int index); + /** + * repeated .protocol.Permission active_permission = 33; + */ + int getActivePermissionCount(); + /** + * repeated .protocol.Permission active_permission = 33; + */ + java.util.List + getActivePermissionOrBuilderList(); + /** + * repeated .protocol.Permission active_permission = 33; + */ + org.tron.protos.Protocol.PermissionOrBuilder getActivePermissionOrBuilder( + int index); + } + /** + *
+   * Account 
+   * 
+ * + * Protobuf type {@code protocol.Account} + */ + public static final class Account extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Account) + AccountOrBuilder { + private static final long serialVersionUID = 0L; + // Use Account.newBuilder() to construct. + private Account(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Account() { + accountName_ = com.google.protobuf.ByteString.EMPTY; + type_ = 0; + address_ = com.google.protobuf.ByteString.EMPTY; + balance_ = 0L; + votes_ = java.util.Collections.emptyList(); + frozen_ = java.util.Collections.emptyList(); + netUsage_ = 0L; + acquiredDelegatedFrozenBalanceForBandwidth_ = 0L; + delegatedFrozenBalanceForBandwidth_ = 0L; + createTime_ = 0L; + latestOprationTime_ = 0L; + allowance_ = 0L; + latestWithdrawTime_ = 0L; + code_ = com.google.protobuf.ByteString.EMPTY; + isWitness_ = false; + isCommittee_ = false; + frozenSupply_ = java.util.Collections.emptyList(); + assetIssuedName_ = com.google.protobuf.ByteString.EMPTY; + assetIssuedID_ = com.google.protobuf.ByteString.EMPTY; + freeNetUsage_ = 0L; + latestConsumeTime_ = 0L; + latestConsumeFreeTime_ = 0L; + accountId_ = com.google.protobuf.ByteString.EMPTY; + codeHash_ = com.google.protobuf.ByteString.EMPTY; + activePermission_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Account( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + int mutable_bitField1_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + accountName_ = input.readBytes(); + break; + } + case 16: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 26: { + + address_ = input.readBytes(); + break; + } + case 32: { + + balance_ = input.readInt64(); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + votes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + votes_.add( + input.readMessage(org.tron.protos.Protocol.Vote.parser(), extensionRegistry)); + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + asset_ = com.google.protobuf.MapField.newMapField( + AssetDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000020; + } + com.google.protobuf.MapEntry + asset__ = input.readMessage( + AssetDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + asset_.getMutableMap().put( + asset__.getKey(), asset__.getValue()); + break; + } + case 58: { + if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + frozen_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000080; + } + frozen_.add( + input.readMessage(org.tron.protos.Protocol.Account.Frozen.parser(), extensionRegistry)); + break; + } + case 64: { + + netUsage_ = input.readInt64(); + break; + } + case 72: { + + createTime_ = input.readInt64(); + break; + } + case 80: { + + latestOprationTime_ = input.readInt64(); + break; + } + case 88: { + + allowance_ = input.readInt64(); + break; + } + case 96: { + + latestWithdrawTime_ = input.readInt64(); + break; + } + case 106: { + + code_ = input.readBytes(); + break; + } + case 112: { + + isWitness_ = input.readBool(); + break; + } + case 120: { + + isCommittee_ = input.readBool(); + break; + } + case 130: { + if (!((mutable_bitField0_ & 0x00040000) == 0x00040000)) { + frozenSupply_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00040000; + } + frozenSupply_.add( + input.readMessage(org.tron.protos.Protocol.Account.Frozen.parser(), extensionRegistry)); + break; + } + case 138: { + + assetIssuedName_ = input.readBytes(); + break; + } + case 146: { + if (!((mutable_bitField0_ & 0x00200000) == 0x00200000)) { + latestAssetOperationTime_ = com.google.protobuf.MapField.newMapField( + LatestAssetOperationTimeDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00200000; + } + com.google.protobuf.MapEntry + latestAssetOperationTime__ = input.readMessage( + LatestAssetOperationTimeDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + latestAssetOperationTime_.getMutableMap().put( + latestAssetOperationTime__.getKey(), latestAssetOperationTime__.getValue()); + break; + } + case 152: { + + freeNetUsage_ = input.readInt64(); + break; + } + case 162: { + if (!((mutable_bitField0_ & 0x01000000) == 0x01000000)) { + freeAssetNetUsage_ = com.google.protobuf.MapField.newMapField( + FreeAssetNetUsageDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x01000000; + } + com.google.protobuf.MapEntry + freeAssetNetUsage__ = input.readMessage( + FreeAssetNetUsageDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + freeAssetNetUsage_.getMutableMap().put( + freeAssetNetUsage__.getKey(), freeAssetNetUsage__.getValue()); + break; + } + case 168: { + + latestConsumeTime_ = input.readInt64(); + break; + } + case 176: { + + latestConsumeFreeTime_ = input.readInt64(); + break; + } + case 186: { + + accountId_ = input.readBytes(); + break; + } + case 210: { + org.tron.protos.Protocol.Account.AccountResource.Builder subBuilder = null; + if (accountResource_ != null) { + subBuilder = accountResource_.toBuilder(); + } + accountResource_ = input.readMessage(org.tron.protos.Protocol.Account.AccountResource.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(accountResource_); + accountResource_ = subBuilder.buildPartial(); + } + + break; + } + case 242: { + + codeHash_ = input.readBytes(); + break; + } + case 250: { + org.tron.protos.Protocol.Permission.Builder subBuilder = null; + if (ownerPermission_ != null) { + subBuilder = ownerPermission_.toBuilder(); + } + ownerPermission_ = input.readMessage(org.tron.protos.Protocol.Permission.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(ownerPermission_); + ownerPermission_ = subBuilder.buildPartial(); + } + + break; + } + case 258: { + org.tron.protos.Protocol.Permission.Builder subBuilder = null; + if (witnessPermission_ != null) { + subBuilder = witnessPermission_.toBuilder(); + } + witnessPermission_ = input.readMessage(org.tron.protos.Protocol.Permission.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(witnessPermission_); + witnessPermission_ = subBuilder.buildPartial(); + } + + break; + } + case 266: { + if (!((mutable_bitField1_ & 0x00000002) == 0x00000002)) { + activePermission_ = new java.util.ArrayList(); + mutable_bitField1_ |= 0x00000002; + } + activePermission_.add( + input.readMessage(org.tron.protos.Protocol.Permission.parser(), extensionRegistry)); + break; + } + case 328: { + + acquiredDelegatedFrozenBalanceForBandwidth_ = input.readInt64(); + break; + } + case 336: { + + delegatedFrozenBalanceForBandwidth_ = input.readInt64(); + break; + } + case 450: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + assetV2_ = com.google.protobuf.MapField.newMapField( + AssetV2DefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000040; + } + com.google.protobuf.MapEntry + assetV2__ = input.readMessage( + AssetV2DefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + assetV2_.getMutableMap().put( + assetV2__.getKey(), assetV2__.getValue()); + break; + } + case 458: { + + assetIssuedID_ = input.readBytes(); + break; + } + case 466: { + if (!((mutable_bitField0_ & 0x00400000) == 0x00400000)) { + latestAssetOperationTimeV2_ = com.google.protobuf.MapField.newMapField( + LatestAssetOperationTimeV2DefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00400000; + } + com.google.protobuf.MapEntry + latestAssetOperationTimeV2__ = input.readMessage( + LatestAssetOperationTimeV2DefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + latestAssetOperationTimeV2_.getMutableMap().put( + latestAssetOperationTimeV2__.getKey(), latestAssetOperationTimeV2__.getValue()); + break; + } + case 474: { + if (!((mutable_bitField0_ & 0x02000000) == 0x02000000)) { + freeAssetNetUsageV2_ = com.google.protobuf.MapField.newMapField( + FreeAssetNetUsageV2DefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x02000000; + } + com.google.protobuf.MapEntry + freeAssetNetUsageV2__ = input.readMessage( + FreeAssetNetUsageV2DefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + freeAssetNetUsageV2_.getMutableMap().put( + freeAssetNetUsageV2__.getKey(), freeAssetNetUsageV2__.getValue()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + votes_ = java.util.Collections.unmodifiableList(votes_); + } + if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + frozen_ = java.util.Collections.unmodifiableList(frozen_); + } + if (((mutable_bitField0_ & 0x00040000) == 0x00040000)) { + frozenSupply_ = java.util.Collections.unmodifiableList(frozenSupply_); + } + if (((mutable_bitField1_ & 0x00000002) == 0x00000002)) { + activePermission_ = java.util.Collections.unmodifiableList(activePermission_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Account_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 6: + return internalGetAsset(); + case 56: + return internalGetAssetV2(); + case 18: + return internalGetLatestAssetOperationTime(); + case 58: + return internalGetLatestAssetOperationTimeV2(); + case 20: + return internalGetFreeAssetNetUsage(); + case 59: + return internalGetFreeAssetNetUsageV2(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Account_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Account.class, org.tron.protos.Protocol.Account.Builder.class); + } + + public interface FrozenOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Account.Frozen) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * the frozen trx balance
+       * 
+ * + * int64 frozen_balance = 1; + */ + long getFrozenBalance(); + + /** + *
+       * the expire time
+       * 
+ * + * int64 expire_time = 2; + */ + long getExpireTime(); + } + /** + *
+     * frozen balance 
+     * 
+ * + * Protobuf type {@code protocol.Account.Frozen} + */ + public static final class Frozen extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Account.Frozen) + FrozenOrBuilder { + private static final long serialVersionUID = 0L; + // Use Frozen.newBuilder() to construct. + private Frozen(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Frozen() { + frozenBalance_ = 0L; + expireTime_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Frozen( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + frozenBalance_ = input.readInt64(); + break; + } + case 16: { + + expireTime_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Account_Frozen_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Account_Frozen_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Account.Frozen.class, org.tron.protos.Protocol.Account.Frozen.Builder.class); + } + + public static final int FROZEN_BALANCE_FIELD_NUMBER = 1; + private long frozenBalance_; + /** + *
+       * the frozen trx balance
+       * 
+ * + * int64 frozen_balance = 1; + */ + public long getFrozenBalance() { + return frozenBalance_; + } + + public static final int EXPIRE_TIME_FIELD_NUMBER = 2; + private long expireTime_; + /** + *
+       * the expire time
+       * 
+ * + * int64 expire_time = 2; + */ + public long getExpireTime() { + return expireTime_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (frozenBalance_ != 0L) { + output.writeInt64(1, frozenBalance_); + } + if (expireTime_ != 0L) { + output.writeInt64(2, expireTime_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (frozenBalance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, frozenBalance_); + } + if (expireTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, expireTime_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Account.Frozen)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Account.Frozen other = (org.tron.protos.Protocol.Account.Frozen) obj; + + boolean result = true; + result = result && (getFrozenBalance() + == other.getFrozenBalance()); + result = result && (getExpireTime() + == other.getExpireTime()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FROZEN_BALANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFrozenBalance()); + hash = (37 * hash) + EXPIRE_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExpireTime()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.Frozen parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account.Frozen parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account.Frozen parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Account.Frozen prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+       * frozen balance 
+       * 
+ * + * Protobuf type {@code protocol.Account.Frozen} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Account.Frozen) + org.tron.protos.Protocol.Account.FrozenOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Account_Frozen_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Account_Frozen_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Account.Frozen.class, org.tron.protos.Protocol.Account.Frozen.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Account.Frozen.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + frozenBalance_ = 0L; + + expireTime_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Account_Frozen_descriptor; + } + + public org.tron.protos.Protocol.Account.Frozen getDefaultInstanceForType() { + return org.tron.protos.Protocol.Account.Frozen.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Account.Frozen build() { + org.tron.protos.Protocol.Account.Frozen result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Account.Frozen buildPartial() { + org.tron.protos.Protocol.Account.Frozen result = new org.tron.protos.Protocol.Account.Frozen(this); + result.frozenBalance_ = frozenBalance_; + result.expireTime_ = expireTime_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Account.Frozen) { + return mergeFrom((org.tron.protos.Protocol.Account.Frozen)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Account.Frozen other) { + if (other == org.tron.protos.Protocol.Account.Frozen.getDefaultInstance()) return this; + if (other.getFrozenBalance() != 0L) { + setFrozenBalance(other.getFrozenBalance()); + } + if (other.getExpireTime() != 0L) { + setExpireTime(other.getExpireTime()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Account.Frozen parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Account.Frozen) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long frozenBalance_ ; + /** + *
+         * the frozen trx balance
+         * 
+ * + * int64 frozen_balance = 1; + */ + public long getFrozenBalance() { + return frozenBalance_; + } + /** + *
+         * the frozen trx balance
+         * 
+ * + * int64 frozen_balance = 1; + */ + public Builder setFrozenBalance(long value) { + + frozenBalance_ = value; + onChanged(); + return this; + } + /** + *
+         * the frozen trx balance
+         * 
+ * + * int64 frozen_balance = 1; + */ + public Builder clearFrozenBalance() { + + frozenBalance_ = 0L; + onChanged(); + return this; + } + + private long expireTime_ ; + /** + *
+         * the expire time
+         * 
+ * + * int64 expire_time = 2; + */ + public long getExpireTime() { + return expireTime_; + } + /** + *
+         * the expire time
+         * 
+ * + * int64 expire_time = 2; + */ + public Builder setExpireTime(long value) { + + expireTime_ = value; + onChanged(); + return this; + } + /** + *
+         * the expire time
+         * 
+ * + * int64 expire_time = 2; + */ + public Builder clearExpireTime() { + + expireTime_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Account.Frozen) + } + + // @@protoc_insertion_point(class_scope:protocol.Account.Frozen) + private static final org.tron.protos.Protocol.Account.Frozen DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Account.Frozen(); + } + + public static org.tron.protos.Protocol.Account.Frozen getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Frozen parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Frozen(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Account.Frozen getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface AccountResourceOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Account.AccountResource) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * energy resource, get from frozen
+       * 
+ * + * int64 energy_usage = 1; + */ + long getEnergyUsage(); + + /** + *
+       * the frozen balance for energy
+       * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + boolean hasFrozenBalanceForEnergy(); + /** + *
+       * the frozen balance for energy
+       * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + org.tron.protos.Protocol.Account.Frozen getFrozenBalanceForEnergy(); + /** + *
+       * the frozen balance for energy
+       * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenBalanceForEnergyOrBuilder(); + + /** + * int64 latest_consume_time_for_energy = 3; + */ + long getLatestConsumeTimeForEnergy(); + + /** + *
+       *Frozen balance provided by other accounts to this account
+       * 
+ * + * int64 acquired_delegated_frozen_balance_for_energy = 4; + */ + long getAcquiredDelegatedFrozenBalanceForEnergy(); + + /** + *
+       *Frozen balances provided to other accounts
+       * 
+ * + * int64 delegated_frozen_balance_for_energy = 5; + */ + long getDelegatedFrozenBalanceForEnergy(); + + /** + *
+       * storage resource, get from market
+       * 
+ * + * int64 storage_limit = 6; + */ + long getStorageLimit(); + + /** + * int64 storage_usage = 7; + */ + long getStorageUsage(); + + /** + * int64 latest_exchange_storage_time = 8; + */ + long getLatestExchangeStorageTime(); + } + /** + * Protobuf type {@code protocol.Account.AccountResource} + */ + public static final class AccountResource extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Account.AccountResource) + AccountResourceOrBuilder { + private static final long serialVersionUID = 0L; + // Use AccountResource.newBuilder() to construct. + private AccountResource(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AccountResource() { + energyUsage_ = 0L; + latestConsumeTimeForEnergy_ = 0L; + acquiredDelegatedFrozenBalanceForEnergy_ = 0L; + delegatedFrozenBalanceForEnergy_ = 0L; + storageLimit_ = 0L; + storageUsage_ = 0L; + latestExchangeStorageTime_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AccountResource( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + energyUsage_ = input.readInt64(); + break; + } + case 18: { + org.tron.protos.Protocol.Account.Frozen.Builder subBuilder = null; + if (frozenBalanceForEnergy_ != null) { + subBuilder = frozenBalanceForEnergy_.toBuilder(); + } + frozenBalanceForEnergy_ = input.readMessage(org.tron.protos.Protocol.Account.Frozen.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(frozenBalanceForEnergy_); + frozenBalanceForEnergy_ = subBuilder.buildPartial(); + } + + break; + } + case 24: { + + latestConsumeTimeForEnergy_ = input.readInt64(); + break; + } + case 32: { + + acquiredDelegatedFrozenBalanceForEnergy_ = input.readInt64(); + break; + } + case 40: { + + delegatedFrozenBalanceForEnergy_ = input.readInt64(); + break; + } + case 48: { + + storageLimit_ = input.readInt64(); + break; + } + case 56: { + + storageUsage_ = input.readInt64(); + break; + } + case 64: { + + latestExchangeStorageTime_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Account_AccountResource_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Account_AccountResource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Account.AccountResource.class, org.tron.protos.Protocol.Account.AccountResource.Builder.class); + } + + public static final int ENERGY_USAGE_FIELD_NUMBER = 1; + private long energyUsage_; + /** + *
+       * energy resource, get from frozen
+       * 
+ * + * int64 energy_usage = 1; + */ + public long getEnergyUsage() { + return energyUsage_; + } + + public static final int FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER = 2; + private org.tron.protos.Protocol.Account.Frozen frozenBalanceForEnergy_; + /** + *
+       * the frozen balance for energy
+       * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public boolean hasFrozenBalanceForEnergy() { + return frozenBalanceForEnergy_ != null; + } + /** + *
+       * the frozen balance for energy
+       * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public org.tron.protos.Protocol.Account.Frozen getFrozenBalanceForEnergy() { + return frozenBalanceForEnergy_ == null ? org.tron.protos.Protocol.Account.Frozen.getDefaultInstance() : frozenBalanceForEnergy_; + } + /** + *
+       * the frozen balance for energy
+       * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenBalanceForEnergyOrBuilder() { + return getFrozenBalanceForEnergy(); + } + + public static final int LATEST_CONSUME_TIME_FOR_ENERGY_FIELD_NUMBER = 3; + private long latestConsumeTimeForEnergy_; + /** + * int64 latest_consume_time_for_energy = 3; + */ + public long getLatestConsumeTimeForEnergy() { + return latestConsumeTimeForEnergy_; + } + + public static final int ACQUIRED_DELEGATED_FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER = 4; + private long acquiredDelegatedFrozenBalanceForEnergy_; + /** + *
+       *Frozen balance provided by other accounts to this account
+       * 
+ * + * int64 acquired_delegated_frozen_balance_for_energy = 4; + */ + public long getAcquiredDelegatedFrozenBalanceForEnergy() { + return acquiredDelegatedFrozenBalanceForEnergy_; + } + + public static final int DELEGATED_FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER = 5; + private long delegatedFrozenBalanceForEnergy_; + /** + *
+       *Frozen balances provided to other accounts
+       * 
+ * + * int64 delegated_frozen_balance_for_energy = 5; + */ + public long getDelegatedFrozenBalanceForEnergy() { + return delegatedFrozenBalanceForEnergy_; + } + + public static final int STORAGE_LIMIT_FIELD_NUMBER = 6; + private long storageLimit_; + /** + *
+       * storage resource, get from market
+       * 
+ * + * int64 storage_limit = 6; + */ + public long getStorageLimit() { + return storageLimit_; + } + + public static final int STORAGE_USAGE_FIELD_NUMBER = 7; + private long storageUsage_; + /** + * int64 storage_usage = 7; + */ + public long getStorageUsage() { + return storageUsage_; + } + + public static final int LATEST_EXCHANGE_STORAGE_TIME_FIELD_NUMBER = 8; + private long latestExchangeStorageTime_; + /** + * int64 latest_exchange_storage_time = 8; + */ + public long getLatestExchangeStorageTime() { + return latestExchangeStorageTime_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (energyUsage_ != 0L) { + output.writeInt64(1, energyUsage_); + } + if (frozenBalanceForEnergy_ != null) { + output.writeMessage(2, getFrozenBalanceForEnergy()); + } + if (latestConsumeTimeForEnergy_ != 0L) { + output.writeInt64(3, latestConsumeTimeForEnergy_); + } + if (acquiredDelegatedFrozenBalanceForEnergy_ != 0L) { + output.writeInt64(4, acquiredDelegatedFrozenBalanceForEnergy_); + } + if (delegatedFrozenBalanceForEnergy_ != 0L) { + output.writeInt64(5, delegatedFrozenBalanceForEnergy_); + } + if (storageLimit_ != 0L) { + output.writeInt64(6, storageLimit_); + } + if (storageUsage_ != 0L) { + output.writeInt64(7, storageUsage_); + } + if (latestExchangeStorageTime_ != 0L) { + output.writeInt64(8, latestExchangeStorageTime_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (energyUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, energyUsage_); + } + if (frozenBalanceForEnergy_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getFrozenBalanceForEnergy()); + } + if (latestConsumeTimeForEnergy_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, latestConsumeTimeForEnergy_); + } + if (acquiredDelegatedFrozenBalanceForEnergy_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, acquiredDelegatedFrozenBalanceForEnergy_); + } + if (delegatedFrozenBalanceForEnergy_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, delegatedFrozenBalanceForEnergy_); + } + if (storageLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, storageLimit_); + } + if (storageUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, storageUsage_); + } + if (latestExchangeStorageTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, latestExchangeStorageTime_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Account.AccountResource)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Account.AccountResource other = (org.tron.protos.Protocol.Account.AccountResource) obj; + + boolean result = true; + result = result && (getEnergyUsage() + == other.getEnergyUsage()); + result = result && (hasFrozenBalanceForEnergy() == other.hasFrozenBalanceForEnergy()); + if (hasFrozenBalanceForEnergy()) { + result = result && getFrozenBalanceForEnergy() + .equals(other.getFrozenBalanceForEnergy()); + } + result = result && (getLatestConsumeTimeForEnergy() + == other.getLatestConsumeTimeForEnergy()); + result = result && (getAcquiredDelegatedFrozenBalanceForEnergy() + == other.getAcquiredDelegatedFrozenBalanceForEnergy()); + result = result && (getDelegatedFrozenBalanceForEnergy() + == other.getDelegatedFrozenBalanceForEnergy()); + result = result && (getStorageLimit() + == other.getStorageLimit()); + result = result && (getStorageUsage() + == other.getStorageUsage()); + result = result && (getLatestExchangeStorageTime() + == other.getLatestExchangeStorageTime()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENERGY_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEnergyUsage()); + if (hasFrozenBalanceForEnergy()) { + hash = (37 * hash) + FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER; + hash = (53 * hash) + getFrozenBalanceForEnergy().hashCode(); + } + hash = (37 * hash) + LATEST_CONSUME_TIME_FOR_ENERGY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestConsumeTimeForEnergy()); + hash = (37 * hash) + ACQUIRED_DELEGATED_FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAcquiredDelegatedFrozenBalanceForEnergy()); + hash = (37 * hash) + DELEGATED_FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getDelegatedFrozenBalanceForEnergy()); + hash = (37 * hash) + STORAGE_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getStorageLimit()); + hash = (37 * hash) + STORAGE_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getStorageUsage()); + hash = (37 * hash) + LATEST_EXCHANGE_STORAGE_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestExchangeStorageTime()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.AccountResource parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account.AccountResource parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account.AccountResource parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Account.AccountResource prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Account.AccountResource} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Account.AccountResource) + org.tron.protos.Protocol.Account.AccountResourceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Account_AccountResource_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Account_AccountResource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Account.AccountResource.class, org.tron.protos.Protocol.Account.AccountResource.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Account.AccountResource.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + energyUsage_ = 0L; + + if (frozenBalanceForEnergyBuilder_ == null) { + frozenBalanceForEnergy_ = null; + } else { + frozenBalanceForEnergy_ = null; + frozenBalanceForEnergyBuilder_ = null; + } + latestConsumeTimeForEnergy_ = 0L; + + acquiredDelegatedFrozenBalanceForEnergy_ = 0L; + + delegatedFrozenBalanceForEnergy_ = 0L; + + storageLimit_ = 0L; + + storageUsage_ = 0L; + + latestExchangeStorageTime_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Account_AccountResource_descriptor; + } + + public org.tron.protos.Protocol.Account.AccountResource getDefaultInstanceForType() { + return org.tron.protos.Protocol.Account.AccountResource.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Account.AccountResource build() { + org.tron.protos.Protocol.Account.AccountResource result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Account.AccountResource buildPartial() { + org.tron.protos.Protocol.Account.AccountResource result = new org.tron.protos.Protocol.Account.AccountResource(this); + result.energyUsage_ = energyUsage_; + if (frozenBalanceForEnergyBuilder_ == null) { + result.frozenBalanceForEnergy_ = frozenBalanceForEnergy_; + } else { + result.frozenBalanceForEnergy_ = frozenBalanceForEnergyBuilder_.build(); + } + result.latestConsumeTimeForEnergy_ = latestConsumeTimeForEnergy_; + result.acquiredDelegatedFrozenBalanceForEnergy_ = acquiredDelegatedFrozenBalanceForEnergy_; + result.delegatedFrozenBalanceForEnergy_ = delegatedFrozenBalanceForEnergy_; + result.storageLimit_ = storageLimit_; + result.storageUsage_ = storageUsage_; + result.latestExchangeStorageTime_ = latestExchangeStorageTime_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Account.AccountResource) { + return mergeFrom((org.tron.protos.Protocol.Account.AccountResource)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Account.AccountResource other) { + if (other == org.tron.protos.Protocol.Account.AccountResource.getDefaultInstance()) return this; + if (other.getEnergyUsage() != 0L) { + setEnergyUsage(other.getEnergyUsage()); + } + if (other.hasFrozenBalanceForEnergy()) { + mergeFrozenBalanceForEnergy(other.getFrozenBalanceForEnergy()); + } + if (other.getLatestConsumeTimeForEnergy() != 0L) { + setLatestConsumeTimeForEnergy(other.getLatestConsumeTimeForEnergy()); + } + if (other.getAcquiredDelegatedFrozenBalanceForEnergy() != 0L) { + setAcquiredDelegatedFrozenBalanceForEnergy(other.getAcquiredDelegatedFrozenBalanceForEnergy()); + } + if (other.getDelegatedFrozenBalanceForEnergy() != 0L) { + setDelegatedFrozenBalanceForEnergy(other.getDelegatedFrozenBalanceForEnergy()); + } + if (other.getStorageLimit() != 0L) { + setStorageLimit(other.getStorageLimit()); + } + if (other.getStorageUsage() != 0L) { + setStorageUsage(other.getStorageUsage()); + } + if (other.getLatestExchangeStorageTime() != 0L) { + setLatestExchangeStorageTime(other.getLatestExchangeStorageTime()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Account.AccountResource parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Account.AccountResource) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long energyUsage_ ; + /** + *
+         * energy resource, get from frozen
+         * 
+ * + * int64 energy_usage = 1; + */ + public long getEnergyUsage() { + return energyUsage_; + } + /** + *
+         * energy resource, get from frozen
+         * 
+ * + * int64 energy_usage = 1; + */ + public Builder setEnergyUsage(long value) { + + energyUsage_ = value; + onChanged(); + return this; + } + /** + *
+         * energy resource, get from frozen
+         * 
+ * + * int64 energy_usage = 1; + */ + public Builder clearEnergyUsage() { + + energyUsage_ = 0L; + onChanged(); + return this; + } + + private org.tron.protos.Protocol.Account.Frozen frozenBalanceForEnergy_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder> frozenBalanceForEnergyBuilder_; + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public boolean hasFrozenBalanceForEnergy() { + return frozenBalanceForEnergyBuilder_ != null || frozenBalanceForEnergy_ != null; + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public org.tron.protos.Protocol.Account.Frozen getFrozenBalanceForEnergy() { + if (frozenBalanceForEnergyBuilder_ == null) { + return frozenBalanceForEnergy_ == null ? org.tron.protos.Protocol.Account.Frozen.getDefaultInstance() : frozenBalanceForEnergy_; + } else { + return frozenBalanceForEnergyBuilder_.getMessage(); + } + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public Builder setFrozenBalanceForEnergy(org.tron.protos.Protocol.Account.Frozen value) { + if (frozenBalanceForEnergyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + frozenBalanceForEnergy_ = value; + onChanged(); + } else { + frozenBalanceForEnergyBuilder_.setMessage(value); + } + + return this; + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public Builder setFrozenBalanceForEnergy( + org.tron.protos.Protocol.Account.Frozen.Builder builderForValue) { + if (frozenBalanceForEnergyBuilder_ == null) { + frozenBalanceForEnergy_ = builderForValue.build(); + onChanged(); + } else { + frozenBalanceForEnergyBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public Builder mergeFrozenBalanceForEnergy(org.tron.protos.Protocol.Account.Frozen value) { + if (frozenBalanceForEnergyBuilder_ == null) { + if (frozenBalanceForEnergy_ != null) { + frozenBalanceForEnergy_ = + org.tron.protos.Protocol.Account.Frozen.newBuilder(frozenBalanceForEnergy_).mergeFrom(value).buildPartial(); + } else { + frozenBalanceForEnergy_ = value; + } + onChanged(); + } else { + frozenBalanceForEnergyBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public Builder clearFrozenBalanceForEnergy() { + if (frozenBalanceForEnergyBuilder_ == null) { + frozenBalanceForEnergy_ = null; + onChanged(); + } else { + frozenBalanceForEnergy_ = null; + frozenBalanceForEnergyBuilder_ = null; + } + + return this; + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public org.tron.protos.Protocol.Account.Frozen.Builder getFrozenBalanceForEnergyBuilder() { + + onChanged(); + return getFrozenBalanceForEnergyFieldBuilder().getBuilder(); + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + public org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenBalanceForEnergyOrBuilder() { + if (frozenBalanceForEnergyBuilder_ != null) { + return frozenBalanceForEnergyBuilder_.getMessageOrBuilder(); + } else { + return frozenBalanceForEnergy_ == null ? + org.tron.protos.Protocol.Account.Frozen.getDefaultInstance() : frozenBalanceForEnergy_; + } + } + /** + *
+         * the frozen balance for energy
+         * 
+ * + * .protocol.Account.Frozen frozen_balance_for_energy = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder> + getFrozenBalanceForEnergyFieldBuilder() { + if (frozenBalanceForEnergyBuilder_ == null) { + frozenBalanceForEnergyBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder>( + getFrozenBalanceForEnergy(), + getParentForChildren(), + isClean()); + frozenBalanceForEnergy_ = null; + } + return frozenBalanceForEnergyBuilder_; + } + + private long latestConsumeTimeForEnergy_ ; + /** + * int64 latest_consume_time_for_energy = 3; + */ + public long getLatestConsumeTimeForEnergy() { + return latestConsumeTimeForEnergy_; + } + /** + * int64 latest_consume_time_for_energy = 3; + */ + public Builder setLatestConsumeTimeForEnergy(long value) { + + latestConsumeTimeForEnergy_ = value; + onChanged(); + return this; + } + /** + * int64 latest_consume_time_for_energy = 3; + */ + public Builder clearLatestConsumeTimeForEnergy() { + + latestConsumeTimeForEnergy_ = 0L; + onChanged(); + return this; + } + + private long acquiredDelegatedFrozenBalanceForEnergy_ ; + /** + *
+         *Frozen balance provided by other accounts to this account
+         * 
+ * + * int64 acquired_delegated_frozen_balance_for_energy = 4; + */ + public long getAcquiredDelegatedFrozenBalanceForEnergy() { + return acquiredDelegatedFrozenBalanceForEnergy_; + } + /** + *
+         *Frozen balance provided by other accounts to this account
+         * 
+ * + * int64 acquired_delegated_frozen_balance_for_energy = 4; + */ + public Builder setAcquiredDelegatedFrozenBalanceForEnergy(long value) { + + acquiredDelegatedFrozenBalanceForEnergy_ = value; + onChanged(); + return this; + } + /** + *
+         *Frozen balance provided by other accounts to this account
+         * 
+ * + * int64 acquired_delegated_frozen_balance_for_energy = 4; + */ + public Builder clearAcquiredDelegatedFrozenBalanceForEnergy() { + + acquiredDelegatedFrozenBalanceForEnergy_ = 0L; + onChanged(); + return this; + } + + private long delegatedFrozenBalanceForEnergy_ ; + /** + *
+         *Frozen balances provided to other accounts
+         * 
+ * + * int64 delegated_frozen_balance_for_energy = 5; + */ + public long getDelegatedFrozenBalanceForEnergy() { + return delegatedFrozenBalanceForEnergy_; + } + /** + *
+         *Frozen balances provided to other accounts
+         * 
+ * + * int64 delegated_frozen_balance_for_energy = 5; + */ + public Builder setDelegatedFrozenBalanceForEnergy(long value) { + + delegatedFrozenBalanceForEnergy_ = value; + onChanged(); + return this; + } + /** + *
+         *Frozen balances provided to other accounts
+         * 
+ * + * int64 delegated_frozen_balance_for_energy = 5; + */ + public Builder clearDelegatedFrozenBalanceForEnergy() { + + delegatedFrozenBalanceForEnergy_ = 0L; + onChanged(); + return this; + } + + private long storageLimit_ ; + /** + *
+         * storage resource, get from market
+         * 
+ * + * int64 storage_limit = 6; + */ + public long getStorageLimit() { + return storageLimit_; + } + /** + *
+         * storage resource, get from market
+         * 
+ * + * int64 storage_limit = 6; + */ + public Builder setStorageLimit(long value) { + + storageLimit_ = value; + onChanged(); + return this; + } + /** + *
+         * storage resource, get from market
+         * 
+ * + * int64 storage_limit = 6; + */ + public Builder clearStorageLimit() { + + storageLimit_ = 0L; + onChanged(); + return this; + } + + private long storageUsage_ ; + /** + * int64 storage_usage = 7; + */ + public long getStorageUsage() { + return storageUsage_; + } + /** + * int64 storage_usage = 7; + */ + public Builder setStorageUsage(long value) { + + storageUsage_ = value; + onChanged(); + return this; + } + /** + * int64 storage_usage = 7; + */ + public Builder clearStorageUsage() { + + storageUsage_ = 0L; + onChanged(); + return this; + } + + private long latestExchangeStorageTime_ ; + /** + * int64 latest_exchange_storage_time = 8; + */ + public long getLatestExchangeStorageTime() { + return latestExchangeStorageTime_; + } + /** + * int64 latest_exchange_storage_time = 8; + */ + public Builder setLatestExchangeStorageTime(long value) { + + latestExchangeStorageTime_ = value; + onChanged(); + return this; + } + /** + * int64 latest_exchange_storage_time = 8; + */ + public Builder clearLatestExchangeStorageTime() { + + latestExchangeStorageTime_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Account.AccountResource) + } + + // @@protoc_insertion_point(class_scope:protocol.Account.AccountResource) + private static final org.tron.protos.Protocol.Account.AccountResource DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Account.AccountResource(); + } + + public static org.tron.protos.Protocol.Account.AccountResource getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AccountResource parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AccountResource(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Account.AccountResource getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int ACCOUNT_NAME_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString accountName_; + /** + *
+     * account nick name
+     * 
+ * + * bytes account_name = 1; + */ + public com.google.protobuf.ByteString getAccountName() { + return accountName_; + } + + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + /** + * .protocol.AccountType type = 2; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.AccountType type = 2; + */ + public org.tron.protos.Protocol.AccountType getType() { + org.tron.protos.Protocol.AccountType result = org.tron.protos.Protocol.AccountType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.AccountType.UNRECOGNIZED : result; + } + + public static final int ADDRESS_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString address_; + /** + *
+     * the create address
+     * 
+ * + * bytes address = 3; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + + public static final int BALANCE_FIELD_NUMBER = 4; + private long balance_; + /** + *
+     * the trx balance
+     * 
+ * + * int64 balance = 4; + */ + public long getBalance() { + return balance_; + } + + public static final int VOTES_FIELD_NUMBER = 5; + private java.util.List votes_; + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public java.util.List getVotesList() { + return votes_; + } + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public java.util.List + getVotesOrBuilderList() { + return votes_; + } + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public int getVotesCount() { + return votes_.size(); + } + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public org.tron.protos.Protocol.Vote getVotes(int index) { + return votes_.get(index); + } + /** + *
+     * the votes
+     * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public org.tron.protos.Protocol.VoteOrBuilder getVotesOrBuilder( + int index) { + return votes_.get(index); + } + + public static final int ASSET_FIELD_NUMBER = 6; + private static final class AssetDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_Account_AssetEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> asset_; + private com.google.protobuf.MapField + internalGetAsset() { + if (asset_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetDefaultEntryHolder.defaultEntry); + } + return asset_; + } + + public int getAssetCount() { + return internalGetAsset().getMap().size(); + } + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + + public boolean containsAsset( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAsset().getMap().containsKey(key); + } + /** + * Use {@link #getAssetMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAsset() { + return getAssetMap(); + } + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + + public java.util.Map getAssetMap() { + return internalGetAsset().getMap(); + } + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + + public long getAssetOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAsset().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+     * the other asset owned by this account
+     * 
+ * + * map<string, int64> asset = 6; + */ + + public long getAssetOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAsset().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int ASSETV2_FIELD_NUMBER = 56; + private static final class AssetV2DefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_Account_AssetV2Entry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetV2_; + private com.google.protobuf.MapField + internalGetAssetV2() { + if (assetV2_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetV2DefaultEntryHolder.defaultEntry); + } + return assetV2_; + } + + public int getAssetV2Count() { + return internalGetAssetV2().getMap().size(); + } + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public boolean containsAssetV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetV2().getMap().containsKey(key); + } + /** + * Use {@link #getAssetV2Map()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetV2() { + return getAssetV2Map(); + } + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public java.util.Map getAssetV2Map() { + return internalGetAssetV2().getMap(); + } + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public long getAssetV2OrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetV2().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+     * the other asset owned by this account,key is assetId
+     * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public long getAssetV2OrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetV2().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int FROZEN_FIELD_NUMBER = 7; + private java.util.List frozen_; + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public java.util.List getFrozenList() { + return frozen_; + } + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public java.util.List + getFrozenOrBuilderList() { + return frozen_; + } + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public int getFrozenCount() { + return frozen_.size(); + } + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public org.tron.protos.Protocol.Account.Frozen getFrozen(int index) { + return frozen_.get(index); + } + /** + *
+     * the frozen balance for bandwidth
+     * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenOrBuilder( + int index) { + return frozen_.get(index); + } + + public static final int NET_USAGE_FIELD_NUMBER = 8; + private long netUsage_; + /** + *
+     * bandwidth, get from frozen
+     * 
+ * + * int64 net_usage = 8; + */ + public long getNetUsage() { + return netUsage_; + } + + public static final int ACQUIRED_DELEGATED_FROZEN_BALANCE_FOR_BANDWIDTH_FIELD_NUMBER = 41; + private long acquiredDelegatedFrozenBalanceForBandwidth_; + /** + *
+     *Frozen balance provided by other accounts to this account
+     * 
+ * + * int64 acquired_delegated_frozen_balance_for_bandwidth = 41; + */ + public long getAcquiredDelegatedFrozenBalanceForBandwidth() { + return acquiredDelegatedFrozenBalanceForBandwidth_; + } + + public static final int DELEGATED_FROZEN_BALANCE_FOR_BANDWIDTH_FIELD_NUMBER = 42; + private long delegatedFrozenBalanceForBandwidth_; + /** + *
+     *Freeze and provide balances to other accounts
+     * 
+ * + * int64 delegated_frozen_balance_for_bandwidth = 42; + */ + public long getDelegatedFrozenBalanceForBandwidth() { + return delegatedFrozenBalanceForBandwidth_; + } + + public static final int CREATE_TIME_FIELD_NUMBER = 9; + private long createTime_; + /** + *
+     * this account create time
+     * 
+ * + * int64 create_time = 9; + */ + public long getCreateTime() { + return createTime_; + } + + public static final int LATEST_OPRATION_TIME_FIELD_NUMBER = 10; + private long latestOprationTime_; + /** + *
+     * this last operation time, including transfer, voting and so on. //FIXME fix grammar
+     * 
+ * + * int64 latest_opration_time = 10; + */ + public long getLatestOprationTime() { + return latestOprationTime_; + } + + public static final int ALLOWANCE_FIELD_NUMBER = 11; + private long allowance_; + /** + *
+     * witness block producing allowance
+     * 
+ * + * int64 allowance = 11; + */ + public long getAllowance() { + return allowance_; + } + + public static final int LATEST_WITHDRAW_TIME_FIELD_NUMBER = 12; + private long latestWithdrawTime_; + /** + *
+     * last withdraw time
+     * 
+ * + * int64 latest_withdraw_time = 12; + */ + public long getLatestWithdrawTime() { + return latestWithdrawTime_; + } + + public static final int CODE_FIELD_NUMBER = 13; + private com.google.protobuf.ByteString code_; + /** + *
+     * not used so far
+     * 
+ * + * bytes code = 13; + */ + public com.google.protobuf.ByteString getCode() { + return code_; + } + + public static final int IS_WITNESS_FIELD_NUMBER = 14; + private boolean isWitness_; + /** + * bool is_witness = 14; + */ + public boolean getIsWitness() { + return isWitness_; + } + + public static final int IS_COMMITTEE_FIELD_NUMBER = 15; + private boolean isCommittee_; + /** + * bool is_committee = 15; + */ + public boolean getIsCommittee() { + return isCommittee_; + } + + public static final int FROZEN_SUPPLY_FIELD_NUMBER = 16; + private java.util.List frozenSupply_; + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public java.util.List getFrozenSupplyList() { + return frozenSupply_; + } + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public java.util.List + getFrozenSupplyOrBuilderList() { + return frozenSupply_; + } + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public int getFrozenSupplyCount() { + return frozenSupply_.size(); + } + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public org.tron.protos.Protocol.Account.Frozen getFrozenSupply(int index) { + return frozenSupply_.get(index); + } + /** + *
+     * frozen asset(for asset issuer)
+     * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenSupplyOrBuilder( + int index) { + return frozenSupply_.get(index); + } + + public static final int ASSET_ISSUED_NAME_FIELD_NUMBER = 17; + private com.google.protobuf.ByteString assetIssuedName_; + /** + *
+     * asset_issued_name
+     * 
+ * + * bytes asset_issued_name = 17; + */ + public com.google.protobuf.ByteString getAssetIssuedName() { + return assetIssuedName_; + } + + public static final int ASSET_ISSUED_ID_FIELD_NUMBER = 57; + private com.google.protobuf.ByteString assetIssuedID_; + /** + * bytes asset_issued_ID = 57; + */ + public com.google.protobuf.ByteString getAssetIssuedID() { + return assetIssuedID_; + } + + public static final int LATEST_ASSET_OPERATION_TIME_FIELD_NUMBER = 18; + private static final class LatestAssetOperationTimeDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_Account_LatestAssetOperationTimeEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> latestAssetOperationTime_; + private com.google.protobuf.MapField + internalGetLatestAssetOperationTime() { + if (latestAssetOperationTime_ == null) { + return com.google.protobuf.MapField.emptyMapField( + LatestAssetOperationTimeDefaultEntryHolder.defaultEntry); + } + return latestAssetOperationTime_; + } + + public int getLatestAssetOperationTimeCount() { + return internalGetLatestAssetOperationTime().getMap().size(); + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public boolean containsLatestAssetOperationTime( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetLatestAssetOperationTime().getMap().containsKey(key); + } + /** + * Use {@link #getLatestAssetOperationTimeMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getLatestAssetOperationTime() { + return getLatestAssetOperationTimeMap(); + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public java.util.Map getLatestAssetOperationTimeMap() { + return internalGetLatestAssetOperationTime().getMap(); + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public long getLatestAssetOperationTimeOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTime().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public long getLatestAssetOperationTimeOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTime().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int LATEST_ASSET_OPERATION_TIMEV2_FIELD_NUMBER = 58; + private static final class LatestAssetOperationTimeV2DefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_Account_LatestAssetOperationTimeV2Entry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> latestAssetOperationTimeV2_; + private com.google.protobuf.MapField + internalGetLatestAssetOperationTimeV2() { + if (latestAssetOperationTimeV2_ == null) { + return com.google.protobuf.MapField.emptyMapField( + LatestAssetOperationTimeV2DefaultEntryHolder.defaultEntry); + } + return latestAssetOperationTimeV2_; + } + + public int getLatestAssetOperationTimeV2Count() { + return internalGetLatestAssetOperationTimeV2().getMap().size(); + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public boolean containsLatestAssetOperationTimeV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetLatestAssetOperationTimeV2().getMap().containsKey(key); + } + /** + * Use {@link #getLatestAssetOperationTimeV2Map()} instead. + */ + @java.lang.Deprecated + public java.util.Map getLatestAssetOperationTimeV2() { + return getLatestAssetOperationTimeV2Map(); + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public java.util.Map getLatestAssetOperationTimeV2Map() { + return internalGetLatestAssetOperationTimeV2().getMap(); + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public long getLatestAssetOperationTimeV2OrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTimeV2().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public long getLatestAssetOperationTimeV2OrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTimeV2().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int FREE_NET_USAGE_FIELD_NUMBER = 19; + private long freeNetUsage_; + /** + * int64 free_net_usage = 19; + */ + public long getFreeNetUsage() { + return freeNetUsage_; + } + + public static final int FREE_ASSET_NET_USAGE_FIELD_NUMBER = 20; + private static final class FreeAssetNetUsageDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_Account_FreeAssetNetUsageEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> freeAssetNetUsage_; + private com.google.protobuf.MapField + internalGetFreeAssetNetUsage() { + if (freeAssetNetUsage_ == null) { + return com.google.protobuf.MapField.emptyMapField( + FreeAssetNetUsageDefaultEntryHolder.defaultEntry); + } + return freeAssetNetUsage_; + } + + public int getFreeAssetNetUsageCount() { + return internalGetFreeAssetNetUsage().getMap().size(); + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public boolean containsFreeAssetNetUsage( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetFreeAssetNetUsage().getMap().containsKey(key); + } + /** + * Use {@link #getFreeAssetNetUsageMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getFreeAssetNetUsage() { + return getFreeAssetNetUsageMap(); + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public java.util.Map getFreeAssetNetUsageMap() { + return internalGetFreeAssetNetUsage().getMap(); + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public long getFreeAssetNetUsageOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsage().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public long getFreeAssetNetUsageOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsage().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int FREE_ASSET_NET_USAGEV2_FIELD_NUMBER = 59; + private static final class FreeAssetNetUsageV2DefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.Long> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_Account_FreeAssetNetUsageV2Entry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.INT64, + 0L); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> freeAssetNetUsageV2_; + private com.google.protobuf.MapField + internalGetFreeAssetNetUsageV2() { + if (freeAssetNetUsageV2_ == null) { + return com.google.protobuf.MapField.emptyMapField( + FreeAssetNetUsageV2DefaultEntryHolder.defaultEntry); + } + return freeAssetNetUsageV2_; + } + + public int getFreeAssetNetUsageV2Count() { + return internalGetFreeAssetNetUsageV2().getMap().size(); + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public boolean containsFreeAssetNetUsageV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetFreeAssetNetUsageV2().getMap().containsKey(key); + } + /** + * Use {@link #getFreeAssetNetUsageV2Map()} instead. + */ + @java.lang.Deprecated + public java.util.Map getFreeAssetNetUsageV2() { + return getFreeAssetNetUsageV2Map(); + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public java.util.Map getFreeAssetNetUsageV2Map() { + return internalGetFreeAssetNetUsageV2().getMap(); + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public long getFreeAssetNetUsageV2OrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsageV2().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public long getFreeAssetNetUsageV2OrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsageV2().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int LATEST_CONSUME_TIME_FIELD_NUMBER = 21; + private long latestConsumeTime_; + /** + * int64 latest_consume_time = 21; + */ + public long getLatestConsumeTime() { + return latestConsumeTime_; + } + + public static final int LATEST_CONSUME_FREE_TIME_FIELD_NUMBER = 22; + private long latestConsumeFreeTime_; + /** + * int64 latest_consume_free_time = 22; + */ + public long getLatestConsumeFreeTime() { + return latestConsumeFreeTime_; + } + + public static final int ACCOUNT_ID_FIELD_NUMBER = 23; + private com.google.protobuf.ByteString accountId_; + /** + *
+     * the identity of this account, case insensitive
+     * 
+ * + * bytes account_id = 23; + */ + public com.google.protobuf.ByteString getAccountId() { + return accountId_; + } + + public static final int ACCOUNT_RESOURCE_FIELD_NUMBER = 26; + private org.tron.protos.Protocol.Account.AccountResource accountResource_; + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public boolean hasAccountResource() { + return accountResource_ != null; + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public org.tron.protos.Protocol.Account.AccountResource getAccountResource() { + return accountResource_ == null ? org.tron.protos.Protocol.Account.AccountResource.getDefaultInstance() : accountResource_; + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public org.tron.protos.Protocol.Account.AccountResourceOrBuilder getAccountResourceOrBuilder() { + return getAccountResource(); + } + + public static final int CODEHASH_FIELD_NUMBER = 30; + private com.google.protobuf.ByteString codeHash_; + /** + * bytes codeHash = 30; + */ + public com.google.protobuf.ByteString getCodeHash() { + return codeHash_; + } + + public static final int OWNER_PERMISSION_FIELD_NUMBER = 31; + private org.tron.protos.Protocol.Permission ownerPermission_; + /** + * .protocol.Permission owner_permission = 31; + */ + public boolean hasOwnerPermission() { + return ownerPermission_ != null; + } + /** + * .protocol.Permission owner_permission = 31; + */ + public org.tron.protos.Protocol.Permission getOwnerPermission() { + return ownerPermission_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : ownerPermission_; + } + /** + * .protocol.Permission owner_permission = 31; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getOwnerPermissionOrBuilder() { + return getOwnerPermission(); + } + + public static final int WITNESS_PERMISSION_FIELD_NUMBER = 32; + private org.tron.protos.Protocol.Permission witnessPermission_; + /** + * .protocol.Permission witness_permission = 32; + */ + public boolean hasWitnessPermission() { + return witnessPermission_ != null; + } + /** + * .protocol.Permission witness_permission = 32; + */ + public org.tron.protos.Protocol.Permission getWitnessPermission() { + return witnessPermission_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : witnessPermission_; + } + /** + * .protocol.Permission witness_permission = 32; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getWitnessPermissionOrBuilder() { + return getWitnessPermission(); + } + + public static final int ACTIVE_PERMISSION_FIELD_NUMBER = 33; + private java.util.List activePermission_; + /** + * repeated .protocol.Permission active_permission = 33; + */ + public java.util.List getActivePermissionList() { + return activePermission_; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public java.util.List + getActivePermissionOrBuilderList() { + return activePermission_; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public int getActivePermissionCount() { + return activePermission_.size(); + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public org.tron.protos.Protocol.Permission getActivePermission(int index) { + return activePermission_.get(index); + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getActivePermissionOrBuilder( + int index) { + return activePermission_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!accountName_.isEmpty()) { + output.writeBytes(1, accountName_); + } + if (type_ != org.tron.protos.Protocol.AccountType.Normal.getNumber()) { + output.writeEnum(2, type_); + } + if (!address_.isEmpty()) { + output.writeBytes(3, address_); + } + if (balance_ != 0L) { + output.writeInt64(4, balance_); + } + for (int i = 0; i < votes_.size(); i++) { + output.writeMessage(5, votes_.get(i)); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetAsset(), + AssetDefaultEntryHolder.defaultEntry, + 6); + for (int i = 0; i < frozen_.size(); i++) { + output.writeMessage(7, frozen_.get(i)); + } + if (netUsage_ != 0L) { + output.writeInt64(8, netUsage_); + } + if (createTime_ != 0L) { + output.writeInt64(9, createTime_); + } + if (latestOprationTime_ != 0L) { + output.writeInt64(10, latestOprationTime_); + } + if (allowance_ != 0L) { + output.writeInt64(11, allowance_); + } + if (latestWithdrawTime_ != 0L) { + output.writeInt64(12, latestWithdrawTime_); + } + if (!code_.isEmpty()) { + output.writeBytes(13, code_); + } + if (isWitness_ != false) { + output.writeBool(14, isWitness_); + } + if (isCommittee_ != false) { + output.writeBool(15, isCommittee_); + } + for (int i = 0; i < frozenSupply_.size(); i++) { + output.writeMessage(16, frozenSupply_.get(i)); + } + if (!assetIssuedName_.isEmpty()) { + output.writeBytes(17, assetIssuedName_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetLatestAssetOperationTime(), + LatestAssetOperationTimeDefaultEntryHolder.defaultEntry, + 18); + if (freeNetUsage_ != 0L) { + output.writeInt64(19, freeNetUsage_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetFreeAssetNetUsage(), + FreeAssetNetUsageDefaultEntryHolder.defaultEntry, + 20); + if (latestConsumeTime_ != 0L) { + output.writeInt64(21, latestConsumeTime_); + } + if (latestConsumeFreeTime_ != 0L) { + output.writeInt64(22, latestConsumeFreeTime_); + } + if (!accountId_.isEmpty()) { + output.writeBytes(23, accountId_); + } + if (accountResource_ != null) { + output.writeMessage(26, getAccountResource()); + } + if (!codeHash_.isEmpty()) { + output.writeBytes(30, codeHash_); + } + if (ownerPermission_ != null) { + output.writeMessage(31, getOwnerPermission()); + } + if (witnessPermission_ != null) { + output.writeMessage(32, getWitnessPermission()); + } + for (int i = 0; i < activePermission_.size(); i++) { + output.writeMessage(33, activePermission_.get(i)); + } + if (acquiredDelegatedFrozenBalanceForBandwidth_ != 0L) { + output.writeInt64(41, acquiredDelegatedFrozenBalanceForBandwidth_); + } + if (delegatedFrozenBalanceForBandwidth_ != 0L) { + output.writeInt64(42, delegatedFrozenBalanceForBandwidth_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetAssetV2(), + AssetV2DefaultEntryHolder.defaultEntry, + 56); + if (!assetIssuedID_.isEmpty()) { + output.writeBytes(57, assetIssuedID_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetLatestAssetOperationTimeV2(), + LatestAssetOperationTimeV2DefaultEntryHolder.defaultEntry, + 58); + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetFreeAssetNetUsageV2(), + FreeAssetNetUsageV2DefaultEntryHolder.defaultEntry, + 59); + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!accountName_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, accountName_); + } + if (type_ != org.tron.protos.Protocol.AccountType.Normal.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, type_); + } + if (!address_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, address_); + } + if (balance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, balance_); + } + for (int i = 0; i < votes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, votes_.get(i)); + } + for (java.util.Map.Entry entry + : internalGetAsset().getMap().entrySet()) { + com.google.protobuf.MapEntry + asset__ = AssetDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, asset__); + } + for (int i = 0; i < frozen_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, frozen_.get(i)); + } + if (netUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, netUsage_); + } + if (createTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(9, createTime_); + } + if (latestOprationTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(10, latestOprationTime_); + } + if (allowance_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(11, allowance_); + } + if (latestWithdrawTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(12, latestWithdrawTime_); + } + if (!code_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(13, code_); + } + if (isWitness_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(14, isWitness_); + } + if (isCommittee_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(15, isCommittee_); + } + for (int i = 0; i < frozenSupply_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(16, frozenSupply_.get(i)); + } + if (!assetIssuedName_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(17, assetIssuedName_); + } + for (java.util.Map.Entry entry + : internalGetLatestAssetOperationTime().getMap().entrySet()) { + com.google.protobuf.MapEntry + latestAssetOperationTime__ = LatestAssetOperationTimeDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(18, latestAssetOperationTime__); + } + if (freeNetUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(19, freeNetUsage_); + } + for (java.util.Map.Entry entry + : internalGetFreeAssetNetUsage().getMap().entrySet()) { + com.google.protobuf.MapEntry + freeAssetNetUsage__ = FreeAssetNetUsageDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(20, freeAssetNetUsage__); + } + if (latestConsumeTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(21, latestConsumeTime_); + } + if (latestConsumeFreeTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(22, latestConsumeFreeTime_); + } + if (!accountId_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(23, accountId_); + } + if (accountResource_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(26, getAccountResource()); + } + if (!codeHash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(30, codeHash_); + } + if (ownerPermission_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(31, getOwnerPermission()); + } + if (witnessPermission_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(32, getWitnessPermission()); + } + for (int i = 0; i < activePermission_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(33, activePermission_.get(i)); + } + if (acquiredDelegatedFrozenBalanceForBandwidth_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(41, acquiredDelegatedFrozenBalanceForBandwidth_); + } + if (delegatedFrozenBalanceForBandwidth_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(42, delegatedFrozenBalanceForBandwidth_); + } + for (java.util.Map.Entry entry + : internalGetAssetV2().getMap().entrySet()) { + com.google.protobuf.MapEntry + assetV2__ = AssetV2DefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(56, assetV2__); + } + if (!assetIssuedID_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(57, assetIssuedID_); + } + for (java.util.Map.Entry entry + : internalGetLatestAssetOperationTimeV2().getMap().entrySet()) { + com.google.protobuf.MapEntry + latestAssetOperationTimeV2__ = LatestAssetOperationTimeV2DefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(58, latestAssetOperationTimeV2__); + } + for (java.util.Map.Entry entry + : internalGetFreeAssetNetUsageV2().getMap().entrySet()) { + com.google.protobuf.MapEntry + freeAssetNetUsageV2__ = FreeAssetNetUsageV2DefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(59, freeAssetNetUsageV2__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Account)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Account other = (org.tron.protos.Protocol.Account) obj; + + boolean result = true; + result = result && getAccountName() + .equals(other.getAccountName()); + result = result && type_ == other.type_; + result = result && getAddress() + .equals(other.getAddress()); + result = result && (getBalance() + == other.getBalance()); + result = result && getVotesList() + .equals(other.getVotesList()); + result = result && internalGetAsset().equals( + other.internalGetAsset()); + result = result && internalGetAssetV2().equals( + other.internalGetAssetV2()); + result = result && getFrozenList() + .equals(other.getFrozenList()); + result = result && (getNetUsage() + == other.getNetUsage()); + result = result && (getAcquiredDelegatedFrozenBalanceForBandwidth() + == other.getAcquiredDelegatedFrozenBalanceForBandwidth()); + result = result && (getDelegatedFrozenBalanceForBandwidth() + == other.getDelegatedFrozenBalanceForBandwidth()); + result = result && (getCreateTime() + == other.getCreateTime()); + result = result && (getLatestOprationTime() + == other.getLatestOprationTime()); + result = result && (getAllowance() + == other.getAllowance()); + result = result && (getLatestWithdrawTime() + == other.getLatestWithdrawTime()); + result = result && getCode() + .equals(other.getCode()); + result = result && (getIsWitness() + == other.getIsWitness()); + result = result && (getIsCommittee() + == other.getIsCommittee()); + result = result && getFrozenSupplyList() + .equals(other.getFrozenSupplyList()); + result = result && getAssetIssuedName() + .equals(other.getAssetIssuedName()); + result = result && getAssetIssuedID() + .equals(other.getAssetIssuedID()); + result = result && internalGetLatestAssetOperationTime().equals( + other.internalGetLatestAssetOperationTime()); + result = result && internalGetLatestAssetOperationTimeV2().equals( + other.internalGetLatestAssetOperationTimeV2()); + result = result && (getFreeNetUsage() + == other.getFreeNetUsage()); + result = result && internalGetFreeAssetNetUsage().equals( + other.internalGetFreeAssetNetUsage()); + result = result && internalGetFreeAssetNetUsageV2().equals( + other.internalGetFreeAssetNetUsageV2()); + result = result && (getLatestConsumeTime() + == other.getLatestConsumeTime()); + result = result && (getLatestConsumeFreeTime() + == other.getLatestConsumeFreeTime()); + result = result && getAccountId() + .equals(other.getAccountId()); + result = result && (hasAccountResource() == other.hasAccountResource()); + if (hasAccountResource()) { + result = result && getAccountResource() + .equals(other.getAccountResource()); + } + result = result && getCodeHash() + .equals(other.getCodeHash()); + result = result && (hasOwnerPermission() == other.hasOwnerPermission()); + if (hasOwnerPermission()) { + result = result && getOwnerPermission() + .equals(other.getOwnerPermission()); + } + result = result && (hasWitnessPermission() == other.hasWitnessPermission()); + if (hasWitnessPermission()) { + result = result && getWitnessPermission() + .equals(other.getWitnessPermission()); + } + result = result && getActivePermissionList() + .equals(other.getActivePermissionList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ACCOUNT_NAME_FIELD_NUMBER; + hash = (53 * hash) + getAccountName().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + hash = (37 * hash) + BALANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBalance()); + if (getVotesCount() > 0) { + hash = (37 * hash) + VOTES_FIELD_NUMBER; + hash = (53 * hash) + getVotesList().hashCode(); + } + if (!internalGetAsset().getMap().isEmpty()) { + hash = (37 * hash) + ASSET_FIELD_NUMBER; + hash = (53 * hash) + internalGetAsset().hashCode(); + } + if (!internalGetAssetV2().getMap().isEmpty()) { + hash = (37 * hash) + ASSETV2_FIELD_NUMBER; + hash = (53 * hash) + internalGetAssetV2().hashCode(); + } + if (getFrozenCount() > 0) { + hash = (37 * hash) + FROZEN_FIELD_NUMBER; + hash = (53 * hash) + getFrozenList().hashCode(); + } + hash = (37 * hash) + NET_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNetUsage()); + hash = (37 * hash) + ACQUIRED_DELEGATED_FROZEN_BALANCE_FOR_BANDWIDTH_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAcquiredDelegatedFrozenBalanceForBandwidth()); + hash = (37 * hash) + DELEGATED_FROZEN_BALANCE_FOR_BANDWIDTH_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getDelegatedFrozenBalanceForBandwidth()); + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCreateTime()); + hash = (37 * hash) + LATEST_OPRATION_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestOprationTime()); + hash = (37 * hash) + ALLOWANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAllowance()); + hash = (37 * hash) + LATEST_WITHDRAW_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestWithdrawTime()); + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + getCode().hashCode(); + hash = (37 * hash) + IS_WITNESS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIsWitness()); + hash = (37 * hash) + IS_COMMITTEE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIsCommittee()); + if (getFrozenSupplyCount() > 0) { + hash = (37 * hash) + FROZEN_SUPPLY_FIELD_NUMBER; + hash = (53 * hash) + getFrozenSupplyList().hashCode(); + } + hash = (37 * hash) + ASSET_ISSUED_NAME_FIELD_NUMBER; + hash = (53 * hash) + getAssetIssuedName().hashCode(); + hash = (37 * hash) + ASSET_ISSUED_ID_FIELD_NUMBER; + hash = (53 * hash) + getAssetIssuedID().hashCode(); + if (!internalGetLatestAssetOperationTime().getMap().isEmpty()) { + hash = (37 * hash) + LATEST_ASSET_OPERATION_TIME_FIELD_NUMBER; + hash = (53 * hash) + internalGetLatestAssetOperationTime().hashCode(); + } + if (!internalGetLatestAssetOperationTimeV2().getMap().isEmpty()) { + hash = (37 * hash) + LATEST_ASSET_OPERATION_TIMEV2_FIELD_NUMBER; + hash = (53 * hash) + internalGetLatestAssetOperationTimeV2().hashCode(); + } + hash = (37 * hash) + FREE_NET_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFreeNetUsage()); + if (!internalGetFreeAssetNetUsage().getMap().isEmpty()) { + hash = (37 * hash) + FREE_ASSET_NET_USAGE_FIELD_NUMBER; + hash = (53 * hash) + internalGetFreeAssetNetUsage().hashCode(); + } + if (!internalGetFreeAssetNetUsageV2().getMap().isEmpty()) { + hash = (37 * hash) + FREE_ASSET_NET_USAGEV2_FIELD_NUMBER; + hash = (53 * hash) + internalGetFreeAssetNetUsageV2().hashCode(); + } + hash = (37 * hash) + LATEST_CONSUME_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestConsumeTime()); + hash = (37 * hash) + LATEST_CONSUME_FREE_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestConsumeFreeTime()); + hash = (37 * hash) + ACCOUNT_ID_FIELD_NUMBER; + hash = (53 * hash) + getAccountId().hashCode(); + if (hasAccountResource()) { + hash = (37 * hash) + ACCOUNT_RESOURCE_FIELD_NUMBER; + hash = (53 * hash) + getAccountResource().hashCode(); + } + hash = (37 * hash) + CODEHASH_FIELD_NUMBER; + hash = (53 * hash) + getCodeHash().hashCode(); + if (hasOwnerPermission()) { + hash = (37 * hash) + OWNER_PERMISSION_FIELD_NUMBER; + hash = (53 * hash) + getOwnerPermission().hashCode(); + } + if (hasWitnessPermission()) { + hash = (37 * hash) + WITNESS_PERMISSION_FIELD_NUMBER; + hash = (53 * hash) + getWitnessPermission().hashCode(); + } + if (getActivePermissionCount() > 0) { + hash = (37 * hash) + ACTIVE_PERMISSION_FIELD_NUMBER; + hash = (53 * hash) + getActivePermissionList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Account parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Account parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Account parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Account parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Account parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Account parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Account prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Account 
+     * 
+ * + * Protobuf type {@code protocol.Account} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Account) + org.tron.protos.Protocol.AccountOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Account_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 6: + return internalGetAsset(); + case 56: + return internalGetAssetV2(); + case 18: + return internalGetLatestAssetOperationTime(); + case 58: + return internalGetLatestAssetOperationTimeV2(); + case 20: + return internalGetFreeAssetNetUsage(); + case 59: + return internalGetFreeAssetNetUsageV2(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 6: + return internalGetMutableAsset(); + case 56: + return internalGetMutableAssetV2(); + case 18: + return internalGetMutableLatestAssetOperationTime(); + case 58: + return internalGetMutableLatestAssetOperationTimeV2(); + case 20: + return internalGetMutableFreeAssetNetUsage(); + case 59: + return internalGetMutableFreeAssetNetUsageV2(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Account_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Account.class, org.tron.protos.Protocol.Account.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Account.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getVotesFieldBuilder(); + getFrozenFieldBuilder(); + getFrozenSupplyFieldBuilder(); + getActivePermissionFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + accountName_ = com.google.protobuf.ByteString.EMPTY; + + type_ = 0; + + address_ = com.google.protobuf.ByteString.EMPTY; + + balance_ = 0L; + + if (votesBuilder_ == null) { + votes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + votesBuilder_.clear(); + } + internalGetMutableAsset().clear(); + internalGetMutableAssetV2().clear(); + if (frozenBuilder_ == null) { + frozen_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + } else { + frozenBuilder_.clear(); + } + netUsage_ = 0L; + + acquiredDelegatedFrozenBalanceForBandwidth_ = 0L; + + delegatedFrozenBalanceForBandwidth_ = 0L; + + createTime_ = 0L; + + latestOprationTime_ = 0L; + + allowance_ = 0L; + + latestWithdrawTime_ = 0L; + + code_ = com.google.protobuf.ByteString.EMPTY; + + isWitness_ = false; + + isCommittee_ = false; + + if (frozenSupplyBuilder_ == null) { + frozenSupply_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00040000); + } else { + frozenSupplyBuilder_.clear(); + } + assetIssuedName_ = com.google.protobuf.ByteString.EMPTY; + + assetIssuedID_ = com.google.protobuf.ByteString.EMPTY; + + internalGetMutableLatestAssetOperationTime().clear(); + internalGetMutableLatestAssetOperationTimeV2().clear(); + freeNetUsage_ = 0L; + + internalGetMutableFreeAssetNetUsage().clear(); + internalGetMutableFreeAssetNetUsageV2().clear(); + latestConsumeTime_ = 0L; + + latestConsumeFreeTime_ = 0L; + + accountId_ = com.google.protobuf.ByteString.EMPTY; + + if (accountResourceBuilder_ == null) { + accountResource_ = null; + } else { + accountResource_ = null; + accountResourceBuilder_ = null; + } + codeHash_ = com.google.protobuf.ByteString.EMPTY; + + if (ownerPermissionBuilder_ == null) { + ownerPermission_ = null; + } else { + ownerPermission_ = null; + ownerPermissionBuilder_ = null; + } + if (witnessPermissionBuilder_ == null) { + witnessPermission_ = null; + } else { + witnessPermission_ = null; + witnessPermissionBuilder_ = null; + } + if (activePermissionBuilder_ == null) { + activePermission_ = java.util.Collections.emptyList(); + bitField1_ = (bitField1_ & ~0x00000002); + } else { + activePermissionBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Account_descriptor; + } + + public org.tron.protos.Protocol.Account getDefaultInstanceForType() { + return org.tron.protos.Protocol.Account.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Account build() { + org.tron.protos.Protocol.Account result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Account buildPartial() { + org.tron.protos.Protocol.Account result = new org.tron.protos.Protocol.Account(this); + int from_bitField0_ = bitField0_; + int from_bitField1_ = bitField1_; + int to_bitField0_ = 0; + result.accountName_ = accountName_; + result.type_ = type_; + result.address_ = address_; + result.balance_ = balance_; + if (votesBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + votes_ = java.util.Collections.unmodifiableList(votes_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.votes_ = votes_; + } else { + result.votes_ = votesBuilder_.build(); + } + result.asset_ = internalGetAsset(); + result.asset_.makeImmutable(); + result.assetV2_ = internalGetAssetV2(); + result.assetV2_.makeImmutable(); + if (frozenBuilder_ == null) { + if (((bitField0_ & 0x00000080) == 0x00000080)) { + frozen_ = java.util.Collections.unmodifiableList(frozen_); + bitField0_ = (bitField0_ & ~0x00000080); + } + result.frozen_ = frozen_; + } else { + result.frozen_ = frozenBuilder_.build(); + } + result.netUsage_ = netUsage_; + result.acquiredDelegatedFrozenBalanceForBandwidth_ = acquiredDelegatedFrozenBalanceForBandwidth_; + result.delegatedFrozenBalanceForBandwidth_ = delegatedFrozenBalanceForBandwidth_; + result.createTime_ = createTime_; + result.latestOprationTime_ = latestOprationTime_; + result.allowance_ = allowance_; + result.latestWithdrawTime_ = latestWithdrawTime_; + result.code_ = code_; + result.isWitness_ = isWitness_; + result.isCommittee_ = isCommittee_; + if (frozenSupplyBuilder_ == null) { + if (((bitField0_ & 0x00040000) == 0x00040000)) { + frozenSupply_ = java.util.Collections.unmodifiableList(frozenSupply_); + bitField0_ = (bitField0_ & ~0x00040000); + } + result.frozenSupply_ = frozenSupply_; + } else { + result.frozenSupply_ = frozenSupplyBuilder_.build(); + } + result.assetIssuedName_ = assetIssuedName_; + result.assetIssuedID_ = assetIssuedID_; + result.latestAssetOperationTime_ = internalGetLatestAssetOperationTime(); + result.latestAssetOperationTime_.makeImmutable(); + result.latestAssetOperationTimeV2_ = internalGetLatestAssetOperationTimeV2(); + result.latestAssetOperationTimeV2_.makeImmutable(); + result.freeNetUsage_ = freeNetUsage_; + result.freeAssetNetUsage_ = internalGetFreeAssetNetUsage(); + result.freeAssetNetUsage_.makeImmutable(); + result.freeAssetNetUsageV2_ = internalGetFreeAssetNetUsageV2(); + result.freeAssetNetUsageV2_.makeImmutable(); + result.latestConsumeTime_ = latestConsumeTime_; + result.latestConsumeFreeTime_ = latestConsumeFreeTime_; + result.accountId_ = accountId_; + if (accountResourceBuilder_ == null) { + result.accountResource_ = accountResource_; + } else { + result.accountResource_ = accountResourceBuilder_.build(); + } + result.codeHash_ = codeHash_; + if (ownerPermissionBuilder_ == null) { + result.ownerPermission_ = ownerPermission_; + } else { + result.ownerPermission_ = ownerPermissionBuilder_.build(); + } + if (witnessPermissionBuilder_ == null) { + result.witnessPermission_ = witnessPermission_; + } else { + result.witnessPermission_ = witnessPermissionBuilder_.build(); + } + if (activePermissionBuilder_ == null) { + if (((bitField1_ & 0x00000002) == 0x00000002)) { + activePermission_ = java.util.Collections.unmodifiableList(activePermission_); + bitField1_ = (bitField1_ & ~0x00000002); + } + result.activePermission_ = activePermission_; + } else { + result.activePermission_ = activePermissionBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Account) { + return mergeFrom((org.tron.protos.Protocol.Account)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Account other) { + if (other == org.tron.protos.Protocol.Account.getDefaultInstance()) return this; + if (other.getAccountName() != com.google.protobuf.ByteString.EMPTY) { + setAccountName(other.getAccountName()); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.getAddress() != com.google.protobuf.ByteString.EMPTY) { + setAddress(other.getAddress()); + } + if (other.getBalance() != 0L) { + setBalance(other.getBalance()); + } + if (votesBuilder_ == null) { + if (!other.votes_.isEmpty()) { + if (votes_.isEmpty()) { + votes_ = other.votes_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureVotesIsMutable(); + votes_.addAll(other.votes_); + } + onChanged(); + } + } else { + if (!other.votes_.isEmpty()) { + if (votesBuilder_.isEmpty()) { + votesBuilder_.dispose(); + votesBuilder_ = null; + votes_ = other.votes_; + bitField0_ = (bitField0_ & ~0x00000010); + votesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getVotesFieldBuilder() : null; + } else { + votesBuilder_.addAllMessages(other.votes_); + } + } + } + internalGetMutableAsset().mergeFrom( + other.internalGetAsset()); + internalGetMutableAssetV2().mergeFrom( + other.internalGetAssetV2()); + if (frozenBuilder_ == null) { + if (!other.frozen_.isEmpty()) { + if (frozen_.isEmpty()) { + frozen_ = other.frozen_; + bitField0_ = (bitField0_ & ~0x00000080); + } else { + ensureFrozenIsMutable(); + frozen_.addAll(other.frozen_); + } + onChanged(); + } + } else { + if (!other.frozen_.isEmpty()) { + if (frozenBuilder_.isEmpty()) { + frozenBuilder_.dispose(); + frozenBuilder_ = null; + frozen_ = other.frozen_; + bitField0_ = (bitField0_ & ~0x00000080); + frozenBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getFrozenFieldBuilder() : null; + } else { + frozenBuilder_.addAllMessages(other.frozen_); + } + } + } + if (other.getNetUsage() != 0L) { + setNetUsage(other.getNetUsage()); + } + if (other.getAcquiredDelegatedFrozenBalanceForBandwidth() != 0L) { + setAcquiredDelegatedFrozenBalanceForBandwidth(other.getAcquiredDelegatedFrozenBalanceForBandwidth()); + } + if (other.getDelegatedFrozenBalanceForBandwidth() != 0L) { + setDelegatedFrozenBalanceForBandwidth(other.getDelegatedFrozenBalanceForBandwidth()); + } + if (other.getCreateTime() != 0L) { + setCreateTime(other.getCreateTime()); + } + if (other.getLatestOprationTime() != 0L) { + setLatestOprationTime(other.getLatestOprationTime()); + } + if (other.getAllowance() != 0L) { + setAllowance(other.getAllowance()); + } + if (other.getLatestWithdrawTime() != 0L) { + setLatestWithdrawTime(other.getLatestWithdrawTime()); + } + if (other.getCode() != com.google.protobuf.ByteString.EMPTY) { + setCode(other.getCode()); + } + if (other.getIsWitness() != false) { + setIsWitness(other.getIsWitness()); + } + if (other.getIsCommittee() != false) { + setIsCommittee(other.getIsCommittee()); + } + if (frozenSupplyBuilder_ == null) { + if (!other.frozenSupply_.isEmpty()) { + if (frozenSupply_.isEmpty()) { + frozenSupply_ = other.frozenSupply_; + bitField0_ = (bitField0_ & ~0x00040000); + } else { + ensureFrozenSupplyIsMutable(); + frozenSupply_.addAll(other.frozenSupply_); + } + onChanged(); + } + } else { + if (!other.frozenSupply_.isEmpty()) { + if (frozenSupplyBuilder_.isEmpty()) { + frozenSupplyBuilder_.dispose(); + frozenSupplyBuilder_ = null; + frozenSupply_ = other.frozenSupply_; + bitField0_ = (bitField0_ & ~0x00040000); + frozenSupplyBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getFrozenSupplyFieldBuilder() : null; + } else { + frozenSupplyBuilder_.addAllMessages(other.frozenSupply_); + } + } + } + if (other.getAssetIssuedName() != com.google.protobuf.ByteString.EMPTY) { + setAssetIssuedName(other.getAssetIssuedName()); + } + if (other.getAssetIssuedID() != com.google.protobuf.ByteString.EMPTY) { + setAssetIssuedID(other.getAssetIssuedID()); + } + internalGetMutableLatestAssetOperationTime().mergeFrom( + other.internalGetLatestAssetOperationTime()); + internalGetMutableLatestAssetOperationTimeV2().mergeFrom( + other.internalGetLatestAssetOperationTimeV2()); + if (other.getFreeNetUsage() != 0L) { + setFreeNetUsage(other.getFreeNetUsage()); + } + internalGetMutableFreeAssetNetUsage().mergeFrom( + other.internalGetFreeAssetNetUsage()); + internalGetMutableFreeAssetNetUsageV2().mergeFrom( + other.internalGetFreeAssetNetUsageV2()); + if (other.getLatestConsumeTime() != 0L) { + setLatestConsumeTime(other.getLatestConsumeTime()); + } + if (other.getLatestConsumeFreeTime() != 0L) { + setLatestConsumeFreeTime(other.getLatestConsumeFreeTime()); + } + if (other.getAccountId() != com.google.protobuf.ByteString.EMPTY) { + setAccountId(other.getAccountId()); + } + if (other.hasAccountResource()) { + mergeAccountResource(other.getAccountResource()); + } + if (other.getCodeHash() != com.google.protobuf.ByteString.EMPTY) { + setCodeHash(other.getCodeHash()); + } + if (other.hasOwnerPermission()) { + mergeOwnerPermission(other.getOwnerPermission()); + } + if (other.hasWitnessPermission()) { + mergeWitnessPermission(other.getWitnessPermission()); + } + if (activePermissionBuilder_ == null) { + if (!other.activePermission_.isEmpty()) { + if (activePermission_.isEmpty()) { + activePermission_ = other.activePermission_; + bitField1_ = (bitField1_ & ~0x00000002); + } else { + ensureActivePermissionIsMutable(); + activePermission_.addAll(other.activePermission_); + } + onChanged(); + } + } else { + if (!other.activePermission_.isEmpty()) { + if (activePermissionBuilder_.isEmpty()) { + activePermissionBuilder_.dispose(); + activePermissionBuilder_ = null; + activePermission_ = other.activePermission_; + bitField1_ = (bitField1_ & ~0x00000002); + activePermissionBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getActivePermissionFieldBuilder() : null; + } else { + activePermissionBuilder_.addAllMessages(other.activePermission_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Account parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Account) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + private int bitField1_; + + private com.google.protobuf.ByteString accountName_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * account nick name
+       * 
+ * + * bytes account_name = 1; + */ + public com.google.protobuf.ByteString getAccountName() { + return accountName_; + } + /** + *
+       * account nick name
+       * 
+ * + * bytes account_name = 1; + */ + public Builder setAccountName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + accountName_ = value; + onChanged(); + return this; + } + /** + *
+       * account nick name
+       * 
+ * + * bytes account_name = 1; + */ + public Builder clearAccountName() { + + accountName_ = getDefaultInstance().getAccountName(); + onChanged(); + return this; + } + + private int type_ = 0; + /** + * .protocol.AccountType type = 2; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.AccountType type = 2; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.AccountType type = 2; + */ + public org.tron.protos.Protocol.AccountType getType() { + org.tron.protos.Protocol.AccountType result = org.tron.protos.Protocol.AccountType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.AccountType.UNRECOGNIZED : result; + } + /** + * .protocol.AccountType type = 2; + */ + public Builder setType(org.tron.protos.Protocol.AccountType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.AccountType type = 2; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString address_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * the create address
+       * 
+ * + * bytes address = 3; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + /** + *
+       * the create address
+       * 
+ * + * bytes address = 3; + */ + public Builder setAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + *
+       * the create address
+       * 
+ * + * bytes address = 3; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + + private long balance_ ; + /** + *
+       * the trx balance
+       * 
+ * + * int64 balance = 4; + */ + public long getBalance() { + return balance_; + } + /** + *
+       * the trx balance
+       * 
+ * + * int64 balance = 4; + */ + public Builder setBalance(long value) { + + balance_ = value; + onChanged(); + return this; + } + /** + *
+       * the trx balance
+       * 
+ * + * int64 balance = 4; + */ + public Builder clearBalance() { + + balance_ = 0L; + onChanged(); + return this; + } + + private java.util.List votes_ = + java.util.Collections.emptyList(); + private void ensureVotesIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + votes_ = new java.util.ArrayList(votes_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder> votesBuilder_; + + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public java.util.List getVotesList() { + if (votesBuilder_ == null) { + return java.util.Collections.unmodifiableList(votes_); + } else { + return votesBuilder_.getMessageList(); + } + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public int getVotesCount() { + if (votesBuilder_ == null) { + return votes_.size(); + } else { + return votesBuilder_.getCount(); + } + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public org.tron.protos.Protocol.Vote getVotes(int index) { + if (votesBuilder_ == null) { + return votes_.get(index); + } else { + return votesBuilder_.getMessage(index); + } + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder setVotes( + int index, org.tron.protos.Protocol.Vote value) { + if (votesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureVotesIsMutable(); + votes_.set(index, value); + onChanged(); + } else { + votesBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder setVotes( + int index, org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.set(index, builderForValue.build()); + onChanged(); + } else { + votesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder addVotes(org.tron.protos.Protocol.Vote value) { + if (votesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureVotesIsMutable(); + votes_.add(value); + onChanged(); + } else { + votesBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder addVotes( + int index, org.tron.protos.Protocol.Vote value) { + if (votesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureVotesIsMutable(); + votes_.add(index, value); + onChanged(); + } else { + votesBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder addVotes( + org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.add(builderForValue.build()); + onChanged(); + } else { + votesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder addVotes( + int index, org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.add(index, builderForValue.build()); + onChanged(); + } else { + votesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder addAllVotes( + java.lang.Iterable values) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, votes_); + onChanged(); + } else { + votesBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder clearVotes() { + if (votesBuilder_ == null) { + votes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + votesBuilder_.clear(); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public Builder removeVotes(int index) { + if (votesBuilder_ == null) { + ensureVotesIsMutable(); + votes_.remove(index); + onChanged(); + } else { + votesBuilder_.remove(index); + } + return this; + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public org.tron.protos.Protocol.Vote.Builder getVotesBuilder( + int index) { + return getVotesFieldBuilder().getBuilder(index); + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public org.tron.protos.Protocol.VoteOrBuilder getVotesOrBuilder( + int index) { + if (votesBuilder_ == null) { + return votes_.get(index); } else { + return votesBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public java.util.List + getVotesOrBuilderList() { + if (votesBuilder_ != null) { + return votesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(votes_); + } + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public org.tron.protos.Protocol.Vote.Builder addVotesBuilder() { + return getVotesFieldBuilder().addBuilder( + org.tron.protos.Protocol.Vote.getDefaultInstance()); + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public org.tron.protos.Protocol.Vote.Builder addVotesBuilder( + int index) { + return getVotesFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Vote.getDefaultInstance()); + } + /** + *
+       * the votes
+       * 
+ * + * repeated .protocol.Vote votes = 5; + */ + public java.util.List + getVotesBuilderList() { + return getVotesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder> + getVotesFieldBuilder() { + if (votesBuilder_ == null) { + votesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder>( + votes_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + votes_ = null; + } + return votesBuilder_; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> asset_; + private com.google.protobuf.MapField + internalGetAsset() { + if (asset_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetDefaultEntryHolder.defaultEntry); + } + return asset_; + } + private com.google.protobuf.MapField + internalGetMutableAsset() { + onChanged();; + if (asset_ == null) { + asset_ = com.google.protobuf.MapField.newMapField( + AssetDefaultEntryHolder.defaultEntry); + } + if (!asset_.isMutable()) { + asset_ = asset_.copy(); + } + return asset_; + } + + public int getAssetCount() { + return internalGetAsset().getMap().size(); + } + /** + *
+       * the other asset owned by this account
+       * 
+ * + * map<string, int64> asset = 6; + */ + + public boolean containsAsset( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAsset().getMap().containsKey(key); + } + /** + * Use {@link #getAssetMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAsset() { + return getAssetMap(); + } + /** + *
+       * the other asset owned by this account
+       * 
+ * + * map<string, int64> asset = 6; + */ + + public java.util.Map getAssetMap() { + return internalGetAsset().getMap(); + } + /** + *
+       * the other asset owned by this account
+       * 
+ * + * map<string, int64> asset = 6; + */ + + public long getAssetOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAsset().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+       * the other asset owned by this account
+       * 
+ * + * map<string, int64> asset = 6; + */ + + public long getAssetOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAsset().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearAsset() { + internalGetMutableAsset().getMutableMap() + .clear(); + return this; + } + /** + *
+       * the other asset owned by this account
+       * 
+ * + * map<string, int64> asset = 6; + */ + + public Builder removeAsset( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAsset().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableAsset() { + return internalGetMutableAsset().getMutableMap(); + } + /** + *
+       * the other asset owned by this account
+       * 
+ * + * map<string, int64> asset = 6; + */ + public Builder putAsset( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableAsset().getMutableMap() + .put(key, value); + return this; + } + /** + *
+       * the other asset owned by this account
+       * 
+ * + * map<string, int64> asset = 6; + */ + + public Builder putAllAsset( + java.util.Map values) { + internalGetMutableAsset().getMutableMap() + .putAll(values); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> assetV2_; + private com.google.protobuf.MapField + internalGetAssetV2() { + if (assetV2_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AssetV2DefaultEntryHolder.defaultEntry); + } + return assetV2_; + } + private com.google.protobuf.MapField + internalGetMutableAssetV2() { + onChanged();; + if (assetV2_ == null) { + assetV2_ = com.google.protobuf.MapField.newMapField( + AssetV2DefaultEntryHolder.defaultEntry); + } + if (!assetV2_.isMutable()) { + assetV2_ = assetV2_.copy(); + } + return assetV2_; + } + + public int getAssetV2Count() { + return internalGetAssetV2().getMap().size(); + } + /** + *
+       * the other asset owned by this account,key is assetId
+       * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public boolean containsAssetV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAssetV2().getMap().containsKey(key); + } + /** + * Use {@link #getAssetV2Map()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAssetV2() { + return getAssetV2Map(); + } + /** + *
+       * the other asset owned by this account,key is assetId
+       * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public java.util.Map getAssetV2Map() { + return internalGetAssetV2().getMap(); + } + /** + *
+       * the other asset owned by this account,key is assetId
+       * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public long getAssetV2OrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetV2().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+       * the other asset owned by this account,key is assetId
+       * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public long getAssetV2OrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAssetV2().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearAssetV2() { + internalGetMutableAssetV2().getMutableMap() + .clear(); + return this; + } + /** + *
+       * the other asset owned by this account,key is assetId
+       * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public Builder removeAssetV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAssetV2().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableAssetV2() { + return internalGetMutableAssetV2().getMutableMap(); + } + /** + *
+       * the other asset owned by this account,key is assetId
+       * 
+ * + * map<string, int64> assetV2 = 56; + */ + public Builder putAssetV2( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableAssetV2().getMutableMap() + .put(key, value); + return this; + } + /** + *
+       * the other asset owned by this account,key is assetId
+       * 
+ * + * map<string, int64> assetV2 = 56; + */ + + public Builder putAllAssetV2( + java.util.Map values) { + internalGetMutableAssetV2().getMutableMap() + .putAll(values); + return this; + } + + private java.util.List frozen_ = + java.util.Collections.emptyList(); + private void ensureFrozenIsMutable() { + if (!((bitField0_ & 0x00000080) == 0x00000080)) { + frozen_ = new java.util.ArrayList(frozen_); + bitField0_ |= 0x00000080; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder> frozenBuilder_; + + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public java.util.List getFrozenList() { + if (frozenBuilder_ == null) { + return java.util.Collections.unmodifiableList(frozen_); + } else { + return frozenBuilder_.getMessageList(); + } + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public int getFrozenCount() { + if (frozenBuilder_ == null) { + return frozen_.size(); + } else { + return frozenBuilder_.getCount(); + } + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public org.tron.protos.Protocol.Account.Frozen getFrozen(int index) { + if (frozenBuilder_ == null) { + return frozen_.get(index); + } else { + return frozenBuilder_.getMessage(index); + } + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder setFrozen( + int index, org.tron.protos.Protocol.Account.Frozen value) { + if (frozenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenIsMutable(); + frozen_.set(index, value); + onChanged(); + } else { + frozenBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder setFrozen( + int index, org.tron.protos.Protocol.Account.Frozen.Builder builderForValue) { + if (frozenBuilder_ == null) { + ensureFrozenIsMutable(); + frozen_.set(index, builderForValue.build()); + onChanged(); + } else { + frozenBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder addFrozen(org.tron.protos.Protocol.Account.Frozen value) { + if (frozenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenIsMutable(); + frozen_.add(value); + onChanged(); + } else { + frozenBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder addFrozen( + int index, org.tron.protos.Protocol.Account.Frozen value) { + if (frozenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenIsMutable(); + frozen_.add(index, value); + onChanged(); + } else { + frozenBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder addFrozen( + org.tron.protos.Protocol.Account.Frozen.Builder builderForValue) { + if (frozenBuilder_ == null) { + ensureFrozenIsMutable(); + frozen_.add(builderForValue.build()); + onChanged(); + } else { + frozenBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder addFrozen( + int index, org.tron.protos.Protocol.Account.Frozen.Builder builderForValue) { + if (frozenBuilder_ == null) { + ensureFrozenIsMutable(); + frozen_.add(index, builderForValue.build()); + onChanged(); + } else { + frozenBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder addAllFrozen( + java.lang.Iterable values) { + if (frozenBuilder_ == null) { + ensureFrozenIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, frozen_); + onChanged(); + } else { + frozenBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder clearFrozen() { + if (frozenBuilder_ == null) { + frozen_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + onChanged(); + } else { + frozenBuilder_.clear(); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public Builder removeFrozen(int index) { + if (frozenBuilder_ == null) { + ensureFrozenIsMutable(); + frozen_.remove(index); + onChanged(); + } else { + frozenBuilder_.remove(index); + } + return this; + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public org.tron.protos.Protocol.Account.Frozen.Builder getFrozenBuilder( + int index) { + return getFrozenFieldBuilder().getBuilder(index); + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenOrBuilder( + int index) { + if (frozenBuilder_ == null) { + return frozen_.get(index); } else { + return frozenBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public java.util.List + getFrozenOrBuilderList() { + if (frozenBuilder_ != null) { + return frozenBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(frozen_); + } + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public org.tron.protos.Protocol.Account.Frozen.Builder addFrozenBuilder() { + return getFrozenFieldBuilder().addBuilder( + org.tron.protos.Protocol.Account.Frozen.getDefaultInstance()); + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public org.tron.protos.Protocol.Account.Frozen.Builder addFrozenBuilder( + int index) { + return getFrozenFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Account.Frozen.getDefaultInstance()); + } + /** + *
+       * the frozen balance for bandwidth
+       * 
+ * + * repeated .protocol.Account.Frozen frozen = 7; + */ + public java.util.List + getFrozenBuilderList() { + return getFrozenFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder> + getFrozenFieldBuilder() { + if (frozenBuilder_ == null) { + frozenBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder>( + frozen_, + ((bitField0_ & 0x00000080) == 0x00000080), + getParentForChildren(), + isClean()); + frozen_ = null; + } + return frozenBuilder_; + } + + private long netUsage_ ; + /** + *
+       * bandwidth, get from frozen
+       * 
+ * + * int64 net_usage = 8; + */ + public long getNetUsage() { + return netUsage_; + } + /** + *
+       * bandwidth, get from frozen
+       * 
+ * + * int64 net_usage = 8; + */ + public Builder setNetUsage(long value) { + + netUsage_ = value; + onChanged(); + return this; + } + /** + *
+       * bandwidth, get from frozen
+       * 
+ * + * int64 net_usage = 8; + */ + public Builder clearNetUsage() { + + netUsage_ = 0L; + onChanged(); + return this; + } + + private long acquiredDelegatedFrozenBalanceForBandwidth_ ; + /** + *
+       *Frozen balance provided by other accounts to this account
+       * 
+ * + * int64 acquired_delegated_frozen_balance_for_bandwidth = 41; + */ + public long getAcquiredDelegatedFrozenBalanceForBandwidth() { + return acquiredDelegatedFrozenBalanceForBandwidth_; + } + /** + *
+       *Frozen balance provided by other accounts to this account
+       * 
+ * + * int64 acquired_delegated_frozen_balance_for_bandwidth = 41; + */ + public Builder setAcquiredDelegatedFrozenBalanceForBandwidth(long value) { + + acquiredDelegatedFrozenBalanceForBandwidth_ = value; + onChanged(); + return this; + } + /** + *
+       *Frozen balance provided by other accounts to this account
+       * 
+ * + * int64 acquired_delegated_frozen_balance_for_bandwidth = 41; + */ + public Builder clearAcquiredDelegatedFrozenBalanceForBandwidth() { + + acquiredDelegatedFrozenBalanceForBandwidth_ = 0L; + onChanged(); + return this; + } + + private long delegatedFrozenBalanceForBandwidth_ ; + /** + *
+       *Freeze and provide balances to other accounts
+       * 
+ * + * int64 delegated_frozen_balance_for_bandwidth = 42; + */ + public long getDelegatedFrozenBalanceForBandwidth() { + return delegatedFrozenBalanceForBandwidth_; + } + /** + *
+       *Freeze and provide balances to other accounts
+       * 
+ * + * int64 delegated_frozen_balance_for_bandwidth = 42; + */ + public Builder setDelegatedFrozenBalanceForBandwidth(long value) { + + delegatedFrozenBalanceForBandwidth_ = value; + onChanged(); + return this; + } + /** + *
+       *Freeze and provide balances to other accounts
+       * 
+ * + * int64 delegated_frozen_balance_for_bandwidth = 42; + */ + public Builder clearDelegatedFrozenBalanceForBandwidth() { + + delegatedFrozenBalanceForBandwidth_ = 0L; + onChanged(); + return this; + } + + private long createTime_ ; + /** + *
+       * this account create time
+       * 
+ * + * int64 create_time = 9; + */ + public long getCreateTime() { + return createTime_; + } + /** + *
+       * this account create time
+       * 
+ * + * int64 create_time = 9; + */ + public Builder setCreateTime(long value) { + + createTime_ = value; + onChanged(); + return this; + } + /** + *
+       * this account create time
+       * 
+ * + * int64 create_time = 9; + */ + public Builder clearCreateTime() { + + createTime_ = 0L; + onChanged(); + return this; + } + + private long latestOprationTime_ ; + /** + *
+       * this last operation time, including transfer, voting and so on. //FIXME fix grammar
+       * 
+ * + * int64 latest_opration_time = 10; + */ + public long getLatestOprationTime() { + return latestOprationTime_; + } + /** + *
+       * this last operation time, including transfer, voting and so on. //FIXME fix grammar
+       * 
+ * + * int64 latest_opration_time = 10; + */ + public Builder setLatestOprationTime(long value) { + + latestOprationTime_ = value; + onChanged(); + return this; + } + /** + *
+       * this last operation time, including transfer, voting and so on. //FIXME fix grammar
+       * 
+ * + * int64 latest_opration_time = 10; + */ + public Builder clearLatestOprationTime() { + + latestOprationTime_ = 0L; + onChanged(); + return this; + } + + private long allowance_ ; + /** + *
+       * witness block producing allowance
+       * 
+ * + * int64 allowance = 11; + */ + public long getAllowance() { + return allowance_; + } + /** + *
+       * witness block producing allowance
+       * 
+ * + * int64 allowance = 11; + */ + public Builder setAllowance(long value) { + + allowance_ = value; + onChanged(); + return this; + } + /** + *
+       * witness block producing allowance
+       * 
+ * + * int64 allowance = 11; + */ + public Builder clearAllowance() { + + allowance_ = 0L; + onChanged(); + return this; + } + + private long latestWithdrawTime_ ; + /** + *
+       * last withdraw time
+       * 
+ * + * int64 latest_withdraw_time = 12; + */ + public long getLatestWithdrawTime() { + return latestWithdrawTime_; + } + /** + *
+       * last withdraw time
+       * 
+ * + * int64 latest_withdraw_time = 12; + */ + public Builder setLatestWithdrawTime(long value) { + + latestWithdrawTime_ = value; + onChanged(); + return this; + } + /** + *
+       * last withdraw time
+       * 
+ * + * int64 latest_withdraw_time = 12; + */ + public Builder clearLatestWithdrawTime() { + + latestWithdrawTime_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString code_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * not used so far
+       * 
+ * + * bytes code = 13; + */ + public com.google.protobuf.ByteString getCode() { + return code_; + } + /** + *
+       * not used so far
+       * 
+ * + * bytes code = 13; + */ + public Builder setCode(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + code_ = value; + onChanged(); + return this; + } + /** + *
+       * not used so far
+       * 
+ * + * bytes code = 13; + */ + public Builder clearCode() { + + code_ = getDefaultInstance().getCode(); + onChanged(); + return this; + } + + private boolean isWitness_ ; + /** + * bool is_witness = 14; + */ + public boolean getIsWitness() { + return isWitness_; + } + /** + * bool is_witness = 14; + */ + public Builder setIsWitness(boolean value) { + + isWitness_ = value; + onChanged(); + return this; + } + /** + * bool is_witness = 14; + */ + public Builder clearIsWitness() { + + isWitness_ = false; + onChanged(); + return this; + } + + private boolean isCommittee_ ; + /** + * bool is_committee = 15; + */ + public boolean getIsCommittee() { + return isCommittee_; + } + /** + * bool is_committee = 15; + */ + public Builder setIsCommittee(boolean value) { + + isCommittee_ = value; + onChanged(); + return this; + } + /** + * bool is_committee = 15; + */ + public Builder clearIsCommittee() { + + isCommittee_ = false; + onChanged(); + return this; + } + + private java.util.List frozenSupply_ = + java.util.Collections.emptyList(); + private void ensureFrozenSupplyIsMutable() { + if (!((bitField0_ & 0x00040000) == 0x00040000)) { + frozenSupply_ = new java.util.ArrayList(frozenSupply_); + bitField0_ |= 0x00040000; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder> frozenSupplyBuilder_; + + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public java.util.List getFrozenSupplyList() { + if (frozenSupplyBuilder_ == null) { + return java.util.Collections.unmodifiableList(frozenSupply_); + } else { + return frozenSupplyBuilder_.getMessageList(); + } + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public int getFrozenSupplyCount() { + if (frozenSupplyBuilder_ == null) { + return frozenSupply_.size(); + } else { + return frozenSupplyBuilder_.getCount(); + } + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public org.tron.protos.Protocol.Account.Frozen getFrozenSupply(int index) { + if (frozenSupplyBuilder_ == null) { + return frozenSupply_.get(index); + } else { + return frozenSupplyBuilder_.getMessage(index); + } + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder setFrozenSupply( + int index, org.tron.protos.Protocol.Account.Frozen value) { + if (frozenSupplyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenSupplyIsMutable(); + frozenSupply_.set(index, value); + onChanged(); + } else { + frozenSupplyBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder setFrozenSupply( + int index, org.tron.protos.Protocol.Account.Frozen.Builder builderForValue) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.set(index, builderForValue.build()); + onChanged(); + } else { + frozenSupplyBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder addFrozenSupply(org.tron.protos.Protocol.Account.Frozen value) { + if (frozenSupplyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(value); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder addFrozenSupply( + int index, org.tron.protos.Protocol.Account.Frozen value) { + if (frozenSupplyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(index, value); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder addFrozenSupply( + org.tron.protos.Protocol.Account.Frozen.Builder builderForValue) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(builderForValue.build()); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder addFrozenSupply( + int index, org.tron.protos.Protocol.Account.Frozen.Builder builderForValue) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.add(index, builderForValue.build()); + onChanged(); + } else { + frozenSupplyBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder addAllFrozenSupply( + java.lang.Iterable values) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, frozenSupply_); + onChanged(); + } else { + frozenSupplyBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder clearFrozenSupply() { + if (frozenSupplyBuilder_ == null) { + frozenSupply_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00040000); + onChanged(); + } else { + frozenSupplyBuilder_.clear(); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public Builder removeFrozenSupply(int index) { + if (frozenSupplyBuilder_ == null) { + ensureFrozenSupplyIsMutable(); + frozenSupply_.remove(index); + onChanged(); + } else { + frozenSupplyBuilder_.remove(index); + } + return this; + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public org.tron.protos.Protocol.Account.Frozen.Builder getFrozenSupplyBuilder( + int index) { + return getFrozenSupplyFieldBuilder().getBuilder(index); + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public org.tron.protos.Protocol.Account.FrozenOrBuilder getFrozenSupplyOrBuilder( + int index) { + if (frozenSupplyBuilder_ == null) { + return frozenSupply_.get(index); } else { + return frozenSupplyBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public java.util.List + getFrozenSupplyOrBuilderList() { + if (frozenSupplyBuilder_ != null) { + return frozenSupplyBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(frozenSupply_); + } + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public org.tron.protos.Protocol.Account.Frozen.Builder addFrozenSupplyBuilder() { + return getFrozenSupplyFieldBuilder().addBuilder( + org.tron.protos.Protocol.Account.Frozen.getDefaultInstance()); + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public org.tron.protos.Protocol.Account.Frozen.Builder addFrozenSupplyBuilder( + int index) { + return getFrozenSupplyFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Account.Frozen.getDefaultInstance()); + } + /** + *
+       * frozen asset(for asset issuer)
+       * 
+ * + * repeated .protocol.Account.Frozen frozen_supply = 16; + */ + public java.util.List + getFrozenSupplyBuilderList() { + return getFrozenSupplyFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder> + getFrozenSupplyFieldBuilder() { + if (frozenSupplyBuilder_ == null) { + frozenSupplyBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Account.Frozen, org.tron.protos.Protocol.Account.Frozen.Builder, org.tron.protos.Protocol.Account.FrozenOrBuilder>( + frozenSupply_, + ((bitField0_ & 0x00040000) == 0x00040000), + getParentForChildren(), + isClean()); + frozenSupply_ = null; + } + return frozenSupplyBuilder_; + } + + private com.google.protobuf.ByteString assetIssuedName_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * asset_issued_name
+       * 
+ * + * bytes asset_issued_name = 17; + */ + public com.google.protobuf.ByteString getAssetIssuedName() { + return assetIssuedName_; + } + /** + *
+       * asset_issued_name
+       * 
+ * + * bytes asset_issued_name = 17; + */ + public Builder setAssetIssuedName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + assetIssuedName_ = value; + onChanged(); + return this; + } + /** + *
+       * asset_issued_name
+       * 
+ * + * bytes asset_issued_name = 17; + */ + public Builder clearAssetIssuedName() { + + assetIssuedName_ = getDefaultInstance().getAssetIssuedName(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString assetIssuedID_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes asset_issued_ID = 57; + */ + public com.google.protobuf.ByteString getAssetIssuedID() { + return assetIssuedID_; + } + /** + * bytes asset_issued_ID = 57; + */ + public Builder setAssetIssuedID(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + assetIssuedID_ = value; + onChanged(); + return this; + } + /** + * bytes asset_issued_ID = 57; + */ + public Builder clearAssetIssuedID() { + + assetIssuedID_ = getDefaultInstance().getAssetIssuedID(); + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> latestAssetOperationTime_; + private com.google.protobuf.MapField + internalGetLatestAssetOperationTime() { + if (latestAssetOperationTime_ == null) { + return com.google.protobuf.MapField.emptyMapField( + LatestAssetOperationTimeDefaultEntryHolder.defaultEntry); + } + return latestAssetOperationTime_; + } + private com.google.protobuf.MapField + internalGetMutableLatestAssetOperationTime() { + onChanged();; + if (latestAssetOperationTime_ == null) { + latestAssetOperationTime_ = com.google.protobuf.MapField.newMapField( + LatestAssetOperationTimeDefaultEntryHolder.defaultEntry); + } + if (!latestAssetOperationTime_.isMutable()) { + latestAssetOperationTime_ = latestAssetOperationTime_.copy(); + } + return latestAssetOperationTime_; + } + + public int getLatestAssetOperationTimeCount() { + return internalGetLatestAssetOperationTime().getMap().size(); + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public boolean containsLatestAssetOperationTime( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetLatestAssetOperationTime().getMap().containsKey(key); + } + /** + * Use {@link #getLatestAssetOperationTimeMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getLatestAssetOperationTime() { + return getLatestAssetOperationTimeMap(); + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public java.util.Map getLatestAssetOperationTimeMap() { + return internalGetLatestAssetOperationTime().getMap(); + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public long getLatestAssetOperationTimeOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTime().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public long getLatestAssetOperationTimeOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTime().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearLatestAssetOperationTime() { + internalGetMutableLatestAssetOperationTime().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public Builder removeLatestAssetOperationTime( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableLatestAssetOperationTime().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableLatestAssetOperationTime() { + return internalGetMutableLatestAssetOperationTime().getMutableMap(); + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + public Builder putLatestAssetOperationTime( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableLatestAssetOperationTime().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> latest_asset_operation_time = 18; + */ + + public Builder putAllLatestAssetOperationTime( + java.util.Map values) { + internalGetMutableLatestAssetOperationTime().getMutableMap() + .putAll(values); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> latestAssetOperationTimeV2_; + private com.google.protobuf.MapField + internalGetLatestAssetOperationTimeV2() { + if (latestAssetOperationTimeV2_ == null) { + return com.google.protobuf.MapField.emptyMapField( + LatestAssetOperationTimeV2DefaultEntryHolder.defaultEntry); + } + return latestAssetOperationTimeV2_; + } + private com.google.protobuf.MapField + internalGetMutableLatestAssetOperationTimeV2() { + onChanged();; + if (latestAssetOperationTimeV2_ == null) { + latestAssetOperationTimeV2_ = com.google.protobuf.MapField.newMapField( + LatestAssetOperationTimeV2DefaultEntryHolder.defaultEntry); + } + if (!latestAssetOperationTimeV2_.isMutable()) { + latestAssetOperationTimeV2_ = latestAssetOperationTimeV2_.copy(); + } + return latestAssetOperationTimeV2_; + } + + public int getLatestAssetOperationTimeV2Count() { + return internalGetLatestAssetOperationTimeV2().getMap().size(); + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public boolean containsLatestAssetOperationTimeV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetLatestAssetOperationTimeV2().getMap().containsKey(key); + } + /** + * Use {@link #getLatestAssetOperationTimeV2Map()} instead. + */ + @java.lang.Deprecated + public java.util.Map getLatestAssetOperationTimeV2() { + return getLatestAssetOperationTimeV2Map(); + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public java.util.Map getLatestAssetOperationTimeV2Map() { + return internalGetLatestAssetOperationTimeV2().getMap(); + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public long getLatestAssetOperationTimeV2OrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTimeV2().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public long getLatestAssetOperationTimeV2OrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetLatestAssetOperationTimeV2().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearLatestAssetOperationTimeV2() { + internalGetMutableLatestAssetOperationTimeV2().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public Builder removeLatestAssetOperationTimeV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableLatestAssetOperationTimeV2().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableLatestAssetOperationTimeV2() { + return internalGetMutableLatestAssetOperationTimeV2().getMutableMap(); + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + public Builder putLatestAssetOperationTimeV2( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableLatestAssetOperationTimeV2().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> latest_asset_operation_timeV2 = 58; + */ + + public Builder putAllLatestAssetOperationTimeV2( + java.util.Map values) { + internalGetMutableLatestAssetOperationTimeV2().getMutableMap() + .putAll(values); + return this; + } + + private long freeNetUsage_ ; + /** + * int64 free_net_usage = 19; + */ + public long getFreeNetUsage() { + return freeNetUsage_; + } + /** + * int64 free_net_usage = 19; + */ + public Builder setFreeNetUsage(long value) { + + freeNetUsage_ = value; + onChanged(); + return this; + } + /** + * int64 free_net_usage = 19; + */ + public Builder clearFreeNetUsage() { + + freeNetUsage_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> freeAssetNetUsage_; + private com.google.protobuf.MapField + internalGetFreeAssetNetUsage() { + if (freeAssetNetUsage_ == null) { + return com.google.protobuf.MapField.emptyMapField( + FreeAssetNetUsageDefaultEntryHolder.defaultEntry); + } + return freeAssetNetUsage_; + } + private com.google.protobuf.MapField + internalGetMutableFreeAssetNetUsage() { + onChanged();; + if (freeAssetNetUsage_ == null) { + freeAssetNetUsage_ = com.google.protobuf.MapField.newMapField( + FreeAssetNetUsageDefaultEntryHolder.defaultEntry); + } + if (!freeAssetNetUsage_.isMutable()) { + freeAssetNetUsage_ = freeAssetNetUsage_.copy(); + } + return freeAssetNetUsage_; + } + + public int getFreeAssetNetUsageCount() { + return internalGetFreeAssetNetUsage().getMap().size(); + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public boolean containsFreeAssetNetUsage( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetFreeAssetNetUsage().getMap().containsKey(key); + } + /** + * Use {@link #getFreeAssetNetUsageMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getFreeAssetNetUsage() { + return getFreeAssetNetUsageMap(); + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public java.util.Map getFreeAssetNetUsageMap() { + return internalGetFreeAssetNetUsage().getMap(); + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public long getFreeAssetNetUsageOrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsage().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public long getFreeAssetNetUsageOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsage().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearFreeAssetNetUsage() { + internalGetMutableFreeAssetNetUsage().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public Builder removeFreeAssetNetUsage( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableFreeAssetNetUsage().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableFreeAssetNetUsage() { + return internalGetMutableFreeAssetNetUsage().getMutableMap(); + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + public Builder putFreeAssetNetUsage( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableFreeAssetNetUsage().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> free_asset_net_usage = 20; + */ + + public Builder putAllFreeAssetNetUsage( + java.util.Map values) { + internalGetMutableFreeAssetNetUsage().getMutableMap() + .putAll(values); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.Long> freeAssetNetUsageV2_; + private com.google.protobuf.MapField + internalGetFreeAssetNetUsageV2() { + if (freeAssetNetUsageV2_ == null) { + return com.google.protobuf.MapField.emptyMapField( + FreeAssetNetUsageV2DefaultEntryHolder.defaultEntry); + } + return freeAssetNetUsageV2_; + } + private com.google.protobuf.MapField + internalGetMutableFreeAssetNetUsageV2() { + onChanged();; + if (freeAssetNetUsageV2_ == null) { + freeAssetNetUsageV2_ = com.google.protobuf.MapField.newMapField( + FreeAssetNetUsageV2DefaultEntryHolder.defaultEntry); + } + if (!freeAssetNetUsageV2_.isMutable()) { + freeAssetNetUsageV2_ = freeAssetNetUsageV2_.copy(); + } + return freeAssetNetUsageV2_; + } + + public int getFreeAssetNetUsageV2Count() { + return internalGetFreeAssetNetUsageV2().getMap().size(); + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public boolean containsFreeAssetNetUsageV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetFreeAssetNetUsageV2().getMap().containsKey(key); + } + /** + * Use {@link #getFreeAssetNetUsageV2Map()} instead. + */ + @java.lang.Deprecated + public java.util.Map getFreeAssetNetUsageV2() { + return getFreeAssetNetUsageV2Map(); + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public java.util.Map getFreeAssetNetUsageV2Map() { + return internalGetFreeAssetNetUsageV2().getMap(); + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public long getFreeAssetNetUsageV2OrDefault( + java.lang.String key, + long defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsageV2().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public long getFreeAssetNetUsageV2OrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetFreeAssetNetUsageV2().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearFreeAssetNetUsageV2() { + internalGetMutableFreeAssetNetUsageV2().getMutableMap() + .clear(); + return this; + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public Builder removeFreeAssetNetUsageV2( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableFreeAssetNetUsageV2().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableFreeAssetNetUsageV2() { + return internalGetMutableFreeAssetNetUsageV2().getMutableMap(); + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + public Builder putFreeAssetNetUsageV2( + java.lang.String key, + long value) { + if (key == null) { throw new java.lang.NullPointerException(); } + + internalGetMutableFreeAssetNetUsageV2().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, int64> free_asset_net_usageV2 = 59; + */ + + public Builder putAllFreeAssetNetUsageV2( + java.util.Map values) { + internalGetMutableFreeAssetNetUsageV2().getMutableMap() + .putAll(values); + return this; + } + + private long latestConsumeTime_ ; + /** + * int64 latest_consume_time = 21; + */ + public long getLatestConsumeTime() { + return latestConsumeTime_; + } + /** + * int64 latest_consume_time = 21; + */ + public Builder setLatestConsumeTime(long value) { + + latestConsumeTime_ = value; + onChanged(); + return this; + } + /** + * int64 latest_consume_time = 21; + */ + public Builder clearLatestConsumeTime() { + + latestConsumeTime_ = 0L; + onChanged(); + return this; + } + + private long latestConsumeFreeTime_ ; + /** + * int64 latest_consume_free_time = 22; + */ + public long getLatestConsumeFreeTime() { + return latestConsumeFreeTime_; + } + /** + * int64 latest_consume_free_time = 22; + */ + public Builder setLatestConsumeFreeTime(long value) { + + latestConsumeFreeTime_ = value; + onChanged(); + return this; + } + /** + * int64 latest_consume_free_time = 22; + */ + public Builder clearLatestConsumeFreeTime() { + + latestConsumeFreeTime_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString accountId_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * the identity of this account, case insensitive
+       * 
+ * + * bytes account_id = 23; + */ + public com.google.protobuf.ByteString getAccountId() { + return accountId_; + } + /** + *
+       * the identity of this account, case insensitive
+       * 
+ * + * bytes account_id = 23; + */ + public Builder setAccountId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + accountId_ = value; + onChanged(); + return this; + } + /** + *
+       * the identity of this account, case insensitive
+       * 
+ * + * bytes account_id = 23; + */ + public Builder clearAccountId() { + + accountId_ = getDefaultInstance().getAccountId(); + onChanged(); + return this; + } + + private org.tron.protos.Protocol.Account.AccountResource accountResource_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account.AccountResource, org.tron.protos.Protocol.Account.AccountResource.Builder, org.tron.protos.Protocol.Account.AccountResourceOrBuilder> accountResourceBuilder_; + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public boolean hasAccountResource() { + return accountResourceBuilder_ != null || accountResource_ != null; + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public org.tron.protos.Protocol.Account.AccountResource getAccountResource() { + if (accountResourceBuilder_ == null) { + return accountResource_ == null ? org.tron.protos.Protocol.Account.AccountResource.getDefaultInstance() : accountResource_; + } else { + return accountResourceBuilder_.getMessage(); + } + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public Builder setAccountResource(org.tron.protos.Protocol.Account.AccountResource value) { + if (accountResourceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + accountResource_ = value; + onChanged(); + } else { + accountResourceBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public Builder setAccountResource( + org.tron.protos.Protocol.Account.AccountResource.Builder builderForValue) { + if (accountResourceBuilder_ == null) { + accountResource_ = builderForValue.build(); + onChanged(); + } else { + accountResourceBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public Builder mergeAccountResource(org.tron.protos.Protocol.Account.AccountResource value) { + if (accountResourceBuilder_ == null) { + if (accountResource_ != null) { + accountResource_ = + org.tron.protos.Protocol.Account.AccountResource.newBuilder(accountResource_).mergeFrom(value).buildPartial(); + } else { + accountResource_ = value; + } + onChanged(); + } else { + accountResourceBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public Builder clearAccountResource() { + if (accountResourceBuilder_ == null) { + accountResource_ = null; + onChanged(); + } else { + accountResource_ = null; + accountResourceBuilder_ = null; + } + + return this; + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public org.tron.protos.Protocol.Account.AccountResource.Builder getAccountResourceBuilder() { + + onChanged(); + return getAccountResourceFieldBuilder().getBuilder(); + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + public org.tron.protos.Protocol.Account.AccountResourceOrBuilder getAccountResourceOrBuilder() { + if (accountResourceBuilder_ != null) { + return accountResourceBuilder_.getMessageOrBuilder(); + } else { + return accountResource_ == null ? + org.tron.protos.Protocol.Account.AccountResource.getDefaultInstance() : accountResource_; + } + } + /** + * .protocol.Account.AccountResource account_resource = 26; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account.AccountResource, org.tron.protos.Protocol.Account.AccountResource.Builder, org.tron.protos.Protocol.Account.AccountResourceOrBuilder> + getAccountResourceFieldBuilder() { + if (accountResourceBuilder_ == null) { + accountResourceBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Account.AccountResource, org.tron.protos.Protocol.Account.AccountResource.Builder, org.tron.protos.Protocol.Account.AccountResourceOrBuilder>( + getAccountResource(), + getParentForChildren(), + isClean()); + accountResource_ = null; + } + return accountResourceBuilder_; + } + + private com.google.protobuf.ByteString codeHash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes codeHash = 30; + */ + public com.google.protobuf.ByteString getCodeHash() { + return codeHash_; + } + /** + * bytes codeHash = 30; + */ + public Builder setCodeHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + codeHash_ = value; + onChanged(); + return this; + } + /** + * bytes codeHash = 30; + */ + public Builder clearCodeHash() { + + codeHash_ = getDefaultInstance().getCodeHash(); + onChanged(); + return this; + } + + private org.tron.protos.Protocol.Permission ownerPermission_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> ownerPermissionBuilder_; + /** + * .protocol.Permission owner_permission = 31; + */ + public boolean hasOwnerPermission() { + return ownerPermissionBuilder_ != null || ownerPermission_ != null; + } + /** + * .protocol.Permission owner_permission = 31; + */ + public org.tron.protos.Protocol.Permission getOwnerPermission() { + if (ownerPermissionBuilder_ == null) { + return ownerPermission_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : ownerPermission_; + } else { + return ownerPermissionBuilder_.getMessage(); + } + } + /** + * .protocol.Permission owner_permission = 31; + */ + public Builder setOwnerPermission(org.tron.protos.Protocol.Permission value) { + if (ownerPermissionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ownerPermission_ = value; + onChanged(); + } else { + ownerPermissionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Permission owner_permission = 31; + */ + public Builder setOwnerPermission( + org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (ownerPermissionBuilder_ == null) { + ownerPermission_ = builderForValue.build(); + onChanged(); + } else { + ownerPermissionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Permission owner_permission = 31; + */ + public Builder mergeOwnerPermission(org.tron.protos.Protocol.Permission value) { + if (ownerPermissionBuilder_ == null) { + if (ownerPermission_ != null) { + ownerPermission_ = + org.tron.protos.Protocol.Permission.newBuilder(ownerPermission_).mergeFrom(value).buildPartial(); + } else { + ownerPermission_ = value; + } + onChanged(); + } else { + ownerPermissionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Permission owner_permission = 31; + */ + public Builder clearOwnerPermission() { + if (ownerPermissionBuilder_ == null) { + ownerPermission_ = null; + onChanged(); + } else { + ownerPermission_ = null; + ownerPermissionBuilder_ = null; + } + + return this; + } + /** + * .protocol.Permission owner_permission = 31; + */ + public org.tron.protos.Protocol.Permission.Builder getOwnerPermissionBuilder() { + + onChanged(); + return getOwnerPermissionFieldBuilder().getBuilder(); + } + /** + * .protocol.Permission owner_permission = 31; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getOwnerPermissionOrBuilder() { + if (ownerPermissionBuilder_ != null) { + return ownerPermissionBuilder_.getMessageOrBuilder(); + } else { + return ownerPermission_ == null ? + org.tron.protos.Protocol.Permission.getDefaultInstance() : ownerPermission_; + } + } + /** + * .protocol.Permission owner_permission = 31; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> + getOwnerPermissionFieldBuilder() { + if (ownerPermissionBuilder_ == null) { + ownerPermissionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder>( + getOwnerPermission(), + getParentForChildren(), + isClean()); + ownerPermission_ = null; + } + return ownerPermissionBuilder_; + } + + private org.tron.protos.Protocol.Permission witnessPermission_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> witnessPermissionBuilder_; + /** + * .protocol.Permission witness_permission = 32; + */ + public boolean hasWitnessPermission() { + return witnessPermissionBuilder_ != null || witnessPermission_ != null; + } + /** + * .protocol.Permission witness_permission = 32; + */ + public org.tron.protos.Protocol.Permission getWitnessPermission() { + if (witnessPermissionBuilder_ == null) { + return witnessPermission_ == null ? org.tron.protos.Protocol.Permission.getDefaultInstance() : witnessPermission_; + } else { + return witnessPermissionBuilder_.getMessage(); + } + } + /** + * .protocol.Permission witness_permission = 32; + */ + public Builder setWitnessPermission(org.tron.protos.Protocol.Permission value) { + if (witnessPermissionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + witnessPermission_ = value; + onChanged(); + } else { + witnessPermissionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Permission witness_permission = 32; + */ + public Builder setWitnessPermission( + org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (witnessPermissionBuilder_ == null) { + witnessPermission_ = builderForValue.build(); + onChanged(); + } else { + witnessPermissionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Permission witness_permission = 32; + */ + public Builder mergeWitnessPermission(org.tron.protos.Protocol.Permission value) { + if (witnessPermissionBuilder_ == null) { + if (witnessPermission_ != null) { + witnessPermission_ = + org.tron.protos.Protocol.Permission.newBuilder(witnessPermission_).mergeFrom(value).buildPartial(); + } else { + witnessPermission_ = value; + } + onChanged(); + } else { + witnessPermissionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Permission witness_permission = 32; + */ + public Builder clearWitnessPermission() { + if (witnessPermissionBuilder_ == null) { + witnessPermission_ = null; + onChanged(); + } else { + witnessPermission_ = null; + witnessPermissionBuilder_ = null; + } + + return this; + } + /** + * .protocol.Permission witness_permission = 32; + */ + public org.tron.protos.Protocol.Permission.Builder getWitnessPermissionBuilder() { + + onChanged(); + return getWitnessPermissionFieldBuilder().getBuilder(); + } + /** + * .protocol.Permission witness_permission = 32; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getWitnessPermissionOrBuilder() { + if (witnessPermissionBuilder_ != null) { + return witnessPermissionBuilder_.getMessageOrBuilder(); + } else { + return witnessPermission_ == null ? + org.tron.protos.Protocol.Permission.getDefaultInstance() : witnessPermission_; + } + } + /** + * .protocol.Permission witness_permission = 32; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> + getWitnessPermissionFieldBuilder() { + if (witnessPermissionBuilder_ == null) { + witnessPermissionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder>( + getWitnessPermission(), + getParentForChildren(), + isClean()); + witnessPermission_ = null; + } + return witnessPermissionBuilder_; + } + + private java.util.List activePermission_ = + java.util.Collections.emptyList(); + private void ensureActivePermissionIsMutable() { + if (!((bitField1_ & 0x00000002) == 0x00000002)) { + activePermission_ = new java.util.ArrayList(activePermission_); + bitField1_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> activePermissionBuilder_; + + /** + * repeated .protocol.Permission active_permission = 33; + */ + public java.util.List getActivePermissionList() { + if (activePermissionBuilder_ == null) { + return java.util.Collections.unmodifiableList(activePermission_); + } else { + return activePermissionBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public int getActivePermissionCount() { + if (activePermissionBuilder_ == null) { + return activePermission_.size(); + } else { + return activePermissionBuilder_.getCount(); + } + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public org.tron.protos.Protocol.Permission getActivePermission(int index) { + if (activePermissionBuilder_ == null) { + return activePermission_.get(index); + } else { + return activePermissionBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder setActivePermission( + int index, org.tron.protos.Protocol.Permission value) { + if (activePermissionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActivePermissionIsMutable(); + activePermission_.set(index, value); + onChanged(); + } else { + activePermissionBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder setActivePermission( + int index, org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (activePermissionBuilder_ == null) { + ensureActivePermissionIsMutable(); + activePermission_.set(index, builderForValue.build()); + onChanged(); + } else { + activePermissionBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder addActivePermission(org.tron.protos.Protocol.Permission value) { + if (activePermissionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActivePermissionIsMutable(); + activePermission_.add(value); + onChanged(); + } else { + activePermissionBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder addActivePermission( + int index, org.tron.protos.Protocol.Permission value) { + if (activePermissionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActivePermissionIsMutable(); + activePermission_.add(index, value); + onChanged(); + } else { + activePermissionBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder addActivePermission( + org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (activePermissionBuilder_ == null) { + ensureActivePermissionIsMutable(); + activePermission_.add(builderForValue.build()); + onChanged(); + } else { + activePermissionBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder addActivePermission( + int index, org.tron.protos.Protocol.Permission.Builder builderForValue) { + if (activePermissionBuilder_ == null) { + ensureActivePermissionIsMutable(); + activePermission_.add(index, builderForValue.build()); + onChanged(); + } else { + activePermissionBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder addAllActivePermission( + java.lang.Iterable values) { + if (activePermissionBuilder_ == null) { + ensureActivePermissionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, activePermission_); + onChanged(); + } else { + activePermissionBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder clearActivePermission() { + if (activePermissionBuilder_ == null) { + activePermission_ = java.util.Collections.emptyList(); + bitField1_ = (bitField1_ & ~0x00000002); + onChanged(); + } else { + activePermissionBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public Builder removeActivePermission(int index) { + if (activePermissionBuilder_ == null) { + ensureActivePermissionIsMutable(); + activePermission_.remove(index); + onChanged(); + } else { + activePermissionBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public org.tron.protos.Protocol.Permission.Builder getActivePermissionBuilder( + int index) { + return getActivePermissionFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public org.tron.protos.Protocol.PermissionOrBuilder getActivePermissionOrBuilder( + int index) { + if (activePermissionBuilder_ == null) { + return activePermission_.get(index); } else { + return activePermissionBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public java.util.List + getActivePermissionOrBuilderList() { + if (activePermissionBuilder_ != null) { + return activePermissionBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(activePermission_); + } + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public org.tron.protos.Protocol.Permission.Builder addActivePermissionBuilder() { + return getActivePermissionFieldBuilder().addBuilder( + org.tron.protos.Protocol.Permission.getDefaultInstance()); + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public org.tron.protos.Protocol.Permission.Builder addActivePermissionBuilder( + int index) { + return getActivePermissionFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Permission.getDefaultInstance()); + } + /** + * repeated .protocol.Permission active_permission = 33; + */ + public java.util.List + getActivePermissionBuilderList() { + return getActivePermissionFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder> + getActivePermissionFieldBuilder() { + if (activePermissionBuilder_ == null) { + activePermissionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Permission, org.tron.protos.Protocol.Permission.Builder, org.tron.protos.Protocol.PermissionOrBuilder>( + activePermission_, + ((bitField1_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + activePermission_ = null; + } + return activePermissionBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Account) + } + + // @@protoc_insertion_point(class_scope:protocol.Account) + private static final org.tron.protos.Protocol.Account DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Account(); + } + + public static org.tron.protos.Protocol.Account getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Account parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Account(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Account getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface KeyOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Key) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes address = 1; + */ + com.google.protobuf.ByteString getAddress(); + + /** + * int64 weight = 2; + */ + long getWeight(); + } + /** + * Protobuf type {@code protocol.Key} + */ + public static final class Key extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Key) + KeyOrBuilder { + private static final long serialVersionUID = 0L; + // Use Key.newBuilder() to construct. + private Key(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Key() { + address_ = com.google.protobuf.ByteString.EMPTY; + weight_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Key( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + address_ = input.readBytes(); + break; + } + case 16: { + + weight_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Key_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Key_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Key.class, org.tron.protos.Protocol.Key.Builder.class); + } + + public static final int ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString address_; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + + public static final int WEIGHT_FIELD_NUMBER = 2; + private long weight_; + /** + * int64 weight = 2; + */ + public long getWeight() { + return weight_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!address_.isEmpty()) { + output.writeBytes(1, address_); + } + if (weight_ != 0L) { + output.writeInt64(2, weight_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!address_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, address_); + } + if (weight_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, weight_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Key)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Key other = (org.tron.protos.Protocol.Key) obj; + + boolean result = true; + result = result && getAddress() + .equals(other.getAddress()); + result = result && (getWeight() + == other.getWeight()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + hash = (37 * hash) + WEIGHT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getWeight()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Key parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Key parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Key parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Key parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Key parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Key parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Key parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Key parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Key parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Key parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Key parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Key parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Key prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Key} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Key) + org.tron.protos.Protocol.KeyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Key_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Key_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Key.class, org.tron.protos.Protocol.Key.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Key.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + address_ = com.google.protobuf.ByteString.EMPTY; + + weight_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Key_descriptor; + } + + public org.tron.protos.Protocol.Key getDefaultInstanceForType() { + return org.tron.protos.Protocol.Key.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Key build() { + org.tron.protos.Protocol.Key result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Key buildPartial() { + org.tron.protos.Protocol.Key result = new org.tron.protos.Protocol.Key(this); + result.address_ = address_; + result.weight_ = weight_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Key) { + return mergeFrom((org.tron.protos.Protocol.Key)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Key other) { + if (other == org.tron.protos.Protocol.Key.getDefaultInstance()) return this; + if (other.getAddress() != com.google.protobuf.ByteString.EMPTY) { + setAddress(other.getAddress()); + } + if (other.getWeight() != 0L) { + setWeight(other.getWeight()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Key parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Key) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString address_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + /** + * bytes address = 1; + */ + public Builder setAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + * bytes address = 1; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + + private long weight_ ; + /** + * int64 weight = 2; + */ + public long getWeight() { + return weight_; + } + /** + * int64 weight = 2; + */ + public Builder setWeight(long value) { + + weight_ = value; + onChanged(); + return this; + } + /** + * int64 weight = 2; + */ + public Builder clearWeight() { + + weight_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Key) + } + + // @@protoc_insertion_point(class_scope:protocol.Key) + private static final org.tron.protos.Protocol.Key DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Key(); + } + + public static org.tron.protos.Protocol.Key getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Key parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Key(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Key getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DelegatedResourceOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.DelegatedResource) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes from = 1; + */ + com.google.protobuf.ByteString getFrom(); + + /** + * bytes to = 2; + */ + com.google.protobuf.ByteString getTo(); + + /** + * int64 frozen_balance_for_bandwidth = 3; + */ + long getFrozenBalanceForBandwidth(); + + /** + * int64 frozen_balance_for_energy = 4; + */ + long getFrozenBalanceForEnergy(); + + /** + * int64 expire_time_for_bandwidth = 5; + */ + long getExpireTimeForBandwidth(); + + /** + * int64 expire_time_for_energy = 6; + */ + long getExpireTimeForEnergy(); + } + /** + * Protobuf type {@code protocol.DelegatedResource} + */ + public static final class DelegatedResource extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.DelegatedResource) + DelegatedResourceOrBuilder { + private static final long serialVersionUID = 0L; + // Use DelegatedResource.newBuilder() to construct. + private DelegatedResource(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DelegatedResource() { + from_ = com.google.protobuf.ByteString.EMPTY; + to_ = com.google.protobuf.ByteString.EMPTY; + frozenBalanceForBandwidth_ = 0L; + frozenBalanceForEnergy_ = 0L; + expireTimeForBandwidth_ = 0L; + expireTimeForEnergy_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DelegatedResource( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + from_ = input.readBytes(); + break; + } + case 18: { + + to_ = input.readBytes(); + break; + } + case 24: { + + frozenBalanceForBandwidth_ = input.readInt64(); + break; + } + case 32: { + + frozenBalanceForEnergy_ = input.readInt64(); + break; + } + case 40: { + + expireTimeForBandwidth_ = input.readInt64(); + break; + } + case 48: { + + expireTimeForEnergy_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResource_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DelegatedResource.class, org.tron.protos.Protocol.DelegatedResource.Builder.class); + } + + public static final int FROM_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString from_; + /** + * bytes from = 1; + */ + public com.google.protobuf.ByteString getFrom() { + return from_; + } + + public static final int TO_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString to_; + /** + * bytes to = 2; + */ + public com.google.protobuf.ByteString getTo() { + return to_; + } + + public static final int FROZEN_BALANCE_FOR_BANDWIDTH_FIELD_NUMBER = 3; + private long frozenBalanceForBandwidth_; + /** + * int64 frozen_balance_for_bandwidth = 3; + */ + public long getFrozenBalanceForBandwidth() { + return frozenBalanceForBandwidth_; + } + + public static final int FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER = 4; + private long frozenBalanceForEnergy_; + /** + * int64 frozen_balance_for_energy = 4; + */ + public long getFrozenBalanceForEnergy() { + return frozenBalanceForEnergy_; + } + + public static final int EXPIRE_TIME_FOR_BANDWIDTH_FIELD_NUMBER = 5; + private long expireTimeForBandwidth_; + /** + * int64 expire_time_for_bandwidth = 5; + */ + public long getExpireTimeForBandwidth() { + return expireTimeForBandwidth_; + } + + public static final int EXPIRE_TIME_FOR_ENERGY_FIELD_NUMBER = 6; + private long expireTimeForEnergy_; + /** + * int64 expire_time_for_energy = 6; + */ + public long getExpireTimeForEnergy() { + return expireTimeForEnergy_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!from_.isEmpty()) { + output.writeBytes(1, from_); + } + if (!to_.isEmpty()) { + output.writeBytes(2, to_); + } + if (frozenBalanceForBandwidth_ != 0L) { + output.writeInt64(3, frozenBalanceForBandwidth_); + } + if (frozenBalanceForEnergy_ != 0L) { + output.writeInt64(4, frozenBalanceForEnergy_); + } + if (expireTimeForBandwidth_ != 0L) { + output.writeInt64(5, expireTimeForBandwidth_); + } + if (expireTimeForEnergy_ != 0L) { + output.writeInt64(6, expireTimeForEnergy_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!from_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, from_); + } + if (!to_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, to_); + } + if (frozenBalanceForBandwidth_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, frozenBalanceForBandwidth_); + } + if (frozenBalanceForEnergy_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, frozenBalanceForEnergy_); + } + if (expireTimeForBandwidth_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, expireTimeForBandwidth_); + } + if (expireTimeForEnergy_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, expireTimeForEnergy_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.DelegatedResource)) { + return super.equals(obj); + } + org.tron.protos.Protocol.DelegatedResource other = (org.tron.protos.Protocol.DelegatedResource) obj; + + boolean result = true; + result = result && getFrom() + .equals(other.getFrom()); + result = result && getTo() + .equals(other.getTo()); + result = result && (getFrozenBalanceForBandwidth() + == other.getFrozenBalanceForBandwidth()); + result = result && (getFrozenBalanceForEnergy() + == other.getFrozenBalanceForEnergy()); + result = result && (getExpireTimeForBandwidth() + == other.getExpireTimeForBandwidth()); + result = result && (getExpireTimeForEnergy() + == other.getExpireTimeForEnergy()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFrom().hashCode(); + hash = (37 * hash) + TO_FIELD_NUMBER; + hash = (53 * hash) + getTo().hashCode(); + hash = (37 * hash) + FROZEN_BALANCE_FOR_BANDWIDTH_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFrozenBalanceForBandwidth()); + hash = (37 * hash) + FROZEN_BALANCE_FOR_ENERGY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFrozenBalanceForEnergy()); + hash = (37 * hash) + EXPIRE_TIME_FOR_BANDWIDTH_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExpireTimeForBandwidth()); + hash = (37 * hash) + EXPIRE_TIME_FOR_ENERGY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExpireTimeForEnergy()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResource parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DelegatedResource parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DelegatedResource parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.DelegatedResource prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.DelegatedResource} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.DelegatedResource) + org.tron.protos.Protocol.DelegatedResourceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResource_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DelegatedResource.class, org.tron.protos.Protocol.DelegatedResource.Builder.class); + } + + // Construct using org.tron.protos.Protocol.DelegatedResource.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + from_ = com.google.protobuf.ByteString.EMPTY; + + to_ = com.google.protobuf.ByteString.EMPTY; + + frozenBalanceForBandwidth_ = 0L; + + frozenBalanceForEnergy_ = 0L; + + expireTimeForBandwidth_ = 0L; + + expireTimeForEnergy_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResource_descriptor; + } + + public org.tron.protos.Protocol.DelegatedResource getDefaultInstanceForType() { + return org.tron.protos.Protocol.DelegatedResource.getDefaultInstance(); + } + + public org.tron.protos.Protocol.DelegatedResource build() { + org.tron.protos.Protocol.DelegatedResource result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.DelegatedResource buildPartial() { + org.tron.protos.Protocol.DelegatedResource result = new org.tron.protos.Protocol.DelegatedResource(this); + result.from_ = from_; + result.to_ = to_; + result.frozenBalanceForBandwidth_ = frozenBalanceForBandwidth_; + result.frozenBalanceForEnergy_ = frozenBalanceForEnergy_; + result.expireTimeForBandwidth_ = expireTimeForBandwidth_; + result.expireTimeForEnergy_ = expireTimeForEnergy_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.DelegatedResource) { + return mergeFrom((org.tron.protos.Protocol.DelegatedResource)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.DelegatedResource other) { + if (other == org.tron.protos.Protocol.DelegatedResource.getDefaultInstance()) return this; + if (other.getFrom() != com.google.protobuf.ByteString.EMPTY) { + setFrom(other.getFrom()); + } + if (other.getTo() != com.google.protobuf.ByteString.EMPTY) { + setTo(other.getTo()); + } + if (other.getFrozenBalanceForBandwidth() != 0L) { + setFrozenBalanceForBandwidth(other.getFrozenBalanceForBandwidth()); + } + if (other.getFrozenBalanceForEnergy() != 0L) { + setFrozenBalanceForEnergy(other.getFrozenBalanceForEnergy()); + } + if (other.getExpireTimeForBandwidth() != 0L) { + setExpireTimeForBandwidth(other.getExpireTimeForBandwidth()); + } + if (other.getExpireTimeForEnergy() != 0L) { + setExpireTimeForEnergy(other.getExpireTimeForEnergy()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.DelegatedResource parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.DelegatedResource) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString from_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes from = 1; + */ + public com.google.protobuf.ByteString getFrom() { + return from_; + } + /** + * bytes from = 1; + */ + public Builder setFrom(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + from_ = value; + onChanged(); + return this; + } + /** + * bytes from = 1; + */ + public Builder clearFrom() { + + from_ = getDefaultInstance().getFrom(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString to_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes to = 2; + */ + public com.google.protobuf.ByteString getTo() { + return to_; + } + /** + * bytes to = 2; + */ + public Builder setTo(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + to_ = value; + onChanged(); + return this; + } + /** + * bytes to = 2; + */ + public Builder clearTo() { + + to_ = getDefaultInstance().getTo(); + onChanged(); + return this; + } + + private long frozenBalanceForBandwidth_ ; + /** + * int64 frozen_balance_for_bandwidth = 3; + */ + public long getFrozenBalanceForBandwidth() { + return frozenBalanceForBandwidth_; + } + /** + * int64 frozen_balance_for_bandwidth = 3; + */ + public Builder setFrozenBalanceForBandwidth(long value) { + + frozenBalanceForBandwidth_ = value; + onChanged(); + return this; + } + /** + * int64 frozen_balance_for_bandwidth = 3; + */ + public Builder clearFrozenBalanceForBandwidth() { + + frozenBalanceForBandwidth_ = 0L; + onChanged(); + return this; + } + + private long frozenBalanceForEnergy_ ; + /** + * int64 frozen_balance_for_energy = 4; + */ + public long getFrozenBalanceForEnergy() { + return frozenBalanceForEnergy_; + } + /** + * int64 frozen_balance_for_energy = 4; + */ + public Builder setFrozenBalanceForEnergy(long value) { + + frozenBalanceForEnergy_ = value; + onChanged(); + return this; + } + /** + * int64 frozen_balance_for_energy = 4; + */ + public Builder clearFrozenBalanceForEnergy() { + + frozenBalanceForEnergy_ = 0L; + onChanged(); + return this; + } + + private long expireTimeForBandwidth_ ; + /** + * int64 expire_time_for_bandwidth = 5; + */ + public long getExpireTimeForBandwidth() { + return expireTimeForBandwidth_; + } + /** + * int64 expire_time_for_bandwidth = 5; + */ + public Builder setExpireTimeForBandwidth(long value) { + + expireTimeForBandwidth_ = value; + onChanged(); + return this; + } + /** + * int64 expire_time_for_bandwidth = 5; + */ + public Builder clearExpireTimeForBandwidth() { + + expireTimeForBandwidth_ = 0L; + onChanged(); + return this; + } + + private long expireTimeForEnergy_ ; + /** + * int64 expire_time_for_energy = 6; + */ + public long getExpireTimeForEnergy() { + return expireTimeForEnergy_; + } + /** + * int64 expire_time_for_energy = 6; + */ + public Builder setExpireTimeForEnergy(long value) { + + expireTimeForEnergy_ = value; + onChanged(); + return this; + } + /** + * int64 expire_time_for_energy = 6; + */ + public Builder clearExpireTimeForEnergy() { + + expireTimeForEnergy_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.DelegatedResource) + } + + // @@protoc_insertion_point(class_scope:protocol.DelegatedResource) + private static final org.tron.protos.Protocol.DelegatedResource DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.DelegatedResource(); + } + + public static org.tron.protos.Protocol.DelegatedResource getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DelegatedResource parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DelegatedResource(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.DelegatedResource getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface authorityOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.authority) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.AccountId account = 1; + */ + boolean hasAccount(); + /** + * .protocol.AccountId account = 1; + */ + org.tron.protos.Protocol.AccountId getAccount(); + /** + * .protocol.AccountId account = 1; + */ + org.tron.protos.Protocol.AccountIdOrBuilder getAccountOrBuilder(); + + /** + * bytes permission_name = 2; + */ + com.google.protobuf.ByteString getPermissionName(); + } + /** + * Protobuf type {@code protocol.authority} + */ + public static final class authority extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.authority) + authorityOrBuilder { + private static final long serialVersionUID = 0L; + // Use authority.newBuilder() to construct. + private authority(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private authority() { + permissionName_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private authority( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.AccountId.Builder subBuilder = null; + if (account_ != null) { + subBuilder = account_.toBuilder(); + } + account_ = input.readMessage(org.tron.protos.Protocol.AccountId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(account_); + account_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + + permissionName_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_authority_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_authority_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.authority.class, org.tron.protos.Protocol.authority.Builder.class); + } + + public static final int ACCOUNT_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.AccountId account_; + /** + * .protocol.AccountId account = 1; + */ + public boolean hasAccount() { + return account_ != null; + } + /** + * .protocol.AccountId account = 1; + */ + public org.tron.protos.Protocol.AccountId getAccount() { + return account_ == null ? org.tron.protos.Protocol.AccountId.getDefaultInstance() : account_; + } + /** + * .protocol.AccountId account = 1; + */ + public org.tron.protos.Protocol.AccountIdOrBuilder getAccountOrBuilder() { + return getAccount(); + } + + public static final int PERMISSION_NAME_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString permissionName_; + /** + * bytes permission_name = 2; + */ + public com.google.protobuf.ByteString getPermissionName() { + return permissionName_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (account_ != null) { + output.writeMessage(1, getAccount()); + } + if (!permissionName_.isEmpty()) { + output.writeBytes(2, permissionName_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (account_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getAccount()); + } + if (!permissionName_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, permissionName_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.authority)) { + return super.equals(obj); + } + org.tron.protos.Protocol.authority other = (org.tron.protos.Protocol.authority) obj; + + boolean result = true; + result = result && (hasAccount() == other.hasAccount()); + if (hasAccount()) { + result = result && getAccount() + .equals(other.getAccount()); + } + result = result && getPermissionName() + .equals(other.getPermissionName()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasAccount()) { + hash = (37 * hash) + ACCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getAccount().hashCode(); + } + hash = (37 * hash) + PERMISSION_NAME_FIELD_NUMBER; + hash = (53 * hash) + getPermissionName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.authority parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.authority parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.authority parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.authority parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.authority parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.authority parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.authority parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.authority parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.authority parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.authority parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.authority parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.authority parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.authority prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.authority} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.authority) + org.tron.protos.Protocol.authorityOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_authority_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_authority_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.authority.class, org.tron.protos.Protocol.authority.Builder.class); + } + + // Construct using org.tron.protos.Protocol.authority.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (accountBuilder_ == null) { + account_ = null; + } else { + account_ = null; + accountBuilder_ = null; + } + permissionName_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_authority_descriptor; + } + + public org.tron.protos.Protocol.authority getDefaultInstanceForType() { + return org.tron.protos.Protocol.authority.getDefaultInstance(); + } + + public org.tron.protos.Protocol.authority build() { + org.tron.protos.Protocol.authority result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.authority buildPartial() { + org.tron.protos.Protocol.authority result = new org.tron.protos.Protocol.authority(this); + if (accountBuilder_ == null) { + result.account_ = account_; + } else { + result.account_ = accountBuilder_.build(); + } + result.permissionName_ = permissionName_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.authority) { + return mergeFrom((org.tron.protos.Protocol.authority)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.authority other) { + if (other == org.tron.protos.Protocol.authority.getDefaultInstance()) return this; + if (other.hasAccount()) { + mergeAccount(other.getAccount()); + } + if (other.getPermissionName() != com.google.protobuf.ByteString.EMPTY) { + setPermissionName(other.getPermissionName()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.authority parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.authority) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Protocol.AccountId account_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.AccountId, org.tron.protos.Protocol.AccountId.Builder, org.tron.protos.Protocol.AccountIdOrBuilder> accountBuilder_; + /** + * .protocol.AccountId account = 1; + */ + public boolean hasAccount() { + return accountBuilder_ != null || account_ != null; + } + /** + * .protocol.AccountId account = 1; + */ + public org.tron.protos.Protocol.AccountId getAccount() { + if (accountBuilder_ == null) { + return account_ == null ? org.tron.protos.Protocol.AccountId.getDefaultInstance() : account_; + } else { + return accountBuilder_.getMessage(); + } + } + /** + * .protocol.AccountId account = 1; + */ + public Builder setAccount(org.tron.protos.Protocol.AccountId value) { + if (accountBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + account_ = value; + onChanged(); + } else { + accountBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.AccountId account = 1; + */ + public Builder setAccount( + org.tron.protos.Protocol.AccountId.Builder builderForValue) { + if (accountBuilder_ == null) { + account_ = builderForValue.build(); + onChanged(); + } else { + accountBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.AccountId account = 1; + */ + public Builder mergeAccount(org.tron.protos.Protocol.AccountId value) { + if (accountBuilder_ == null) { + if (account_ != null) { + account_ = + org.tron.protos.Protocol.AccountId.newBuilder(account_).mergeFrom(value).buildPartial(); + } else { + account_ = value; + } + onChanged(); + } else { + accountBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.AccountId account = 1; + */ + public Builder clearAccount() { + if (accountBuilder_ == null) { + account_ = null; + onChanged(); + } else { + account_ = null; + accountBuilder_ = null; + } + + return this; + } + /** + * .protocol.AccountId account = 1; + */ + public org.tron.protos.Protocol.AccountId.Builder getAccountBuilder() { + + onChanged(); + return getAccountFieldBuilder().getBuilder(); + } + /** + * .protocol.AccountId account = 1; + */ + public org.tron.protos.Protocol.AccountIdOrBuilder getAccountOrBuilder() { + if (accountBuilder_ != null) { + return accountBuilder_.getMessageOrBuilder(); + } else { + return account_ == null ? + org.tron.protos.Protocol.AccountId.getDefaultInstance() : account_; + } + } + /** + * .protocol.AccountId account = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.AccountId, org.tron.protos.Protocol.AccountId.Builder, org.tron.protos.Protocol.AccountIdOrBuilder> + getAccountFieldBuilder() { + if (accountBuilder_ == null) { + accountBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.AccountId, org.tron.protos.Protocol.AccountId.Builder, org.tron.protos.Protocol.AccountIdOrBuilder>( + getAccount(), + getParentForChildren(), + isClean()); + account_ = null; + } + return accountBuilder_; + } + + private com.google.protobuf.ByteString permissionName_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes permission_name = 2; + */ + public com.google.protobuf.ByteString getPermissionName() { + return permissionName_; + } + /** + * bytes permission_name = 2; + */ + public Builder setPermissionName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + permissionName_ = value; + onChanged(); + return this; + } + /** + * bytes permission_name = 2; + */ + public Builder clearPermissionName() { + + permissionName_ = getDefaultInstance().getPermissionName(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.authority) + } + + // @@protoc_insertion_point(class_scope:protocol.authority) + private static final org.tron.protos.Protocol.authority DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.authority(); + } + + public static org.tron.protos.Protocol.authority getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public authority parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new authority(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.authority getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface PermissionOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Permission) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Permission.PermissionType type = 1; + */ + int getTypeValue(); + /** + * .protocol.Permission.PermissionType type = 1; + */ + org.tron.protos.Protocol.Permission.PermissionType getType(); + + /** + *
+     *Owner id=0, Witness id=1, Active id start by 2
+     * 
+ * + * int32 id = 2; + */ + int getId(); + + /** + * string permission_name = 3; + */ + java.lang.String getPermissionName(); + /** + * string permission_name = 3; + */ + com.google.protobuf.ByteString + getPermissionNameBytes(); + + /** + * int64 threshold = 4; + */ + long getThreshold(); + + /** + * int32 parent_id = 5; + */ + int getParentId(); + + /** + *
+     *1 bit 1 contract
+     * 
+ * + * bytes operations = 6; + */ + com.google.protobuf.ByteString getOperations(); + + /** + * repeated .protocol.Key keys = 7; + */ + java.util.List + getKeysList(); + /** + * repeated .protocol.Key keys = 7; + */ + org.tron.protos.Protocol.Key getKeys(int index); + /** + * repeated .protocol.Key keys = 7; + */ + int getKeysCount(); + /** + * repeated .protocol.Key keys = 7; + */ + java.util.List + getKeysOrBuilderList(); + /** + * repeated .protocol.Key keys = 7; + */ + org.tron.protos.Protocol.KeyOrBuilder getKeysOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.Permission} + */ + public static final class Permission extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Permission) + PermissionOrBuilder { + private static final long serialVersionUID = 0L; + // Use Permission.newBuilder() to construct. + private Permission(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Permission() { + type_ = 0; + id_ = 0; + permissionName_ = ""; + threshold_ = 0L; + parentId_ = 0; + operations_ = com.google.protobuf.ByteString.EMPTY; + keys_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Permission( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 16: { + + id_ = input.readInt32(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + permissionName_ = s; + break; + } + case 32: { + + threshold_ = input.readInt64(); + break; + } + case 40: { + + parentId_ = input.readInt32(); + break; + } + case 50: { + + operations_ = input.readBytes(); + break; + } + case 58: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + keys_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + keys_.add( + input.readMessage(org.tron.protos.Protocol.Key.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + keys_ = java.util.Collections.unmodifiableList(keys_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Permission_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Permission_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Permission.class, org.tron.protos.Protocol.Permission.Builder.class); + } + + /** + * Protobuf enum {@code protocol.Permission.PermissionType} + */ + public enum PermissionType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * Owner = 0; + */ + Owner(0), + /** + * Witness = 1; + */ + Witness(1), + /** + * Active = 2; + */ + Active(2), + UNRECOGNIZED(-1), + ; + + /** + * Owner = 0; + */ + public static final int Owner_VALUE = 0; + /** + * Witness = 1; + */ + public static final int Witness_VALUE = 1; + /** + * Active = 2; + */ + public static final int Active_VALUE = 2; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static PermissionType valueOf(int value) { + return forNumber(value); + } + + public static PermissionType forNumber(int value) { + switch (value) { + case 0: return Owner; + case 1: return Witness; + case 2: return Active; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + PermissionType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public PermissionType findValueByNumber(int number) { + return PermissionType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.Permission.getDescriptor().getEnumTypes().get(0); + } + + private static final PermissionType[] VALUES = values(); + + public static PermissionType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private PermissionType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Permission.PermissionType) + } + + private int bitField0_; + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + * .protocol.Permission.PermissionType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Permission.PermissionType type = 1; + */ + public org.tron.protos.Protocol.Permission.PermissionType getType() { + org.tron.protos.Protocol.Permission.PermissionType result = org.tron.protos.Protocol.Permission.PermissionType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Permission.PermissionType.UNRECOGNIZED : result; + } + + public static final int ID_FIELD_NUMBER = 2; + private int id_; + /** + *
+     *Owner id=0, Witness id=1, Active id start by 2
+     * 
+ * + * int32 id = 2; + */ + public int getId() { + return id_; + } + + public static final int PERMISSION_NAME_FIELD_NUMBER = 3; + private volatile java.lang.Object permissionName_; + /** + * string permission_name = 3; + */ + public java.lang.String getPermissionName() { + java.lang.Object ref = permissionName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + permissionName_ = s; + return s; + } + } + /** + * string permission_name = 3; + */ + public com.google.protobuf.ByteString + getPermissionNameBytes() { + java.lang.Object ref = permissionName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + permissionName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int THRESHOLD_FIELD_NUMBER = 4; + private long threshold_; + /** + * int64 threshold = 4; + */ + public long getThreshold() { + return threshold_; + } + + public static final int PARENT_ID_FIELD_NUMBER = 5; + private int parentId_; + /** + * int32 parent_id = 5; + */ + public int getParentId() { + return parentId_; + } + + public static final int OPERATIONS_FIELD_NUMBER = 6; + private com.google.protobuf.ByteString operations_; + /** + *
+     *1 bit 1 contract
+     * 
+ * + * bytes operations = 6; + */ + public com.google.protobuf.ByteString getOperations() { + return operations_; + } + + public static final int KEYS_FIELD_NUMBER = 7; + private java.util.List keys_; + /** + * repeated .protocol.Key keys = 7; + */ + public java.util.List getKeysList() { + return keys_; + } + /** + * repeated .protocol.Key keys = 7; + */ + public java.util.List + getKeysOrBuilderList() { + return keys_; + } + /** + * repeated .protocol.Key keys = 7; + */ + public int getKeysCount() { + return keys_.size(); + } + /** + * repeated .protocol.Key keys = 7; + */ + public org.tron.protos.Protocol.Key getKeys(int index) { + return keys_.get(index); + } + /** + * repeated .protocol.Key keys = 7; + */ + public org.tron.protos.Protocol.KeyOrBuilder getKeysOrBuilder( + int index) { + return keys_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != org.tron.protos.Protocol.Permission.PermissionType.Owner.getNumber()) { + output.writeEnum(1, type_); + } + if (id_ != 0) { + output.writeInt32(2, id_); + } + if (!getPermissionNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, permissionName_); + } + if (threshold_ != 0L) { + output.writeInt64(4, threshold_); + } + if (parentId_ != 0) { + output.writeInt32(5, parentId_); + } + if (!operations_.isEmpty()) { + output.writeBytes(6, operations_); + } + for (int i = 0; i < keys_.size(); i++) { + output.writeMessage(7, keys_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != org.tron.protos.Protocol.Permission.PermissionType.Owner.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, type_); + } + if (id_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, id_); + } + if (!getPermissionNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, permissionName_); + } + if (threshold_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, threshold_); + } + if (parentId_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, parentId_); + } + if (!operations_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(6, operations_); + } + for (int i = 0; i < keys_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, keys_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Permission)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Permission other = (org.tron.protos.Protocol.Permission) obj; + + boolean result = true; + result = result && type_ == other.type_; + result = result && (getId() + == other.getId()); + result = result && getPermissionName() + .equals(other.getPermissionName()); + result = result && (getThreshold() + == other.getThreshold()); + result = result && (getParentId() + == other.getParentId()); + result = result && getOperations() + .equals(other.getOperations()); + result = result && getKeysList() + .equals(other.getKeysList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId(); + hash = (37 * hash) + PERMISSION_NAME_FIELD_NUMBER; + hash = (53 * hash) + getPermissionName().hashCode(); + hash = (37 * hash) + THRESHOLD_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getThreshold()); + hash = (37 * hash) + PARENT_ID_FIELD_NUMBER; + hash = (53 * hash) + getParentId(); + hash = (37 * hash) + OPERATIONS_FIELD_NUMBER; + hash = (53 * hash) + getOperations().hashCode(); + if (getKeysCount() > 0) { + hash = (37 * hash) + KEYS_FIELD_NUMBER; + hash = (53 * hash) + getKeysList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Permission parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Permission parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Permission parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Permission parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Permission parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Permission parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Permission parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Permission parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Permission parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Permission parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Permission parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Permission parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Permission prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Permission} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Permission) + org.tron.protos.Protocol.PermissionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Permission_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Permission_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Permission.class, org.tron.protos.Protocol.Permission.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Permission.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getKeysFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + type_ = 0; + + id_ = 0; + + permissionName_ = ""; + + threshold_ = 0L; + + parentId_ = 0; + + operations_ = com.google.protobuf.ByteString.EMPTY; + + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + } else { + keysBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Permission_descriptor; + } + + public org.tron.protos.Protocol.Permission getDefaultInstanceForType() { + return org.tron.protos.Protocol.Permission.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Permission build() { + org.tron.protos.Protocol.Permission result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Permission buildPartial() { + org.tron.protos.Protocol.Permission result = new org.tron.protos.Protocol.Permission(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.type_ = type_; + result.id_ = id_; + result.permissionName_ = permissionName_; + result.threshold_ = threshold_; + result.parentId_ = parentId_; + result.operations_ = operations_; + if (keysBuilder_ == null) { + if (((bitField0_ & 0x00000040) == 0x00000040)) { + keys_ = java.util.Collections.unmodifiableList(keys_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.keys_ = keys_; + } else { + result.keys_ = keysBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Permission) { + return mergeFrom((org.tron.protos.Protocol.Permission)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Permission other) { + if (other == org.tron.protos.Protocol.Permission.getDefaultInstance()) return this; + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.getId() != 0) { + setId(other.getId()); + } + if (!other.getPermissionName().isEmpty()) { + permissionName_ = other.permissionName_; + onChanged(); + } + if (other.getThreshold() != 0L) { + setThreshold(other.getThreshold()); + } + if (other.getParentId() != 0) { + setParentId(other.getParentId()); + } + if (other.getOperations() != com.google.protobuf.ByteString.EMPTY) { + setOperations(other.getOperations()); + } + if (keysBuilder_ == null) { + if (!other.keys_.isEmpty()) { + if (keys_.isEmpty()) { + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureKeysIsMutable(); + keys_.addAll(other.keys_); + } + onChanged(); + } + } else { + if (!other.keys_.isEmpty()) { + if (keysBuilder_.isEmpty()) { + keysBuilder_.dispose(); + keysBuilder_ = null; + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000040); + keysBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getKeysFieldBuilder() : null; + } else { + keysBuilder_.addAllMessages(other.keys_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Permission parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Permission) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int type_ = 0; + /** + * .protocol.Permission.PermissionType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Permission.PermissionType type = 1; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.Permission.PermissionType type = 1; + */ + public org.tron.protos.Protocol.Permission.PermissionType getType() { + org.tron.protos.Protocol.Permission.PermissionType result = org.tron.protos.Protocol.Permission.PermissionType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Permission.PermissionType.UNRECOGNIZED : result; + } + /** + * .protocol.Permission.PermissionType type = 1; + */ + public Builder setType(org.tron.protos.Protocol.Permission.PermissionType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Permission.PermissionType type = 1; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private int id_ ; + /** + *
+       *Owner id=0, Witness id=1, Active id start by 2
+       * 
+ * + * int32 id = 2; + */ + public int getId() { + return id_; + } + /** + *
+       *Owner id=0, Witness id=1, Active id start by 2
+       * 
+ * + * int32 id = 2; + */ + public Builder setId(int value) { + + id_ = value; + onChanged(); + return this; + } + /** + *
+       *Owner id=0, Witness id=1, Active id start by 2
+       * 
+ * + * int32 id = 2; + */ + public Builder clearId() { + + id_ = 0; + onChanged(); + return this; + } + + private java.lang.Object permissionName_ = ""; + /** + * string permission_name = 3; + */ + public java.lang.String getPermissionName() { + java.lang.Object ref = permissionName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + permissionName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string permission_name = 3; + */ + public com.google.protobuf.ByteString + getPermissionNameBytes() { + java.lang.Object ref = permissionName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + permissionName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string permission_name = 3; + */ + public Builder setPermissionName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + permissionName_ = value; + onChanged(); + return this; + } + /** + * string permission_name = 3; + */ + public Builder clearPermissionName() { + + permissionName_ = getDefaultInstance().getPermissionName(); + onChanged(); + return this; + } + /** + * string permission_name = 3; + */ + public Builder setPermissionNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + permissionName_ = value; + onChanged(); + return this; + } + + private long threshold_ ; + /** + * int64 threshold = 4; + */ + public long getThreshold() { + return threshold_; + } + /** + * int64 threshold = 4; + */ + public Builder setThreshold(long value) { + + threshold_ = value; + onChanged(); + return this; + } + /** + * int64 threshold = 4; + */ + public Builder clearThreshold() { + + threshold_ = 0L; + onChanged(); + return this; + } + + private int parentId_ ; + /** + * int32 parent_id = 5; + */ + public int getParentId() { + return parentId_; + } + /** + * int32 parent_id = 5; + */ + public Builder setParentId(int value) { + + parentId_ = value; + onChanged(); + return this; + } + /** + * int32 parent_id = 5; + */ + public Builder clearParentId() { + + parentId_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString operations_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       *1 bit 1 contract
+       * 
+ * + * bytes operations = 6; + */ + public com.google.protobuf.ByteString getOperations() { + return operations_; + } + /** + *
+       *1 bit 1 contract
+       * 
+ * + * bytes operations = 6; + */ + public Builder setOperations(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + operations_ = value; + onChanged(); + return this; + } + /** + *
+       *1 bit 1 contract
+       * 
+ * + * bytes operations = 6; + */ + public Builder clearOperations() { + + operations_ = getDefaultInstance().getOperations(); + onChanged(); + return this; + } + + private java.util.List keys_ = + java.util.Collections.emptyList(); + private void ensureKeysIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + keys_ = new java.util.ArrayList(keys_); + bitField0_ |= 0x00000040; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Key, org.tron.protos.Protocol.Key.Builder, org.tron.protos.Protocol.KeyOrBuilder> keysBuilder_; + + /** + * repeated .protocol.Key keys = 7; + */ + public java.util.List getKeysList() { + if (keysBuilder_ == null) { + return java.util.Collections.unmodifiableList(keys_); + } else { + return keysBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Key keys = 7; + */ + public int getKeysCount() { + if (keysBuilder_ == null) { + return keys_.size(); + } else { + return keysBuilder_.getCount(); + } + } + /** + * repeated .protocol.Key keys = 7; + */ + public org.tron.protos.Protocol.Key getKeys(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder setKeys( + int index, org.tron.protos.Protocol.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.set(index, value); + onChanged(); + } else { + keysBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder setKeys( + int index, org.tron.protos.Protocol.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.set(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder addKeys(org.tron.protos.Protocol.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(value); + onChanged(); + } else { + keysBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder addKeys( + int index, org.tron.protos.Protocol.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(index, value); + onChanged(); + } else { + keysBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder addKeys( + org.tron.protos.Protocol.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder addKeys( + int index, org.tron.protos.Protocol.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder addAllKeys( + java.lang.Iterable values) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, keys_); + onChanged(); + } else { + keysBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder clearKeys() { + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + } else { + keysBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public Builder removeKeys(int index) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.remove(index); + onChanged(); + } else { + keysBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Key keys = 7; + */ + public org.tron.protos.Protocol.Key.Builder getKeysBuilder( + int index) { + return getKeysFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Key keys = 7; + */ + public org.tron.protos.Protocol.KeyOrBuilder getKeysOrBuilder( + int index) { + if (keysBuilder_ == null) { + return keys_.get(index); } else { + return keysBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Key keys = 7; + */ + public java.util.List + getKeysOrBuilderList() { + if (keysBuilder_ != null) { + return keysBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(keys_); + } + } + /** + * repeated .protocol.Key keys = 7; + */ + public org.tron.protos.Protocol.Key.Builder addKeysBuilder() { + return getKeysFieldBuilder().addBuilder( + org.tron.protos.Protocol.Key.getDefaultInstance()); + } + /** + * repeated .protocol.Key keys = 7; + */ + public org.tron.protos.Protocol.Key.Builder addKeysBuilder( + int index) { + return getKeysFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Key.getDefaultInstance()); + } + /** + * repeated .protocol.Key keys = 7; + */ + public java.util.List + getKeysBuilderList() { + return getKeysFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Key, org.tron.protos.Protocol.Key.Builder, org.tron.protos.Protocol.KeyOrBuilder> + getKeysFieldBuilder() { + if (keysBuilder_ == null) { + keysBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Key, org.tron.protos.Protocol.Key.Builder, org.tron.protos.Protocol.KeyOrBuilder>( + keys_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + keys_ = null; + } + return keysBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Permission) + } + + // @@protoc_insertion_point(class_scope:protocol.Permission) + private static final org.tron.protos.Protocol.Permission DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Permission(); + } + + public static org.tron.protos.Protocol.Permission getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Permission parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Permission(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Permission getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface WitnessOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Witness) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes address = 1; + */ + com.google.protobuf.ByteString getAddress(); + + /** + * int64 voteCount = 2; + */ + long getVoteCount(); + + /** + * bytes pubKey = 3; + */ + com.google.protobuf.ByteString getPubKey(); + + /** + * string url = 4; + */ + java.lang.String getUrl(); + /** + * string url = 4; + */ + com.google.protobuf.ByteString + getUrlBytes(); + + /** + * int64 totalProduced = 5; + */ + long getTotalProduced(); + + /** + * int64 totalMissed = 6; + */ + long getTotalMissed(); + + /** + * int64 latestBlockNum = 7; + */ + long getLatestBlockNum(); + + /** + * int64 latestSlotNum = 8; + */ + long getLatestSlotNum(); + + /** + * bool isJobs = 9; + */ + boolean getIsJobs(); + } + /** + *
+   * Witness
+   * 
+ * + * Protobuf type {@code protocol.Witness} + */ + public static final class Witness extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Witness) + WitnessOrBuilder { + private static final long serialVersionUID = 0L; + // Use Witness.newBuilder() to construct. + private Witness(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Witness() { + address_ = com.google.protobuf.ByteString.EMPTY; + voteCount_ = 0L; + pubKey_ = com.google.protobuf.ByteString.EMPTY; + url_ = ""; + totalProduced_ = 0L; + totalMissed_ = 0L; + latestBlockNum_ = 0L; + latestSlotNum_ = 0L; + isJobs_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Witness( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + address_ = input.readBytes(); + break; + } + case 16: { + + voteCount_ = input.readInt64(); + break; + } + case 26: { + + pubKey_ = input.readBytes(); + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + case 40: { + + totalProduced_ = input.readInt64(); + break; + } + case 48: { + + totalMissed_ = input.readInt64(); + break; + } + case 56: { + + latestBlockNum_ = input.readInt64(); + break; + } + case 64: { + + latestSlotNum_ = input.readInt64(); + break; + } + case 72: { + + isJobs_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Witness_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Witness_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Witness.class, org.tron.protos.Protocol.Witness.Builder.class); + } + + public static final int ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString address_; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + + public static final int VOTECOUNT_FIELD_NUMBER = 2; + private long voteCount_; + /** + * int64 voteCount = 2; + */ + public long getVoteCount() { + return voteCount_; + } + + public static final int PUBKEY_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString pubKey_; + /** + * bytes pubKey = 3; + */ + public com.google.protobuf.ByteString getPubKey() { + return pubKey_; + } + + public static final int URL_FIELD_NUMBER = 4; + private volatile java.lang.Object url_; + /** + * string url = 4; + */ + public java.lang.String getUrl() { + java.lang.Object ref = url_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + java.lang.Object ref = url_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TOTALPRODUCED_FIELD_NUMBER = 5; + private long totalProduced_; + /** + * int64 totalProduced = 5; + */ + public long getTotalProduced() { + return totalProduced_; + } + + public static final int TOTALMISSED_FIELD_NUMBER = 6; + private long totalMissed_; + /** + * int64 totalMissed = 6; + */ + public long getTotalMissed() { + return totalMissed_; + } + + public static final int LATESTBLOCKNUM_FIELD_NUMBER = 7; + private long latestBlockNum_; + /** + * int64 latestBlockNum = 7; + */ + public long getLatestBlockNum() { + return latestBlockNum_; + } + + public static final int LATESTSLOTNUM_FIELD_NUMBER = 8; + private long latestSlotNum_; + /** + * int64 latestSlotNum = 8; + */ + public long getLatestSlotNum() { + return latestSlotNum_; + } + + public static final int ISJOBS_FIELD_NUMBER = 9; + private boolean isJobs_; + /** + * bool isJobs = 9; + */ + public boolean getIsJobs() { + return isJobs_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!address_.isEmpty()) { + output.writeBytes(1, address_); + } + if (voteCount_ != 0L) { + output.writeInt64(2, voteCount_); + } + if (!pubKey_.isEmpty()) { + output.writeBytes(3, pubKey_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_); + } + if (totalProduced_ != 0L) { + output.writeInt64(5, totalProduced_); + } + if (totalMissed_ != 0L) { + output.writeInt64(6, totalMissed_); + } + if (latestBlockNum_ != 0L) { + output.writeInt64(7, latestBlockNum_); + } + if (latestSlotNum_ != 0L) { + output.writeInt64(8, latestSlotNum_); + } + if (isJobs_ != false) { + output.writeBool(9, isJobs_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!address_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, address_); + } + if (voteCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, voteCount_); + } + if (!pubKey_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, pubKey_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_); + } + if (totalProduced_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, totalProduced_); + } + if (totalMissed_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, totalMissed_); + } + if (latestBlockNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, latestBlockNum_); + } + if (latestSlotNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, latestSlotNum_); + } + if (isJobs_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(9, isJobs_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Witness)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Witness other = (org.tron.protos.Protocol.Witness) obj; + + boolean result = true; + result = result && getAddress() + .equals(other.getAddress()); + result = result && (getVoteCount() + == other.getVoteCount()); + result = result && getPubKey() + .equals(other.getPubKey()); + result = result && getUrl() + .equals(other.getUrl()); + result = result && (getTotalProduced() + == other.getTotalProduced()); + result = result && (getTotalMissed() + == other.getTotalMissed()); + result = result && (getLatestBlockNum() + == other.getLatestBlockNum()); + result = result && (getLatestSlotNum() + == other.getLatestSlotNum()); + result = result && (getIsJobs() + == other.getIsJobs()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + hash = (37 * hash) + VOTECOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getVoteCount()); + hash = (37 * hash) + PUBKEY_FIELD_NUMBER; + hash = (53 * hash) + getPubKey().hashCode(); + hash = (37 * hash) + URL_FIELD_NUMBER; + hash = (53 * hash) + getUrl().hashCode(); + hash = (37 * hash) + TOTALPRODUCED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalProduced()); + hash = (37 * hash) + TOTALMISSED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalMissed()); + hash = (37 * hash) + LATESTBLOCKNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestBlockNum()); + hash = (37 * hash) + LATESTSLOTNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLatestSlotNum()); + hash = (37 * hash) + ISJOBS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIsJobs()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Witness parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Witness parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Witness parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Witness parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Witness parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Witness parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Witness parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Witness parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Witness parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Witness parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Witness parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Witness parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Witness prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Witness
+     * 
+ * + * Protobuf type {@code protocol.Witness} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Witness) + org.tron.protos.Protocol.WitnessOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Witness_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Witness_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Witness.class, org.tron.protos.Protocol.Witness.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Witness.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + address_ = com.google.protobuf.ByteString.EMPTY; + + voteCount_ = 0L; + + pubKey_ = com.google.protobuf.ByteString.EMPTY; + + url_ = ""; + + totalProduced_ = 0L; + + totalMissed_ = 0L; + + latestBlockNum_ = 0L; + + latestSlotNum_ = 0L; + + isJobs_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Witness_descriptor; + } + + public org.tron.protos.Protocol.Witness getDefaultInstanceForType() { + return org.tron.protos.Protocol.Witness.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Witness build() { + org.tron.protos.Protocol.Witness result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Witness buildPartial() { + org.tron.protos.Protocol.Witness result = new org.tron.protos.Protocol.Witness(this); + result.address_ = address_; + result.voteCount_ = voteCount_; + result.pubKey_ = pubKey_; + result.url_ = url_; + result.totalProduced_ = totalProduced_; + result.totalMissed_ = totalMissed_; + result.latestBlockNum_ = latestBlockNum_; + result.latestSlotNum_ = latestSlotNum_; + result.isJobs_ = isJobs_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Witness) { + return mergeFrom((org.tron.protos.Protocol.Witness)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Witness other) { + if (other == org.tron.protos.Protocol.Witness.getDefaultInstance()) return this; + if (other.getAddress() != com.google.protobuf.ByteString.EMPTY) { + setAddress(other.getAddress()); + } + if (other.getVoteCount() != 0L) { + setVoteCount(other.getVoteCount()); + } + if (other.getPubKey() != com.google.protobuf.ByteString.EMPTY) { + setPubKey(other.getPubKey()); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + if (other.getTotalProduced() != 0L) { + setTotalProduced(other.getTotalProduced()); + } + if (other.getTotalMissed() != 0L) { + setTotalMissed(other.getTotalMissed()); + } + if (other.getLatestBlockNum() != 0L) { + setLatestBlockNum(other.getLatestBlockNum()); + } + if (other.getLatestSlotNum() != 0L) { + setLatestSlotNum(other.getLatestSlotNum()); + } + if (other.getIsJobs() != false) { + setIsJobs(other.getIsJobs()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Witness parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Witness) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString address_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + /** + * bytes address = 1; + */ + public Builder setAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + * bytes address = 1; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + + private long voteCount_ ; + /** + * int64 voteCount = 2; + */ + public long getVoteCount() { + return voteCount_; + } + /** + * int64 voteCount = 2; + */ + public Builder setVoteCount(long value) { + + voteCount_ = value; + onChanged(); + return this; + } + /** + * int64 voteCount = 2; + */ + public Builder clearVoteCount() { + + voteCount_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString pubKey_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes pubKey = 3; + */ + public com.google.protobuf.ByteString getPubKey() { + return pubKey_; + } + /** + * bytes pubKey = 3; + */ + public Builder setPubKey(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + pubKey_ = value; + onChanged(); + return this; + } + /** + * bytes pubKey = 3; + */ + public Builder clearPubKey() { + + pubKey_ = getDefaultInstance().getPubKey(); + onChanged(); + return this; + } + + private java.lang.Object url_ = ""; + /** + * string url = 4; + */ + public java.lang.String getUrl() { + java.lang.Object ref = url_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string url = 4; + */ + public com.google.protobuf.ByteString + getUrlBytes() { + java.lang.Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string url = 4; + */ + public Builder setUrl( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * string url = 4; + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + + private long totalProduced_ ; + /** + * int64 totalProduced = 5; + */ + public long getTotalProduced() { + return totalProduced_; + } + /** + * int64 totalProduced = 5; + */ + public Builder setTotalProduced(long value) { + + totalProduced_ = value; + onChanged(); + return this; + } + /** + * int64 totalProduced = 5; + */ + public Builder clearTotalProduced() { + + totalProduced_ = 0L; + onChanged(); + return this; + } + + private long totalMissed_ ; + /** + * int64 totalMissed = 6; + */ + public long getTotalMissed() { + return totalMissed_; + } + /** + * int64 totalMissed = 6; + */ + public Builder setTotalMissed(long value) { + + totalMissed_ = value; + onChanged(); + return this; + } + /** + * int64 totalMissed = 6; + */ + public Builder clearTotalMissed() { + + totalMissed_ = 0L; + onChanged(); + return this; + } + + private long latestBlockNum_ ; + /** + * int64 latestBlockNum = 7; + */ + public long getLatestBlockNum() { + return latestBlockNum_; + } + /** + * int64 latestBlockNum = 7; + */ + public Builder setLatestBlockNum(long value) { + + latestBlockNum_ = value; + onChanged(); + return this; + } + /** + * int64 latestBlockNum = 7; + */ + public Builder clearLatestBlockNum() { + + latestBlockNum_ = 0L; + onChanged(); + return this; + } + + private long latestSlotNum_ ; + /** + * int64 latestSlotNum = 8; + */ + public long getLatestSlotNum() { + return latestSlotNum_; + } + /** + * int64 latestSlotNum = 8; + */ + public Builder setLatestSlotNum(long value) { + + latestSlotNum_ = value; + onChanged(); + return this; + } + /** + * int64 latestSlotNum = 8; + */ + public Builder clearLatestSlotNum() { + + latestSlotNum_ = 0L; + onChanged(); + return this; + } + + private boolean isJobs_ ; + /** + * bool isJobs = 9; + */ + public boolean getIsJobs() { + return isJobs_; + } + /** + * bool isJobs = 9; + */ + public Builder setIsJobs(boolean value) { + + isJobs_ = value; + onChanged(); + return this; + } + /** + * bool isJobs = 9; + */ + public Builder clearIsJobs() { + + isJobs_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Witness) + } + + // @@protoc_insertion_point(class_scope:protocol.Witness) + private static final org.tron.protos.Protocol.Witness DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Witness(); + } + + public static org.tron.protos.Protocol.Witness getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Witness parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Witness(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Witness getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface VotesOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Votes) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes address = 1; + */ + com.google.protobuf.ByteString getAddress(); + + /** + * repeated .protocol.Vote old_votes = 2; + */ + java.util.List + getOldVotesList(); + /** + * repeated .protocol.Vote old_votes = 2; + */ + org.tron.protos.Protocol.Vote getOldVotes(int index); + /** + * repeated .protocol.Vote old_votes = 2; + */ + int getOldVotesCount(); + /** + * repeated .protocol.Vote old_votes = 2; + */ + java.util.List + getOldVotesOrBuilderList(); + /** + * repeated .protocol.Vote old_votes = 2; + */ + org.tron.protos.Protocol.VoteOrBuilder getOldVotesOrBuilder( + int index); + + /** + * repeated .protocol.Vote new_votes = 3; + */ + java.util.List + getNewVotesList(); + /** + * repeated .protocol.Vote new_votes = 3; + */ + org.tron.protos.Protocol.Vote getNewVotes(int index); + /** + * repeated .protocol.Vote new_votes = 3; + */ + int getNewVotesCount(); + /** + * repeated .protocol.Vote new_votes = 3; + */ + java.util.List + getNewVotesOrBuilderList(); + /** + * repeated .protocol.Vote new_votes = 3; + */ + org.tron.protos.Protocol.VoteOrBuilder getNewVotesOrBuilder( + int index); + } + /** + *
+   * Vote Change
+   * 
+ * + * Protobuf type {@code protocol.Votes} + */ + public static final class Votes extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Votes) + VotesOrBuilder { + private static final long serialVersionUID = 0L; + // Use Votes.newBuilder() to construct. + private Votes(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Votes() { + address_ = com.google.protobuf.ByteString.EMPTY; + oldVotes_ = java.util.Collections.emptyList(); + newVotes_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Votes( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + address_ = input.readBytes(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + oldVotes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + oldVotes_.add( + input.readMessage(org.tron.protos.Protocol.Vote.parser(), extensionRegistry)); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + newVotes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + newVotes_.add( + input.readMessage(org.tron.protos.Protocol.Vote.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + oldVotes_ = java.util.Collections.unmodifiableList(oldVotes_); + } + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + newVotes_ = java.util.Collections.unmodifiableList(newVotes_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Votes_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Votes_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Votes.class, org.tron.protos.Protocol.Votes.Builder.class); + } + + private int bitField0_; + public static final int ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString address_; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + + public static final int OLD_VOTES_FIELD_NUMBER = 2; + private java.util.List oldVotes_; + /** + * repeated .protocol.Vote old_votes = 2; + */ + public java.util.List getOldVotesList() { + return oldVotes_; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public java.util.List + getOldVotesOrBuilderList() { + return oldVotes_; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public int getOldVotesCount() { + return oldVotes_.size(); + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public org.tron.protos.Protocol.Vote getOldVotes(int index) { + return oldVotes_.get(index); + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public org.tron.protos.Protocol.VoteOrBuilder getOldVotesOrBuilder( + int index) { + return oldVotes_.get(index); + } + + public static final int NEW_VOTES_FIELD_NUMBER = 3; + private java.util.List newVotes_; + /** + * repeated .protocol.Vote new_votes = 3; + */ + public java.util.List getNewVotesList() { + return newVotes_; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public java.util.List + getNewVotesOrBuilderList() { + return newVotes_; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public int getNewVotesCount() { + return newVotes_.size(); + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public org.tron.protos.Protocol.Vote getNewVotes(int index) { + return newVotes_.get(index); + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public org.tron.protos.Protocol.VoteOrBuilder getNewVotesOrBuilder( + int index) { + return newVotes_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!address_.isEmpty()) { + output.writeBytes(1, address_); + } + for (int i = 0; i < oldVotes_.size(); i++) { + output.writeMessage(2, oldVotes_.get(i)); + } + for (int i = 0; i < newVotes_.size(); i++) { + output.writeMessage(3, newVotes_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!address_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, address_); + } + for (int i = 0; i < oldVotes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, oldVotes_.get(i)); + } + for (int i = 0; i < newVotes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, newVotes_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Votes)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Votes other = (org.tron.protos.Protocol.Votes) obj; + + boolean result = true; + result = result && getAddress() + .equals(other.getAddress()); + result = result && getOldVotesList() + .equals(other.getOldVotesList()); + result = result && getNewVotesList() + .equals(other.getNewVotesList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + if (getOldVotesCount() > 0) { + hash = (37 * hash) + OLD_VOTES_FIELD_NUMBER; + hash = (53 * hash) + getOldVotesList().hashCode(); + } + if (getNewVotesCount() > 0) { + hash = (37 * hash) + NEW_VOTES_FIELD_NUMBER; + hash = (53 * hash) + getNewVotesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Votes parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Votes parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Votes parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Votes parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Votes parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Votes parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Votes parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Votes parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Votes parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Votes parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Votes parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Votes parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Votes prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Vote Change
+     * 
+ * + * Protobuf type {@code protocol.Votes} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Votes) + org.tron.protos.Protocol.VotesOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Votes_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Votes_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Votes.class, org.tron.protos.Protocol.Votes.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Votes.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getOldVotesFieldBuilder(); + getNewVotesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + address_ = com.google.protobuf.ByteString.EMPTY; + + if (oldVotesBuilder_ == null) { + oldVotes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + oldVotesBuilder_.clear(); + } + if (newVotesBuilder_ == null) { + newVotes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + newVotesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Votes_descriptor; + } + + public org.tron.protos.Protocol.Votes getDefaultInstanceForType() { + return org.tron.protos.Protocol.Votes.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Votes build() { + org.tron.protos.Protocol.Votes result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Votes buildPartial() { + org.tron.protos.Protocol.Votes result = new org.tron.protos.Protocol.Votes(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.address_ = address_; + if (oldVotesBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + oldVotes_ = java.util.Collections.unmodifiableList(oldVotes_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.oldVotes_ = oldVotes_; + } else { + result.oldVotes_ = oldVotesBuilder_.build(); + } + if (newVotesBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + newVotes_ = java.util.Collections.unmodifiableList(newVotes_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.newVotes_ = newVotes_; + } else { + result.newVotes_ = newVotesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Votes) { + return mergeFrom((org.tron.protos.Protocol.Votes)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Votes other) { + if (other == org.tron.protos.Protocol.Votes.getDefaultInstance()) return this; + if (other.getAddress() != com.google.protobuf.ByteString.EMPTY) { + setAddress(other.getAddress()); + } + if (oldVotesBuilder_ == null) { + if (!other.oldVotes_.isEmpty()) { + if (oldVotes_.isEmpty()) { + oldVotes_ = other.oldVotes_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureOldVotesIsMutable(); + oldVotes_.addAll(other.oldVotes_); + } + onChanged(); + } + } else { + if (!other.oldVotes_.isEmpty()) { + if (oldVotesBuilder_.isEmpty()) { + oldVotesBuilder_.dispose(); + oldVotesBuilder_ = null; + oldVotes_ = other.oldVotes_; + bitField0_ = (bitField0_ & ~0x00000002); + oldVotesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getOldVotesFieldBuilder() : null; + } else { + oldVotesBuilder_.addAllMessages(other.oldVotes_); + } + } + } + if (newVotesBuilder_ == null) { + if (!other.newVotes_.isEmpty()) { + if (newVotes_.isEmpty()) { + newVotes_ = other.newVotes_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureNewVotesIsMutable(); + newVotes_.addAll(other.newVotes_); + } + onChanged(); + } + } else { + if (!other.newVotes_.isEmpty()) { + if (newVotesBuilder_.isEmpty()) { + newVotesBuilder_.dispose(); + newVotesBuilder_ = null; + newVotes_ = other.newVotes_; + bitField0_ = (bitField0_ & ~0x00000004); + newVotesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getNewVotesFieldBuilder() : null; + } else { + newVotesBuilder_.addAllMessages(other.newVotes_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Votes parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Votes) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString address_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + /** + * bytes address = 1; + */ + public Builder setAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + * bytes address = 1; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + + private java.util.List oldVotes_ = + java.util.Collections.emptyList(); + private void ensureOldVotesIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + oldVotes_ = new java.util.ArrayList(oldVotes_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder> oldVotesBuilder_; + + /** + * repeated .protocol.Vote old_votes = 2; + */ + public java.util.List getOldVotesList() { + if (oldVotesBuilder_ == null) { + return java.util.Collections.unmodifiableList(oldVotes_); + } else { + return oldVotesBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public int getOldVotesCount() { + if (oldVotesBuilder_ == null) { + return oldVotes_.size(); + } else { + return oldVotesBuilder_.getCount(); + } + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public org.tron.protos.Protocol.Vote getOldVotes(int index) { + if (oldVotesBuilder_ == null) { + return oldVotes_.get(index); + } else { + return oldVotesBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder setOldVotes( + int index, org.tron.protos.Protocol.Vote value) { + if (oldVotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOldVotesIsMutable(); + oldVotes_.set(index, value); + onChanged(); + } else { + oldVotesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder setOldVotes( + int index, org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (oldVotesBuilder_ == null) { + ensureOldVotesIsMutable(); + oldVotes_.set(index, builderForValue.build()); + onChanged(); + } else { + oldVotesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder addOldVotes(org.tron.protos.Protocol.Vote value) { + if (oldVotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOldVotesIsMutable(); + oldVotes_.add(value); + onChanged(); + } else { + oldVotesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder addOldVotes( + int index, org.tron.protos.Protocol.Vote value) { + if (oldVotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOldVotesIsMutable(); + oldVotes_.add(index, value); + onChanged(); + } else { + oldVotesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder addOldVotes( + org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (oldVotesBuilder_ == null) { + ensureOldVotesIsMutable(); + oldVotes_.add(builderForValue.build()); + onChanged(); + } else { + oldVotesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder addOldVotes( + int index, org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (oldVotesBuilder_ == null) { + ensureOldVotesIsMutable(); + oldVotes_.add(index, builderForValue.build()); + onChanged(); + } else { + oldVotesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder addAllOldVotes( + java.lang.Iterable values) { + if (oldVotesBuilder_ == null) { + ensureOldVotesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, oldVotes_); + onChanged(); + } else { + oldVotesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder clearOldVotes() { + if (oldVotesBuilder_ == null) { + oldVotes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + oldVotesBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public Builder removeOldVotes(int index) { + if (oldVotesBuilder_ == null) { + ensureOldVotesIsMutable(); + oldVotes_.remove(index); + onChanged(); + } else { + oldVotesBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public org.tron.protos.Protocol.Vote.Builder getOldVotesBuilder( + int index) { + return getOldVotesFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public org.tron.protos.Protocol.VoteOrBuilder getOldVotesOrBuilder( + int index) { + if (oldVotesBuilder_ == null) { + return oldVotes_.get(index); } else { + return oldVotesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public java.util.List + getOldVotesOrBuilderList() { + if (oldVotesBuilder_ != null) { + return oldVotesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(oldVotes_); + } + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public org.tron.protos.Protocol.Vote.Builder addOldVotesBuilder() { + return getOldVotesFieldBuilder().addBuilder( + org.tron.protos.Protocol.Vote.getDefaultInstance()); + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public org.tron.protos.Protocol.Vote.Builder addOldVotesBuilder( + int index) { + return getOldVotesFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Vote.getDefaultInstance()); + } + /** + * repeated .protocol.Vote old_votes = 2; + */ + public java.util.List + getOldVotesBuilderList() { + return getOldVotesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder> + getOldVotesFieldBuilder() { + if (oldVotesBuilder_ == null) { + oldVotesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder>( + oldVotes_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + oldVotes_ = null; + } + return oldVotesBuilder_; + } + + private java.util.List newVotes_ = + java.util.Collections.emptyList(); + private void ensureNewVotesIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + newVotes_ = new java.util.ArrayList(newVotes_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder> newVotesBuilder_; + + /** + * repeated .protocol.Vote new_votes = 3; + */ + public java.util.List getNewVotesList() { + if (newVotesBuilder_ == null) { + return java.util.Collections.unmodifiableList(newVotes_); + } else { + return newVotesBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public int getNewVotesCount() { + if (newVotesBuilder_ == null) { + return newVotes_.size(); + } else { + return newVotesBuilder_.getCount(); + } + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public org.tron.protos.Protocol.Vote getNewVotes(int index) { + if (newVotesBuilder_ == null) { + return newVotes_.get(index); + } else { + return newVotesBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder setNewVotes( + int index, org.tron.protos.Protocol.Vote value) { + if (newVotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNewVotesIsMutable(); + newVotes_.set(index, value); + onChanged(); + } else { + newVotesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder setNewVotes( + int index, org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (newVotesBuilder_ == null) { + ensureNewVotesIsMutable(); + newVotes_.set(index, builderForValue.build()); + onChanged(); + } else { + newVotesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder addNewVotes(org.tron.protos.Protocol.Vote value) { + if (newVotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNewVotesIsMutable(); + newVotes_.add(value); + onChanged(); + } else { + newVotesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder addNewVotes( + int index, org.tron.protos.Protocol.Vote value) { + if (newVotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNewVotesIsMutable(); + newVotes_.add(index, value); + onChanged(); + } else { + newVotesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder addNewVotes( + org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (newVotesBuilder_ == null) { + ensureNewVotesIsMutable(); + newVotes_.add(builderForValue.build()); + onChanged(); + } else { + newVotesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder addNewVotes( + int index, org.tron.protos.Protocol.Vote.Builder builderForValue) { + if (newVotesBuilder_ == null) { + ensureNewVotesIsMutable(); + newVotes_.add(index, builderForValue.build()); + onChanged(); + } else { + newVotesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder addAllNewVotes( + java.lang.Iterable values) { + if (newVotesBuilder_ == null) { + ensureNewVotesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, newVotes_); + onChanged(); + } else { + newVotesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder clearNewVotes() { + if (newVotesBuilder_ == null) { + newVotes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + newVotesBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public Builder removeNewVotes(int index) { + if (newVotesBuilder_ == null) { + ensureNewVotesIsMutable(); + newVotes_.remove(index); + onChanged(); + } else { + newVotesBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public org.tron.protos.Protocol.Vote.Builder getNewVotesBuilder( + int index) { + return getNewVotesFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public org.tron.protos.Protocol.VoteOrBuilder getNewVotesOrBuilder( + int index) { + if (newVotesBuilder_ == null) { + return newVotes_.get(index); } else { + return newVotesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public java.util.List + getNewVotesOrBuilderList() { + if (newVotesBuilder_ != null) { + return newVotesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(newVotes_); + } + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public org.tron.protos.Protocol.Vote.Builder addNewVotesBuilder() { + return getNewVotesFieldBuilder().addBuilder( + org.tron.protos.Protocol.Vote.getDefaultInstance()); + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public org.tron.protos.Protocol.Vote.Builder addNewVotesBuilder( + int index) { + return getNewVotesFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Vote.getDefaultInstance()); + } + /** + * repeated .protocol.Vote new_votes = 3; + */ + public java.util.List + getNewVotesBuilderList() { + return getNewVotesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder> + getNewVotesFieldBuilder() { + if (newVotesBuilder_ == null) { + newVotesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Vote, org.tron.protos.Protocol.Vote.Builder, org.tron.protos.Protocol.VoteOrBuilder>( + newVotes_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + newVotes_ = null; + } + return newVotesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Votes) + } + + // @@protoc_insertion_point(class_scope:protocol.Votes) + private static final org.tron.protos.Protocol.Votes DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Votes(); + } + + public static org.tron.protos.Protocol.Votes getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Votes parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Votes(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Votes getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TXOutputOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TXOutput) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 value = 1; + */ + long getValue(); + + /** + * bytes pubKeyHash = 2; + */ + com.google.protobuf.ByteString getPubKeyHash(); + } + /** + * Protobuf type {@code protocol.TXOutput} + */ + public static final class TXOutput extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TXOutput) + TXOutputOrBuilder { + private static final long serialVersionUID = 0L; + // Use TXOutput.newBuilder() to construct. + private TXOutput(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TXOutput() { + value_ = 0L; + pubKeyHash_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TXOutput( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + value_ = input.readInt64(); + break; + } + case 18: { + + pubKeyHash_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutput_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXOutput.class, org.tron.protos.Protocol.TXOutput.Builder.class); + } + + public static final int VALUE_FIELD_NUMBER = 1; + private long value_; + /** + * int64 value = 1; + */ + public long getValue() { + return value_; + } + + public static final int PUBKEYHASH_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString pubKeyHash_; + /** + * bytes pubKeyHash = 2; + */ + public com.google.protobuf.ByteString getPubKeyHash() { + return pubKeyHash_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (value_ != 0L) { + output.writeInt64(1, value_); + } + if (!pubKeyHash_.isEmpty()) { + output.writeBytes(2, pubKeyHash_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (value_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, value_); + } + if (!pubKeyHash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, pubKeyHash_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TXOutput)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TXOutput other = (org.tron.protos.Protocol.TXOutput) obj; + + boolean result = true; + result = result && (getValue() + == other.getValue()); + result = result && getPubKeyHash() + .equals(other.getPubKeyHash()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getValue()); + hash = (37 * hash) + PUBKEYHASH_FIELD_NUMBER; + hash = (53 * hash) + getPubKeyHash().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TXOutput parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXOutput parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutput parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXOutput parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutput parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXOutput parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutput parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXOutput parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutput parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXOutput parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutput parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXOutput parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TXOutput prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TXOutput} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TXOutput) + org.tron.protos.Protocol.TXOutputOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutput_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXOutput.class, org.tron.protos.Protocol.TXOutput.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TXOutput.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + value_ = 0L; + + pubKeyHash_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutput_descriptor; + } + + public org.tron.protos.Protocol.TXOutput getDefaultInstanceForType() { + return org.tron.protos.Protocol.TXOutput.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TXOutput build() { + org.tron.protos.Protocol.TXOutput result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TXOutput buildPartial() { + org.tron.protos.Protocol.TXOutput result = new org.tron.protos.Protocol.TXOutput(this); + result.value_ = value_; + result.pubKeyHash_ = pubKeyHash_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TXOutput) { + return mergeFrom((org.tron.protos.Protocol.TXOutput)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TXOutput other) { + if (other == org.tron.protos.Protocol.TXOutput.getDefaultInstance()) return this; + if (other.getValue() != 0L) { + setValue(other.getValue()); + } + if (other.getPubKeyHash() != com.google.protobuf.ByteString.EMPTY) { + setPubKeyHash(other.getPubKeyHash()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TXOutput parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TXOutput) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long value_ ; + /** + * int64 value = 1; + */ + public long getValue() { + return value_; + } + /** + * int64 value = 1; + */ + public Builder setValue(long value) { + + value_ = value; + onChanged(); + return this; + } + /** + * int64 value = 1; + */ + public Builder clearValue() { + + value_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString pubKeyHash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes pubKeyHash = 2; + */ + public com.google.protobuf.ByteString getPubKeyHash() { + return pubKeyHash_; + } + /** + * bytes pubKeyHash = 2; + */ + public Builder setPubKeyHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + pubKeyHash_ = value; + onChanged(); + return this; + } + /** + * bytes pubKeyHash = 2; + */ + public Builder clearPubKeyHash() { + + pubKeyHash_ = getDefaultInstance().getPubKeyHash(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TXOutput) + } + + // @@protoc_insertion_point(class_scope:protocol.TXOutput) + private static final org.tron.protos.Protocol.TXOutput DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TXOutput(); + } + + public static org.tron.protos.Protocol.TXOutput getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TXOutput parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TXOutput(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TXOutput getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TXInputOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TXInput) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.TXInput.raw raw_data = 1; + */ + boolean hasRawData(); + /** + * .protocol.TXInput.raw raw_data = 1; + */ + org.tron.protos.Protocol.TXInput.raw getRawData(); + /** + * .protocol.TXInput.raw raw_data = 1; + */ + org.tron.protos.Protocol.TXInput.rawOrBuilder getRawDataOrBuilder(); + + /** + * bytes signature = 4; + */ + com.google.protobuf.ByteString getSignature(); + } + /** + * Protobuf type {@code protocol.TXInput} + */ + public static final class TXInput extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TXInput) + TXInputOrBuilder { + private static final long serialVersionUID = 0L; + // Use TXInput.newBuilder() to construct. + private TXInput(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TXInput() { + signature_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TXInput( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.TXInput.raw.Builder subBuilder = null; + if (rawData_ != null) { + subBuilder = rawData_.toBuilder(); + } + rawData_ = input.readMessage(org.tron.protos.Protocol.TXInput.raw.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(rawData_); + rawData_ = subBuilder.buildPartial(); + } + + break; + } + case 34: { + + signature_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXInput.class, org.tron.protos.Protocol.TXInput.Builder.class); + } + + public interface rawOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TXInput.raw) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes txID = 1; + */ + com.google.protobuf.ByteString getTxID(); + + /** + * int64 vout = 2; + */ + long getVout(); + + /** + * bytes pubKey = 3; + */ + com.google.protobuf.ByteString getPubKey(); + } + /** + * Protobuf type {@code protocol.TXInput.raw} + */ + public static final class raw extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TXInput.raw) + rawOrBuilder { + private static final long serialVersionUID = 0L; + // Use raw.newBuilder() to construct. + private raw(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private raw() { + txID_ = com.google.protobuf.ByteString.EMPTY; + vout_ = 0L; + pubKey_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private raw( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + txID_ = input.readBytes(); + break; + } + case 16: { + + vout_ = input.readInt64(); + break; + } + case 26: { + + pubKey_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_raw_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_raw_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXInput.raw.class, org.tron.protos.Protocol.TXInput.raw.Builder.class); + } + + public static final int TXID_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString txID_; + /** + * bytes txID = 1; + */ + public com.google.protobuf.ByteString getTxID() { + return txID_; + } + + public static final int VOUT_FIELD_NUMBER = 2; + private long vout_; + /** + * int64 vout = 2; + */ + public long getVout() { + return vout_; + } + + public static final int PUBKEY_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString pubKey_; + /** + * bytes pubKey = 3; + */ + public com.google.protobuf.ByteString getPubKey() { + return pubKey_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!txID_.isEmpty()) { + output.writeBytes(1, txID_); + } + if (vout_ != 0L) { + output.writeInt64(2, vout_); + } + if (!pubKey_.isEmpty()) { + output.writeBytes(3, pubKey_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!txID_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, txID_); + } + if (vout_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, vout_); + } + if (!pubKey_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, pubKey_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TXInput.raw)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TXInput.raw other = (org.tron.protos.Protocol.TXInput.raw) obj; + + boolean result = true; + result = result && getTxID() + .equals(other.getTxID()); + result = result && (getVout() + == other.getVout()); + result = result && getPubKey() + .equals(other.getPubKey()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TXID_FIELD_NUMBER; + hash = (53 * hash) + getTxID().hashCode(); + hash = (37 * hash) + VOUT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getVout()); + hash = (37 * hash) + PUBKEY_FIELD_NUMBER; + hash = (53 * hash) + getPubKey().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput.raw parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXInput.raw parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXInput.raw parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TXInput.raw prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TXInput.raw} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TXInput.raw) + org.tron.protos.Protocol.TXInput.rawOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_raw_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_raw_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXInput.raw.class, org.tron.protos.Protocol.TXInput.raw.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TXInput.raw.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + txID_ = com.google.protobuf.ByteString.EMPTY; + + vout_ = 0L; + + pubKey_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_raw_descriptor; + } + + public org.tron.protos.Protocol.TXInput.raw getDefaultInstanceForType() { + return org.tron.protos.Protocol.TXInput.raw.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TXInput.raw build() { + org.tron.protos.Protocol.TXInput.raw result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TXInput.raw buildPartial() { + org.tron.protos.Protocol.TXInput.raw result = new org.tron.protos.Protocol.TXInput.raw(this); + result.txID_ = txID_; + result.vout_ = vout_; + result.pubKey_ = pubKey_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TXInput.raw) { + return mergeFrom((org.tron.protos.Protocol.TXInput.raw)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TXInput.raw other) { + if (other == org.tron.protos.Protocol.TXInput.raw.getDefaultInstance()) return this; + if (other.getTxID() != com.google.protobuf.ByteString.EMPTY) { + setTxID(other.getTxID()); + } + if (other.getVout() != 0L) { + setVout(other.getVout()); + } + if (other.getPubKey() != com.google.protobuf.ByteString.EMPTY) { + setPubKey(other.getPubKey()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TXInput.raw parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TXInput.raw) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString txID_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes txID = 1; + */ + public com.google.protobuf.ByteString getTxID() { + return txID_; + } + /** + * bytes txID = 1; + */ + public Builder setTxID(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + txID_ = value; + onChanged(); + return this; + } + /** + * bytes txID = 1; + */ + public Builder clearTxID() { + + txID_ = getDefaultInstance().getTxID(); + onChanged(); + return this; + } + + private long vout_ ; + /** + * int64 vout = 2; + */ + public long getVout() { + return vout_; + } + /** + * int64 vout = 2; + */ + public Builder setVout(long value) { + + vout_ = value; + onChanged(); + return this; + } + /** + * int64 vout = 2; + */ + public Builder clearVout() { + + vout_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString pubKey_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes pubKey = 3; + */ + public com.google.protobuf.ByteString getPubKey() { + return pubKey_; + } + /** + * bytes pubKey = 3; + */ + public Builder setPubKey(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + pubKey_ = value; + onChanged(); + return this; + } + /** + * bytes pubKey = 3; + */ + public Builder clearPubKey() { + + pubKey_ = getDefaultInstance().getPubKey(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TXInput.raw) + } + + // @@protoc_insertion_point(class_scope:protocol.TXInput.raw) + private static final org.tron.protos.Protocol.TXInput.raw DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TXInput.raw(); + } + + public static org.tron.protos.Protocol.TXInput.raw getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public raw parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new raw(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TXInput.raw getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int RAW_DATA_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.TXInput.raw rawData_; + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public boolean hasRawData() { + return rawData_ != null; + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public org.tron.protos.Protocol.TXInput.raw getRawData() { + return rawData_ == null ? org.tron.protos.Protocol.TXInput.raw.getDefaultInstance() : rawData_; + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public org.tron.protos.Protocol.TXInput.rawOrBuilder getRawDataOrBuilder() { + return getRawData(); + } + + public static final int SIGNATURE_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString signature_; + /** + * bytes signature = 4; + */ + public com.google.protobuf.ByteString getSignature() { + return signature_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (rawData_ != null) { + output.writeMessage(1, getRawData()); + } + if (!signature_.isEmpty()) { + output.writeBytes(4, signature_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (rawData_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getRawData()); + } + if (!signature_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, signature_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TXInput)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TXInput other = (org.tron.protos.Protocol.TXInput) obj; + + boolean result = true; + result = result && (hasRawData() == other.hasRawData()); + if (hasRawData()) { + result = result && getRawData() + .equals(other.getRawData()); + } + result = result && getSignature() + .equals(other.getSignature()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasRawData()) { + hash = (37 * hash) + RAW_DATA_FIELD_NUMBER; + hash = (53 * hash) + getRawData().hashCode(); + } + hash = (37 * hash) + SIGNATURE_FIELD_NUMBER; + hash = (53 * hash) + getSignature().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TXInput parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXInput parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXInput parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXInput parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXInput parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXInput parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXInput parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXInput parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TXInput prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TXInput} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TXInput) + org.tron.protos.Protocol.TXInputOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXInput.class, org.tron.protos.Protocol.TXInput.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TXInput.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (rawDataBuilder_ == null) { + rawData_ = null; + } else { + rawData_ = null; + rawDataBuilder_ = null; + } + signature_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TXInput_descriptor; + } + + public org.tron.protos.Protocol.TXInput getDefaultInstanceForType() { + return org.tron.protos.Protocol.TXInput.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TXInput build() { + org.tron.protos.Protocol.TXInput result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TXInput buildPartial() { + org.tron.protos.Protocol.TXInput result = new org.tron.protos.Protocol.TXInput(this); + if (rawDataBuilder_ == null) { + result.rawData_ = rawData_; + } else { + result.rawData_ = rawDataBuilder_.build(); + } + result.signature_ = signature_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TXInput) { + return mergeFrom((org.tron.protos.Protocol.TXInput)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TXInput other) { + if (other == org.tron.protos.Protocol.TXInput.getDefaultInstance()) return this; + if (other.hasRawData()) { + mergeRawData(other.getRawData()); + } + if (other.getSignature() != com.google.protobuf.ByteString.EMPTY) { + setSignature(other.getSignature()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TXInput parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TXInput) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Protocol.TXInput.raw rawData_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.TXInput.raw, org.tron.protos.Protocol.TXInput.raw.Builder, org.tron.protos.Protocol.TXInput.rawOrBuilder> rawDataBuilder_; + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public boolean hasRawData() { + return rawDataBuilder_ != null || rawData_ != null; + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public org.tron.protos.Protocol.TXInput.raw getRawData() { + if (rawDataBuilder_ == null) { + return rawData_ == null ? org.tron.protos.Protocol.TXInput.raw.getDefaultInstance() : rawData_; + } else { + return rawDataBuilder_.getMessage(); + } + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public Builder setRawData(org.tron.protos.Protocol.TXInput.raw value) { + if (rawDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + rawData_ = value; + onChanged(); + } else { + rawDataBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public Builder setRawData( + org.tron.protos.Protocol.TXInput.raw.Builder builderForValue) { + if (rawDataBuilder_ == null) { + rawData_ = builderForValue.build(); + onChanged(); + } else { + rawDataBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public Builder mergeRawData(org.tron.protos.Protocol.TXInput.raw value) { + if (rawDataBuilder_ == null) { + if (rawData_ != null) { + rawData_ = + org.tron.protos.Protocol.TXInput.raw.newBuilder(rawData_).mergeFrom(value).buildPartial(); + } else { + rawData_ = value; + } + onChanged(); + } else { + rawDataBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public Builder clearRawData() { + if (rawDataBuilder_ == null) { + rawData_ = null; + onChanged(); + } else { + rawData_ = null; + rawDataBuilder_ = null; + } + + return this; + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public org.tron.protos.Protocol.TXInput.raw.Builder getRawDataBuilder() { + + onChanged(); + return getRawDataFieldBuilder().getBuilder(); + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + public org.tron.protos.Protocol.TXInput.rawOrBuilder getRawDataOrBuilder() { + if (rawDataBuilder_ != null) { + return rawDataBuilder_.getMessageOrBuilder(); + } else { + return rawData_ == null ? + org.tron.protos.Protocol.TXInput.raw.getDefaultInstance() : rawData_; + } + } + /** + * .protocol.TXInput.raw raw_data = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.TXInput.raw, org.tron.protos.Protocol.TXInput.raw.Builder, org.tron.protos.Protocol.TXInput.rawOrBuilder> + getRawDataFieldBuilder() { + if (rawDataBuilder_ == null) { + rawDataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.TXInput.raw, org.tron.protos.Protocol.TXInput.raw.Builder, org.tron.protos.Protocol.TXInput.rawOrBuilder>( + getRawData(), + getParentForChildren(), + isClean()); + rawData_ = null; + } + return rawDataBuilder_; + } + + private com.google.protobuf.ByteString signature_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes signature = 4; + */ + public com.google.protobuf.ByteString getSignature() { + return signature_; + } + /** + * bytes signature = 4; + */ + public Builder setSignature(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + signature_ = value; + onChanged(); + return this; + } + /** + * bytes signature = 4; + */ + public Builder clearSignature() { + + signature_ = getDefaultInstance().getSignature(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TXInput) + } + + // @@protoc_insertion_point(class_scope:protocol.TXInput) + private static final org.tron.protos.Protocol.TXInput DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TXInput(); + } + + public static org.tron.protos.Protocol.TXInput getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TXInput parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TXInput(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TXInput getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TXOutputsOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TXOutputs) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.TXOutput outputs = 1; + */ + java.util.List + getOutputsList(); + /** + * repeated .protocol.TXOutput outputs = 1; + */ + org.tron.protos.Protocol.TXOutput getOutputs(int index); + /** + * repeated .protocol.TXOutput outputs = 1; + */ + int getOutputsCount(); + /** + * repeated .protocol.TXOutput outputs = 1; + */ + java.util.List + getOutputsOrBuilderList(); + /** + * repeated .protocol.TXOutput outputs = 1; + */ + org.tron.protos.Protocol.TXOutputOrBuilder getOutputsOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.TXOutputs} + */ + public static final class TXOutputs extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TXOutputs) + TXOutputsOrBuilder { + private static final long serialVersionUID = 0L; + // Use TXOutputs.newBuilder() to construct. + private TXOutputs(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TXOutputs() { + outputs_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TXOutputs( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + outputs_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + outputs_.add( + input.readMessage(org.tron.protos.Protocol.TXOutput.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + outputs_ = java.util.Collections.unmodifiableList(outputs_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutputs_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutputs_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXOutputs.class, org.tron.protos.Protocol.TXOutputs.Builder.class); + } + + public static final int OUTPUTS_FIELD_NUMBER = 1; + private java.util.List outputs_; + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public java.util.List getOutputsList() { + return outputs_; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public java.util.List + getOutputsOrBuilderList() { + return outputs_; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public int getOutputsCount() { + return outputs_.size(); + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public org.tron.protos.Protocol.TXOutput getOutputs(int index) { + return outputs_.get(index); + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public org.tron.protos.Protocol.TXOutputOrBuilder getOutputsOrBuilder( + int index) { + return outputs_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < outputs_.size(); i++) { + output.writeMessage(1, outputs_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < outputs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, outputs_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TXOutputs)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TXOutputs other = (org.tron.protos.Protocol.TXOutputs) obj; + + boolean result = true; + result = result && getOutputsList() + .equals(other.getOutputsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getOutputsCount() > 0) { + hash = (37 * hash) + OUTPUTS_FIELD_NUMBER; + hash = (53 * hash) + getOutputsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TXOutputs parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutputs parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXOutputs parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TXOutputs parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TXOutputs prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TXOutputs} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TXOutputs) + org.tron.protos.Protocol.TXOutputsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutputs_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutputs_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TXOutputs.class, org.tron.protos.Protocol.TXOutputs.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TXOutputs.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getOutputsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (outputsBuilder_ == null) { + outputs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + outputsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TXOutputs_descriptor; + } + + public org.tron.protos.Protocol.TXOutputs getDefaultInstanceForType() { + return org.tron.protos.Protocol.TXOutputs.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TXOutputs build() { + org.tron.protos.Protocol.TXOutputs result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TXOutputs buildPartial() { + org.tron.protos.Protocol.TXOutputs result = new org.tron.protos.Protocol.TXOutputs(this); + int from_bitField0_ = bitField0_; + if (outputsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + outputs_ = java.util.Collections.unmodifiableList(outputs_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.outputs_ = outputs_; + } else { + result.outputs_ = outputsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TXOutputs) { + return mergeFrom((org.tron.protos.Protocol.TXOutputs)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TXOutputs other) { + if (other == org.tron.protos.Protocol.TXOutputs.getDefaultInstance()) return this; + if (outputsBuilder_ == null) { + if (!other.outputs_.isEmpty()) { + if (outputs_.isEmpty()) { + outputs_ = other.outputs_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureOutputsIsMutable(); + outputs_.addAll(other.outputs_); + } + onChanged(); + } + } else { + if (!other.outputs_.isEmpty()) { + if (outputsBuilder_.isEmpty()) { + outputsBuilder_.dispose(); + outputsBuilder_ = null; + outputs_ = other.outputs_; + bitField0_ = (bitField0_ & ~0x00000001); + outputsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getOutputsFieldBuilder() : null; + } else { + outputsBuilder_.addAllMessages(other.outputs_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TXOutputs parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TXOutputs) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List outputs_ = + java.util.Collections.emptyList(); + private void ensureOutputsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + outputs_ = new java.util.ArrayList(outputs_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TXOutput, org.tron.protos.Protocol.TXOutput.Builder, org.tron.protos.Protocol.TXOutputOrBuilder> outputsBuilder_; + + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public java.util.List getOutputsList() { + if (outputsBuilder_ == null) { + return java.util.Collections.unmodifiableList(outputs_); + } else { + return outputsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public int getOutputsCount() { + if (outputsBuilder_ == null) { + return outputs_.size(); + } else { + return outputsBuilder_.getCount(); + } + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public org.tron.protos.Protocol.TXOutput getOutputs(int index) { + if (outputsBuilder_ == null) { + return outputs_.get(index); + } else { + return outputsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder setOutputs( + int index, org.tron.protos.Protocol.TXOutput value) { + if (outputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.set(index, value); + onChanged(); + } else { + outputsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder setOutputs( + int index, org.tron.protos.Protocol.TXOutput.Builder builderForValue) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.set(index, builderForValue.build()); + onChanged(); + } else { + outputsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder addOutputs(org.tron.protos.Protocol.TXOutput value) { + if (outputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.add(value); + onChanged(); + } else { + outputsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder addOutputs( + int index, org.tron.protos.Protocol.TXOutput value) { + if (outputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.add(index, value); + onChanged(); + } else { + outputsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder addOutputs( + org.tron.protos.Protocol.TXOutput.Builder builderForValue) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.add(builderForValue.build()); + onChanged(); + } else { + outputsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder addOutputs( + int index, org.tron.protos.Protocol.TXOutput.Builder builderForValue) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.add(index, builderForValue.build()); + onChanged(); + } else { + outputsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder addAllOutputs( + java.lang.Iterable values) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, outputs_); + onChanged(); + } else { + outputsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder clearOutputs() { + if (outputsBuilder_ == null) { + outputs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + outputsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public Builder removeOutputs(int index) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.remove(index); + onChanged(); + } else { + outputsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public org.tron.protos.Protocol.TXOutput.Builder getOutputsBuilder( + int index) { + return getOutputsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public org.tron.protos.Protocol.TXOutputOrBuilder getOutputsOrBuilder( + int index) { + if (outputsBuilder_ == null) { + return outputs_.get(index); } else { + return outputsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public java.util.List + getOutputsOrBuilderList() { + if (outputsBuilder_ != null) { + return outputsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(outputs_); + } + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public org.tron.protos.Protocol.TXOutput.Builder addOutputsBuilder() { + return getOutputsFieldBuilder().addBuilder( + org.tron.protos.Protocol.TXOutput.getDefaultInstance()); + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public org.tron.protos.Protocol.TXOutput.Builder addOutputsBuilder( + int index) { + return getOutputsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.TXOutput.getDefaultInstance()); + } + /** + * repeated .protocol.TXOutput outputs = 1; + */ + public java.util.List + getOutputsBuilderList() { + return getOutputsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TXOutput, org.tron.protos.Protocol.TXOutput.Builder, org.tron.protos.Protocol.TXOutputOrBuilder> + getOutputsFieldBuilder() { + if (outputsBuilder_ == null) { + outputsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TXOutput, org.tron.protos.Protocol.TXOutput.Builder, org.tron.protos.Protocol.TXOutputOrBuilder>( + outputs_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + outputs_ = null; + } + return outputsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TXOutputs) + } + + // @@protoc_insertion_point(class_scope:protocol.TXOutputs) + private static final org.tron.protos.Protocol.TXOutputs DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TXOutputs(); + } + + public static org.tron.protos.Protocol.TXOutputs getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TXOutputs parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TXOutputs(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TXOutputs getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ResourceReceiptOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ResourceReceipt) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 energy_usage = 1; + */ + long getEnergyUsage(); + + /** + * int64 energy_fee = 2; + */ + long getEnergyFee(); + + /** + * int64 origin_energy_usage = 3; + */ + long getOriginEnergyUsage(); + + /** + * int64 energy_usage_total = 4; + */ + long getEnergyUsageTotal(); + + /** + * int64 net_usage = 5; + */ + long getNetUsage(); + + /** + * int64 net_fee = 6; + */ + long getNetFee(); + + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + int getResultValue(); + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + org.tron.protos.Protocol.Transaction.Result.contractResult getResult(); + } + /** + * Protobuf type {@code protocol.ResourceReceipt} + */ + public static final class ResourceReceipt extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ResourceReceipt) + ResourceReceiptOrBuilder { + private static final long serialVersionUID = 0L; + // Use ResourceReceipt.newBuilder() to construct. + private ResourceReceipt(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ResourceReceipt() { + energyUsage_ = 0L; + energyFee_ = 0L; + originEnergyUsage_ = 0L; + energyUsageTotal_ = 0L; + netUsage_ = 0L; + netFee_ = 0L; + result_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ResourceReceipt( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + energyUsage_ = input.readInt64(); + break; + } + case 16: { + + energyFee_ = input.readInt64(); + break; + } + case 24: { + + originEnergyUsage_ = input.readInt64(); + break; + } + case 32: { + + energyUsageTotal_ = input.readInt64(); + break; + } + case 40: { + + netUsage_ = input.readInt64(); + break; + } + case 48: { + + netFee_ = input.readInt64(); + break; + } + case 56: { + int rawValue = input.readEnum(); + + result_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ResourceReceipt_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ResourceReceipt_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ResourceReceipt.class, org.tron.protos.Protocol.ResourceReceipt.Builder.class); + } + + public static final int ENERGY_USAGE_FIELD_NUMBER = 1; + private long energyUsage_; + /** + * int64 energy_usage = 1; + */ + public long getEnergyUsage() { + return energyUsage_; + } + + public static final int ENERGY_FEE_FIELD_NUMBER = 2; + private long energyFee_; + /** + * int64 energy_fee = 2; + */ + public long getEnergyFee() { + return energyFee_; + } + + public static final int ORIGIN_ENERGY_USAGE_FIELD_NUMBER = 3; + private long originEnergyUsage_; + /** + * int64 origin_energy_usage = 3; + */ + public long getOriginEnergyUsage() { + return originEnergyUsage_; + } + + public static final int ENERGY_USAGE_TOTAL_FIELD_NUMBER = 4; + private long energyUsageTotal_; + /** + * int64 energy_usage_total = 4; + */ + public long getEnergyUsageTotal() { + return energyUsageTotal_; + } + + public static final int NET_USAGE_FIELD_NUMBER = 5; + private long netUsage_; + /** + * int64 net_usage = 5; + */ + public long getNetUsage() { + return netUsage_; + } + + public static final int NET_FEE_FIELD_NUMBER = 6; + private long netFee_; + /** + * int64 net_fee = 6; + */ + public long getNetFee() { + return netFee_; + } + + public static final int RESULT_FIELD_NUMBER = 7; + private int result_; + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + public int getResultValue() { + return result_; + } + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + public org.tron.protos.Protocol.Transaction.Result.contractResult getResult() { + org.tron.protos.Protocol.Transaction.Result.contractResult result = org.tron.protos.Protocol.Transaction.Result.contractResult.valueOf(result_); + return result == null ? org.tron.protos.Protocol.Transaction.Result.contractResult.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (energyUsage_ != 0L) { + output.writeInt64(1, energyUsage_); + } + if (energyFee_ != 0L) { + output.writeInt64(2, energyFee_); + } + if (originEnergyUsage_ != 0L) { + output.writeInt64(3, originEnergyUsage_); + } + if (energyUsageTotal_ != 0L) { + output.writeInt64(4, energyUsageTotal_); + } + if (netUsage_ != 0L) { + output.writeInt64(5, netUsage_); + } + if (netFee_ != 0L) { + output.writeInt64(6, netFee_); + } + if (result_ != org.tron.protos.Protocol.Transaction.Result.contractResult.DEFAULT.getNumber()) { + output.writeEnum(7, result_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (energyUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, energyUsage_); + } + if (energyFee_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, energyFee_); + } + if (originEnergyUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, originEnergyUsage_); + } + if (energyUsageTotal_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, energyUsageTotal_); + } + if (netUsage_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, netUsage_); + } + if (netFee_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, netFee_); + } + if (result_ != org.tron.protos.Protocol.Transaction.Result.contractResult.DEFAULT.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(7, result_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.ResourceReceipt)) { + return super.equals(obj); + } + org.tron.protos.Protocol.ResourceReceipt other = (org.tron.protos.Protocol.ResourceReceipt) obj; + + boolean result = true; + result = result && (getEnergyUsage() + == other.getEnergyUsage()); + result = result && (getEnergyFee() + == other.getEnergyFee()); + result = result && (getOriginEnergyUsage() + == other.getOriginEnergyUsage()); + result = result && (getEnergyUsageTotal() + == other.getEnergyUsageTotal()); + result = result && (getNetUsage() + == other.getNetUsage()); + result = result && (getNetFee() + == other.getNetFee()); + result = result && result_ == other.result_; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENERGY_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEnergyUsage()); + hash = (37 * hash) + ENERGY_FEE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEnergyFee()); + hash = (37 * hash) + ORIGIN_ENERGY_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOriginEnergyUsage()); + hash = (37 * hash) + ENERGY_USAGE_TOTAL_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEnergyUsageTotal()); + hash = (37 * hash) + NET_USAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNetUsage()); + hash = (37 * hash) + NET_FEE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNetFee()); + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + result_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ResourceReceipt parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ResourceReceipt parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ResourceReceipt parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.ResourceReceipt prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ResourceReceipt} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ResourceReceipt) + org.tron.protos.Protocol.ResourceReceiptOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ResourceReceipt_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ResourceReceipt_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ResourceReceipt.class, org.tron.protos.Protocol.ResourceReceipt.Builder.class); + } + + // Construct using org.tron.protos.Protocol.ResourceReceipt.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + energyUsage_ = 0L; + + energyFee_ = 0L; + + originEnergyUsage_ = 0L; + + energyUsageTotal_ = 0L; + + netUsage_ = 0L; + + netFee_ = 0L; + + result_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_ResourceReceipt_descriptor; + } + + public org.tron.protos.Protocol.ResourceReceipt getDefaultInstanceForType() { + return org.tron.protos.Protocol.ResourceReceipt.getDefaultInstance(); + } + + public org.tron.protos.Protocol.ResourceReceipt build() { + org.tron.protos.Protocol.ResourceReceipt result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.ResourceReceipt buildPartial() { + org.tron.protos.Protocol.ResourceReceipt result = new org.tron.protos.Protocol.ResourceReceipt(this); + result.energyUsage_ = energyUsage_; + result.energyFee_ = energyFee_; + result.originEnergyUsage_ = originEnergyUsage_; + result.energyUsageTotal_ = energyUsageTotal_; + result.netUsage_ = netUsage_; + result.netFee_ = netFee_; + result.result_ = result_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.ResourceReceipt) { + return mergeFrom((org.tron.protos.Protocol.ResourceReceipt)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.ResourceReceipt other) { + if (other == org.tron.protos.Protocol.ResourceReceipt.getDefaultInstance()) return this; + if (other.getEnergyUsage() != 0L) { + setEnergyUsage(other.getEnergyUsage()); + } + if (other.getEnergyFee() != 0L) { + setEnergyFee(other.getEnergyFee()); + } + if (other.getOriginEnergyUsage() != 0L) { + setOriginEnergyUsage(other.getOriginEnergyUsage()); + } + if (other.getEnergyUsageTotal() != 0L) { + setEnergyUsageTotal(other.getEnergyUsageTotal()); + } + if (other.getNetUsage() != 0L) { + setNetUsage(other.getNetUsage()); + } + if (other.getNetFee() != 0L) { + setNetFee(other.getNetFee()); + } + if (other.result_ != 0) { + setResultValue(other.getResultValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.ResourceReceipt parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.ResourceReceipt) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long energyUsage_ ; + /** + * int64 energy_usage = 1; + */ + public long getEnergyUsage() { + return energyUsage_; + } + /** + * int64 energy_usage = 1; + */ + public Builder setEnergyUsage(long value) { + + energyUsage_ = value; + onChanged(); + return this; + } + /** + * int64 energy_usage = 1; + */ + public Builder clearEnergyUsage() { + + energyUsage_ = 0L; + onChanged(); + return this; + } + + private long energyFee_ ; + /** + * int64 energy_fee = 2; + */ + public long getEnergyFee() { + return energyFee_; + } + /** + * int64 energy_fee = 2; + */ + public Builder setEnergyFee(long value) { + + energyFee_ = value; + onChanged(); + return this; + } + /** + * int64 energy_fee = 2; + */ + public Builder clearEnergyFee() { + + energyFee_ = 0L; + onChanged(); + return this; + } + + private long originEnergyUsage_ ; + /** + * int64 origin_energy_usage = 3; + */ + public long getOriginEnergyUsage() { + return originEnergyUsage_; + } + /** + * int64 origin_energy_usage = 3; + */ + public Builder setOriginEnergyUsage(long value) { + + originEnergyUsage_ = value; + onChanged(); + return this; + } + /** + * int64 origin_energy_usage = 3; + */ + public Builder clearOriginEnergyUsage() { + + originEnergyUsage_ = 0L; + onChanged(); + return this; + } + + private long energyUsageTotal_ ; + /** + * int64 energy_usage_total = 4; + */ + public long getEnergyUsageTotal() { + return energyUsageTotal_; + } + /** + * int64 energy_usage_total = 4; + */ + public Builder setEnergyUsageTotal(long value) { + + energyUsageTotal_ = value; + onChanged(); + return this; + } + /** + * int64 energy_usage_total = 4; + */ + public Builder clearEnergyUsageTotal() { + + energyUsageTotal_ = 0L; + onChanged(); + return this; + } + + private long netUsage_ ; + /** + * int64 net_usage = 5; + */ + public long getNetUsage() { + return netUsage_; + } + /** + * int64 net_usage = 5; + */ + public Builder setNetUsage(long value) { + + netUsage_ = value; + onChanged(); + return this; + } + /** + * int64 net_usage = 5; + */ + public Builder clearNetUsage() { + + netUsage_ = 0L; + onChanged(); + return this; + } + + private long netFee_ ; + /** + * int64 net_fee = 6; + */ + public long getNetFee() { + return netFee_; + } + /** + * int64 net_fee = 6; + */ + public Builder setNetFee(long value) { + + netFee_ = value; + onChanged(); + return this; + } + /** + * int64 net_fee = 6; + */ + public Builder clearNetFee() { + + netFee_ = 0L; + onChanged(); + return this; + } + + private int result_ = 0; + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + public int getResultValue() { + return result_; + } + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + public Builder setResultValue(int value) { + result_ = value; + onChanged(); + return this; + } + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + public org.tron.protos.Protocol.Transaction.Result.contractResult getResult() { + org.tron.protos.Protocol.Transaction.Result.contractResult result = org.tron.protos.Protocol.Transaction.Result.contractResult.valueOf(result_); + return result == null ? org.tron.protos.Protocol.Transaction.Result.contractResult.UNRECOGNIZED : result; + } + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + public Builder setResult(org.tron.protos.Protocol.Transaction.Result.contractResult value) { + if (value == null) { + throw new NullPointerException(); + } + + result_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Transaction.Result.contractResult result = 7; + */ + public Builder clearResult() { + + result_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ResourceReceipt) + } + + // @@protoc_insertion_point(class_scope:protocol.ResourceReceipt) + private static final org.tron.protos.Protocol.ResourceReceipt DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.ResourceReceipt(); + } + + public static org.tron.protos.Protocol.ResourceReceipt getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ResourceReceipt parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ResourceReceipt(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.ResourceReceipt getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Transaction) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Transaction.raw raw_data = 1; + */ + boolean hasRawData(); + /** + * .protocol.Transaction.raw raw_data = 1; + */ + org.tron.protos.Protocol.Transaction.raw getRawData(); + /** + * .protocol.Transaction.raw raw_data = 1; + */ + org.tron.protos.Protocol.Transaction.rawOrBuilder getRawDataOrBuilder(); + + /** + *
+     * only support size = 1,  repeated list here for muti-sig extension
+     * 
+ * + * repeated bytes signature = 2; + */ + java.util.List getSignatureList(); + /** + *
+     * only support size = 1,  repeated list here for muti-sig extension
+     * 
+ * + * repeated bytes signature = 2; + */ + int getSignatureCount(); + /** + *
+     * only support size = 1,  repeated list here for muti-sig extension
+     * 
+ * + * repeated bytes signature = 2; + */ + com.google.protobuf.ByteString getSignature(int index); + + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + java.util.List + getRetList(); + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + org.tron.protos.Protocol.Transaction.Result getRet(int index); + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + int getRetCount(); + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + java.util.List + getRetOrBuilderList(); + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + org.tron.protos.Protocol.Transaction.ResultOrBuilder getRetOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.Transaction} + */ + public static final class Transaction extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Transaction) + TransactionOrBuilder { + private static final long serialVersionUID = 0L; + // Use Transaction.newBuilder() to construct. + private Transaction(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Transaction() { + signature_ = java.util.Collections.emptyList(); + ret_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Transaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.Transaction.raw.Builder subBuilder = null; + if (rawData_ != null) { + subBuilder = rawData_.toBuilder(); + } + rawData_ = input.readMessage(org.tron.protos.Protocol.Transaction.raw.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(rawData_); + rawData_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + signature_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + signature_.add(input.readBytes()); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + ret_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + ret_.add( + input.readMessage(org.tron.protos.Protocol.Transaction.Result.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + signature_ = java.util.Collections.unmodifiableList(signature_); + } + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + ret_ = java.util.Collections.unmodifiableList(ret_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.class, org.tron.protos.Protocol.Transaction.Builder.class); + } + + public interface ContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Transaction.Contract) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + int getTypeValue(); + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + org.tron.protos.Protocol.Transaction.Contract.ContractType getType(); + + /** + * .google.protobuf.Any parameter = 2; + */ + boolean hasParameter(); + /** + * .google.protobuf.Any parameter = 2; + */ + com.google.protobuf.Any getParameter(); + /** + * .google.protobuf.Any parameter = 2; + */ + com.google.protobuf.AnyOrBuilder getParameterOrBuilder(); + + /** + * bytes provider = 3; + */ + com.google.protobuf.ByteString getProvider(); + + /** + * bytes ContractName = 4; + */ + com.google.protobuf.ByteString getContractName(); + + /** + * int32 Permission_id = 5; + */ + int getPermissionId(); + } + /** + * Protobuf type {@code protocol.Transaction.Contract} + */ + public static final class Contract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Transaction.Contract) + ContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use Contract.newBuilder() to construct. + private Contract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Contract() { + type_ = 0; + provider_ = com.google.protobuf.ByteString.EMPTY; + contractName_ = com.google.protobuf.ByteString.EMPTY; + permissionId_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Contract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 18: { + com.google.protobuf.Any.Builder subBuilder = null; + if (parameter_ != null) { + subBuilder = parameter_.toBuilder(); + } + parameter_ = input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(parameter_); + parameter_ = subBuilder.buildPartial(); + } + + break; + } + case 26: { + + provider_ = input.readBytes(); + break; + } + case 34: { + + contractName_ = input.readBytes(); + break; + } + case 40: { + + permissionId_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Contract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Contract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.Contract.class, org.tron.protos.Protocol.Transaction.Contract.Builder.class); + } + + /** + * Protobuf enum {@code protocol.Transaction.Contract.ContractType} + */ + public enum ContractType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * AccountCreateContract = 0; + */ + AccountCreateContract(0), + /** + * TransferContract = 1; + */ + TransferContract(1), + /** + * TransferAssetContract = 2; + */ + TransferAssetContract(2), + /** + * VoteAssetContract = 3; + */ + VoteAssetContract(3), + /** + * VoteWitnessContract = 4; + */ + VoteWitnessContract(4), + /** + * WitnessCreateContract = 5; + */ + WitnessCreateContract(5), + /** + * AssetIssueContract = 6; + */ + AssetIssueContract(6), + /** + * WitnessUpdateContract = 8; + */ + WitnessUpdateContract(8), + /** + * ParticipateAssetIssueContract = 9; + */ + ParticipateAssetIssueContract(9), + /** + * AccountUpdateContract = 10; + */ + AccountUpdateContract(10), + /** + * FreezeBalanceContract = 11; + */ + FreezeBalanceContract(11), + /** + * UnfreezeBalanceContract = 12; + */ + UnfreezeBalanceContract(12), + /** + * WithdrawBalanceContract = 13; + */ + WithdrawBalanceContract(13), + /** + * UnfreezeAssetContract = 14; + */ + UnfreezeAssetContract(14), + /** + * UpdateAssetContract = 15; + */ + UpdateAssetContract(15), + /** + * ProposalCreateContract = 16; + */ + ProposalCreateContract(16), + /** + * ProposalApproveContract = 17; + */ + ProposalApproveContract(17), + /** + * ProposalDeleteContract = 18; + */ + ProposalDeleteContract(18), + /** + * SetAccountIdContract = 19; + */ + SetAccountIdContract(19), + /** + * CustomContract = 20; + */ + CustomContract(20), + /** + *
+         * BuyStorageContract = 21;
+         * BuyStorageBytesContract = 22;
+         * SellStorageContract = 23;
+         * 
+ * + * CreateSmartContract = 30; + */ + CreateSmartContract(30), + /** + * TriggerSmartContract = 31; + */ + TriggerSmartContract(31), + /** + * GetContract = 32; + */ + GetContract(32), + /** + * UpdateSettingContract = 33; + */ + UpdateSettingContract(33), + /** + * ExchangeCreateContract = 41; + */ + ExchangeCreateContract(41), + /** + * ExchangeInjectContract = 42; + */ + ExchangeInjectContract(42), + /** + * ExchangeWithdrawContract = 43; + */ + ExchangeWithdrawContract(43), + /** + * ExchangeTransactionContract = 44; + */ + ExchangeTransactionContract(44), + /** + * UpdateEnergyLimitContract = 45; + */ + UpdateEnergyLimitContract(45), + /** + * AccountPermissionUpdateContract = 46; + */ + AccountPermissionUpdateContract(46), + /** + * ClearABIContract = 48; + */ + ClearABIContract(48), + UNRECOGNIZED(-1), + ; + + /** + * AccountCreateContract = 0; + */ + public static final int AccountCreateContract_VALUE = 0; + /** + * TransferContract = 1; + */ + public static final int TransferContract_VALUE = 1; + /** + * TransferAssetContract = 2; + */ + public static final int TransferAssetContract_VALUE = 2; + /** + * VoteAssetContract = 3; + */ + public static final int VoteAssetContract_VALUE = 3; + /** + * VoteWitnessContract = 4; + */ + public static final int VoteWitnessContract_VALUE = 4; + /** + * WitnessCreateContract = 5; + */ + public static final int WitnessCreateContract_VALUE = 5; + /** + * AssetIssueContract = 6; + */ + public static final int AssetIssueContract_VALUE = 6; + /** + * WitnessUpdateContract = 8; + */ + public static final int WitnessUpdateContract_VALUE = 8; + /** + * ParticipateAssetIssueContract = 9; + */ + public static final int ParticipateAssetIssueContract_VALUE = 9; + /** + * AccountUpdateContract = 10; + */ + public static final int AccountUpdateContract_VALUE = 10; + /** + * FreezeBalanceContract = 11; + */ + public static final int FreezeBalanceContract_VALUE = 11; + /** + * UnfreezeBalanceContract = 12; + */ + public static final int UnfreezeBalanceContract_VALUE = 12; + /** + * WithdrawBalanceContract = 13; + */ + public static final int WithdrawBalanceContract_VALUE = 13; + /** + * UnfreezeAssetContract = 14; + */ + public static final int UnfreezeAssetContract_VALUE = 14; + /** + * UpdateAssetContract = 15; + */ + public static final int UpdateAssetContract_VALUE = 15; + /** + * ProposalCreateContract = 16; + */ + public static final int ProposalCreateContract_VALUE = 16; + /** + * ProposalApproveContract = 17; + */ + public static final int ProposalApproveContract_VALUE = 17; + /** + * ProposalDeleteContract = 18; + */ + public static final int ProposalDeleteContract_VALUE = 18; + /** + * SetAccountIdContract = 19; + */ + public static final int SetAccountIdContract_VALUE = 19; + /** + * CustomContract = 20; + */ + public static final int CustomContract_VALUE = 20; + /** + *
+         * BuyStorageContract = 21;
+         * BuyStorageBytesContract = 22;
+         * SellStorageContract = 23;
+         * 
+ * + * CreateSmartContract = 30; + */ + public static final int CreateSmartContract_VALUE = 30; + /** + * TriggerSmartContract = 31; + */ + public static final int TriggerSmartContract_VALUE = 31; + /** + * GetContract = 32; + */ + public static final int GetContract_VALUE = 32; + /** + * UpdateSettingContract = 33; + */ + public static final int UpdateSettingContract_VALUE = 33; + /** + * ExchangeCreateContract = 41; + */ + public static final int ExchangeCreateContract_VALUE = 41; + /** + * ExchangeInjectContract = 42; + */ + public static final int ExchangeInjectContract_VALUE = 42; + /** + * ExchangeWithdrawContract = 43; + */ + public static final int ExchangeWithdrawContract_VALUE = 43; + /** + * ExchangeTransactionContract = 44; + */ + public static final int ExchangeTransactionContract_VALUE = 44; + /** + * UpdateEnergyLimitContract = 45; + */ + public static final int UpdateEnergyLimitContract_VALUE = 45; + /** + * AccountPermissionUpdateContract = 46; + */ + public static final int AccountPermissionUpdateContract_VALUE = 46; + /** + * ClearABIContract = 48; + */ + public static final int ClearABIContract_VALUE = 48; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ContractType valueOf(int value) { + return forNumber(value); + } + + public static ContractType forNumber(int value) { + switch (value) { + case 0: return AccountCreateContract; + case 1: return TransferContract; + case 2: return TransferAssetContract; + case 3: return VoteAssetContract; + case 4: return VoteWitnessContract; + case 5: return WitnessCreateContract; + case 6: return AssetIssueContract; + case 8: return WitnessUpdateContract; + case 9: return ParticipateAssetIssueContract; + case 10: return AccountUpdateContract; + case 11: return FreezeBalanceContract; + case 12: return UnfreezeBalanceContract; + case 13: return WithdrawBalanceContract; + case 14: return UnfreezeAssetContract; + case 15: return UpdateAssetContract; + case 16: return ProposalCreateContract; + case 17: return ProposalApproveContract; + case 18: return ProposalDeleteContract; + case 19: return SetAccountIdContract; + case 20: return CustomContract; + case 30: return CreateSmartContract; + case 31: return TriggerSmartContract; + case 32: return GetContract; + case 33: return UpdateSettingContract; + case 41: return ExchangeCreateContract; + case 42: return ExchangeInjectContract; + case 43: return ExchangeWithdrawContract; + case 44: return ExchangeTransactionContract; + case 45: return UpdateEnergyLimitContract; + case 46: return AccountPermissionUpdateContract; + case 48: return ClearABIContract; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + ContractType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ContractType findValueByNumber(int number) { + return ContractType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.Transaction.Contract.getDescriptor().getEnumTypes().get(0); + } + + private static final ContractType[] VALUES = values(); + + public static ContractType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ContractType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Transaction.Contract.ContractType) + } + + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + public org.tron.protos.Protocol.Transaction.Contract.ContractType getType() { + org.tron.protos.Protocol.Transaction.Contract.ContractType result = org.tron.protos.Protocol.Transaction.Contract.ContractType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Transaction.Contract.ContractType.UNRECOGNIZED : result; + } + + public static final int PARAMETER_FIELD_NUMBER = 2; + private com.google.protobuf.Any parameter_; + /** + * .google.protobuf.Any parameter = 2; + */ + public boolean hasParameter() { + return parameter_ != null; + } + /** + * .google.protobuf.Any parameter = 2; + */ + public com.google.protobuf.Any getParameter() { + return parameter_ == null ? com.google.protobuf.Any.getDefaultInstance() : parameter_; + } + /** + * .google.protobuf.Any parameter = 2; + */ + public com.google.protobuf.AnyOrBuilder getParameterOrBuilder() { + return getParameter(); + } + + public static final int PROVIDER_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString provider_; + /** + * bytes provider = 3; + */ + public com.google.protobuf.ByteString getProvider() { + return provider_; + } + + public static final int CONTRACTNAME_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString contractName_; + /** + * bytes ContractName = 4; + */ + public com.google.protobuf.ByteString getContractName() { + return contractName_; + } + + public static final int PERMISSION_ID_FIELD_NUMBER = 5; + private int permissionId_; + /** + * int32 Permission_id = 5; + */ + public int getPermissionId() { + return permissionId_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != org.tron.protos.Protocol.Transaction.Contract.ContractType.AccountCreateContract.getNumber()) { + output.writeEnum(1, type_); + } + if (parameter_ != null) { + output.writeMessage(2, getParameter()); + } + if (!provider_.isEmpty()) { + output.writeBytes(3, provider_); + } + if (!contractName_.isEmpty()) { + output.writeBytes(4, contractName_); + } + if (permissionId_ != 0) { + output.writeInt32(5, permissionId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != org.tron.protos.Protocol.Transaction.Contract.ContractType.AccountCreateContract.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, type_); + } + if (parameter_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getParameter()); + } + if (!provider_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, provider_); + } + if (!contractName_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, contractName_); + } + if (permissionId_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, permissionId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Transaction.Contract)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Transaction.Contract other = (org.tron.protos.Protocol.Transaction.Contract) obj; + + boolean result = true; + result = result && type_ == other.type_; + result = result && (hasParameter() == other.hasParameter()); + if (hasParameter()) { + result = result && getParameter() + .equals(other.getParameter()); + } + result = result && getProvider() + .equals(other.getProvider()); + result = result && getContractName() + .equals(other.getContractName()); + result = result && (getPermissionId() + == other.getPermissionId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + if (hasParameter()) { + hash = (37 * hash) + PARAMETER_FIELD_NUMBER; + hash = (53 * hash) + getParameter().hashCode(); + } + hash = (37 * hash) + PROVIDER_FIELD_NUMBER; + hash = (53 * hash) + getProvider().hashCode(); + hash = (37 * hash) + CONTRACTNAME_FIELD_NUMBER; + hash = (53 * hash) + getContractName().hashCode(); + hash = (37 * hash) + PERMISSION_ID_FIELD_NUMBER; + hash = (53 * hash) + getPermissionId(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Contract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.Contract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.Contract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Transaction.Contract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Transaction.Contract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Transaction.Contract) + org.tron.protos.Protocol.Transaction.ContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Contract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Contract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.Contract.class, org.tron.protos.Protocol.Transaction.Contract.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Transaction.Contract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + type_ = 0; + + if (parameterBuilder_ == null) { + parameter_ = null; + } else { + parameter_ = null; + parameterBuilder_ = null; + } + provider_ = com.google.protobuf.ByteString.EMPTY; + + contractName_ = com.google.protobuf.ByteString.EMPTY; + + permissionId_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Contract_descriptor; + } + + public org.tron.protos.Protocol.Transaction.Contract getDefaultInstanceForType() { + return org.tron.protos.Protocol.Transaction.Contract.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Transaction.Contract build() { + org.tron.protos.Protocol.Transaction.Contract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Transaction.Contract buildPartial() { + org.tron.protos.Protocol.Transaction.Contract result = new org.tron.protos.Protocol.Transaction.Contract(this); + result.type_ = type_; + if (parameterBuilder_ == null) { + result.parameter_ = parameter_; + } else { + result.parameter_ = parameterBuilder_.build(); + } + result.provider_ = provider_; + result.contractName_ = contractName_; + result.permissionId_ = permissionId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Transaction.Contract) { + return mergeFrom((org.tron.protos.Protocol.Transaction.Contract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Transaction.Contract other) { + if (other == org.tron.protos.Protocol.Transaction.Contract.getDefaultInstance()) return this; + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.hasParameter()) { + mergeParameter(other.getParameter()); + } + if (other.getProvider() != com.google.protobuf.ByteString.EMPTY) { + setProvider(other.getProvider()); + } + if (other.getContractName() != com.google.protobuf.ByteString.EMPTY) { + setContractName(other.getContractName()); + } + if (other.getPermissionId() != 0) { + setPermissionId(other.getPermissionId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Transaction.Contract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Transaction.Contract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int type_ = 0; + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + public org.tron.protos.Protocol.Transaction.Contract.ContractType getType() { + org.tron.protos.Protocol.Transaction.Contract.ContractType result = org.tron.protos.Protocol.Transaction.Contract.ContractType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Transaction.Contract.ContractType.UNRECOGNIZED : result; + } + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + public Builder setType(org.tron.protos.Protocol.Transaction.Contract.ContractType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Transaction.Contract.ContractType type = 1; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Any parameter_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> parameterBuilder_; + /** + * .google.protobuf.Any parameter = 2; + */ + public boolean hasParameter() { + return parameterBuilder_ != null || parameter_ != null; + } + /** + * .google.protobuf.Any parameter = 2; + */ + public com.google.protobuf.Any getParameter() { + if (parameterBuilder_ == null) { + return parameter_ == null ? com.google.protobuf.Any.getDefaultInstance() : parameter_; + } else { + return parameterBuilder_.getMessage(); + } + } + /** + * .google.protobuf.Any parameter = 2; + */ + public Builder setParameter(com.google.protobuf.Any value) { + if (parameterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + parameter_ = value; + onChanged(); + } else { + parameterBuilder_.setMessage(value); + } + + return this; + } + /** + * .google.protobuf.Any parameter = 2; + */ + public Builder setParameter( + com.google.protobuf.Any.Builder builderForValue) { + if (parameterBuilder_ == null) { + parameter_ = builderForValue.build(); + onChanged(); + } else { + parameterBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .google.protobuf.Any parameter = 2; + */ + public Builder mergeParameter(com.google.protobuf.Any value) { + if (parameterBuilder_ == null) { + if (parameter_ != null) { + parameter_ = + com.google.protobuf.Any.newBuilder(parameter_).mergeFrom(value).buildPartial(); + } else { + parameter_ = value; + } + onChanged(); + } else { + parameterBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .google.protobuf.Any parameter = 2; + */ + public Builder clearParameter() { + if (parameterBuilder_ == null) { + parameter_ = null; + onChanged(); + } else { + parameter_ = null; + parameterBuilder_ = null; + } + + return this; + } + /** + * .google.protobuf.Any parameter = 2; + */ + public com.google.protobuf.Any.Builder getParameterBuilder() { + + onChanged(); + return getParameterFieldBuilder().getBuilder(); + } + /** + * .google.protobuf.Any parameter = 2; + */ + public com.google.protobuf.AnyOrBuilder getParameterOrBuilder() { + if (parameterBuilder_ != null) { + return parameterBuilder_.getMessageOrBuilder(); + } else { + return parameter_ == null ? + com.google.protobuf.Any.getDefaultInstance() : parameter_; + } + } + /** + * .google.protobuf.Any parameter = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> + getParameterFieldBuilder() { + if (parameterBuilder_ == null) { + parameterBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( + getParameter(), + getParentForChildren(), + isClean()); + parameter_ = null; + } + return parameterBuilder_; + } + + private com.google.protobuf.ByteString provider_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes provider = 3; + */ + public com.google.protobuf.ByteString getProvider() { + return provider_; + } + /** + * bytes provider = 3; + */ + public Builder setProvider(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + provider_ = value; + onChanged(); + return this; + } + /** + * bytes provider = 3; + */ + public Builder clearProvider() { + + provider_ = getDefaultInstance().getProvider(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString contractName_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes ContractName = 4; + */ + public com.google.protobuf.ByteString getContractName() { + return contractName_; + } + /** + * bytes ContractName = 4; + */ + public Builder setContractName(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + contractName_ = value; + onChanged(); + return this; + } + /** + * bytes ContractName = 4; + */ + public Builder clearContractName() { + + contractName_ = getDefaultInstance().getContractName(); + onChanged(); + return this; + } + + private int permissionId_ ; + /** + * int32 Permission_id = 5; + */ + public int getPermissionId() { + return permissionId_; + } + /** + * int32 Permission_id = 5; + */ + public Builder setPermissionId(int value) { + + permissionId_ = value; + onChanged(); + return this; + } + /** + * int32 Permission_id = 5; + */ + public Builder clearPermissionId() { + + permissionId_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Transaction.Contract) + } + + // @@protoc_insertion_point(class_scope:protocol.Transaction.Contract) + private static final org.tron.protos.Protocol.Transaction.Contract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Transaction.Contract(); + } + + public static org.tron.protos.Protocol.Transaction.Contract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Contract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Contract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Transaction.Contract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ResultOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Transaction.Result) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 fee = 1; + */ + long getFee(); + + /** + * .protocol.Transaction.Result.code ret = 2; + */ + int getRetValue(); + /** + * .protocol.Transaction.Result.code ret = 2; + */ + org.tron.protos.Protocol.Transaction.Result.code getRet(); + + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + int getContractRetValue(); + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + org.tron.protos.Protocol.Transaction.Result.contractResult getContractRet(); + + /** + * string assetIssueID = 14; + */ + java.lang.String getAssetIssueID(); + /** + * string assetIssueID = 14; + */ + com.google.protobuf.ByteString + getAssetIssueIDBytes(); + + /** + * int64 withdraw_amount = 15; + */ + long getWithdrawAmount(); + + /** + * int64 unfreeze_amount = 16; + */ + long getUnfreezeAmount(); + + /** + * int64 exchange_received_amount = 18; + */ + long getExchangeReceivedAmount(); + + /** + * int64 exchange_inject_another_amount = 19; + */ + long getExchangeInjectAnotherAmount(); + + /** + * int64 exchange_withdraw_another_amount = 20; + */ + long getExchangeWithdrawAnotherAmount(); + + /** + * int64 exchange_id = 21; + */ + long getExchangeId(); + } + /** + * Protobuf type {@code protocol.Transaction.Result} + */ + public static final class Result extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Transaction.Result) + ResultOrBuilder { + private static final long serialVersionUID = 0L; + // Use Result.newBuilder() to construct. + private Result(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Result() { + fee_ = 0L; + ret_ = 0; + contractRet_ = 0; + assetIssueID_ = ""; + withdrawAmount_ = 0L; + unfreezeAmount_ = 0L; + exchangeReceivedAmount_ = 0L; + exchangeInjectAnotherAmount_ = 0L; + exchangeWithdrawAnotherAmount_ = 0L; + exchangeId_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Result( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + fee_ = input.readInt64(); + break; + } + case 16: { + int rawValue = input.readEnum(); + + ret_ = rawValue; + break; + } + case 24: { + int rawValue = input.readEnum(); + + contractRet_ = rawValue; + break; + } + case 114: { + java.lang.String s = input.readStringRequireUtf8(); + + assetIssueID_ = s; + break; + } + case 120: { + + withdrawAmount_ = input.readInt64(); + break; + } + case 128: { + + unfreezeAmount_ = input.readInt64(); + break; + } + case 144: { + + exchangeReceivedAmount_ = input.readInt64(); + break; + } + case 152: { + + exchangeInjectAnotherAmount_ = input.readInt64(); + break; + } + case 160: { + + exchangeWithdrawAnotherAmount_ = input.readInt64(); + break; + } + case 168: { + + exchangeId_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Result_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Result_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.Result.class, org.tron.protos.Protocol.Transaction.Result.Builder.class); + } + + /** + * Protobuf enum {@code protocol.Transaction.Result.code} + */ + public enum code + implements com.google.protobuf.ProtocolMessageEnum { + /** + * SUCESS = 0; + */ + SUCESS(0), + /** + * FAILED = 1; + */ + FAILED(1), + UNRECOGNIZED(-1), + ; + + /** + * SUCESS = 0; + */ + public static final int SUCESS_VALUE = 0; + /** + * FAILED = 1; + */ + public static final int FAILED_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static code valueOf(int value) { + return forNumber(value); + } + + public static code forNumber(int value) { + switch (value) { + case 0: return SUCESS; + case 1: return FAILED; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public code findValueByNumber(int number) { + return code.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.Transaction.Result.getDescriptor().getEnumTypes().get(0); + } + + private static final code[] VALUES = values(); + + public static code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private code(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Transaction.Result.code) + } + + /** + * Protobuf enum {@code protocol.Transaction.Result.contractResult} + */ + public enum contractResult + implements com.google.protobuf.ProtocolMessageEnum { + /** + * DEFAULT = 0; + */ + DEFAULT(0), + /** + * SUCCESS = 1; + */ + SUCCESS(1), + /** + * REVERT = 2; + */ + REVERT(2), + /** + * BAD_JUMP_DESTINATION = 3; + */ + BAD_JUMP_DESTINATION(3), + /** + * OUT_OF_MEMORY = 4; + */ + OUT_OF_MEMORY(4), + /** + * PRECOMPILED_CONTRACT = 5; + */ + PRECOMPILED_CONTRACT(5), + /** + * STACK_TOO_SMALL = 6; + */ + STACK_TOO_SMALL(6), + /** + * STACK_TOO_LARGE = 7; + */ + STACK_TOO_LARGE(7), + /** + * ILLEGAL_OPERATION = 8; + */ + ILLEGAL_OPERATION(8), + /** + * STACK_OVERFLOW = 9; + */ + STACK_OVERFLOW(9), + /** + * OUT_OF_ENERGY = 10; + */ + OUT_OF_ENERGY(10), + /** + * OUT_OF_TIME = 11; + */ + OUT_OF_TIME(11), + /** + * JVM_STACK_OVER_FLOW = 12; + */ + JVM_STACK_OVER_FLOW(12), + /** + * UNKNOWN = 13; + */ + UNKNOWN(13), + /** + * TRANSFER_FAILED = 14; + */ + TRANSFER_FAILED(14), + UNRECOGNIZED(-1), + ; + + /** + * DEFAULT = 0; + */ + public static final int DEFAULT_VALUE = 0; + /** + * SUCCESS = 1; + */ + public static final int SUCCESS_VALUE = 1; + /** + * REVERT = 2; + */ + public static final int REVERT_VALUE = 2; + /** + * BAD_JUMP_DESTINATION = 3; + */ + public static final int BAD_JUMP_DESTINATION_VALUE = 3; + /** + * OUT_OF_MEMORY = 4; + */ + public static final int OUT_OF_MEMORY_VALUE = 4; + /** + * PRECOMPILED_CONTRACT = 5; + */ + public static final int PRECOMPILED_CONTRACT_VALUE = 5; + /** + * STACK_TOO_SMALL = 6; + */ + public static final int STACK_TOO_SMALL_VALUE = 6; + /** + * STACK_TOO_LARGE = 7; + */ + public static final int STACK_TOO_LARGE_VALUE = 7; + /** + * ILLEGAL_OPERATION = 8; + */ + public static final int ILLEGAL_OPERATION_VALUE = 8; + /** + * STACK_OVERFLOW = 9; + */ + public static final int STACK_OVERFLOW_VALUE = 9; + /** + * OUT_OF_ENERGY = 10; + */ + public static final int OUT_OF_ENERGY_VALUE = 10; + /** + * OUT_OF_TIME = 11; + */ + public static final int OUT_OF_TIME_VALUE = 11; + /** + * JVM_STACK_OVER_FLOW = 12; + */ + public static final int JVM_STACK_OVER_FLOW_VALUE = 12; + /** + * UNKNOWN = 13; + */ + public static final int UNKNOWN_VALUE = 13; + /** + * TRANSFER_FAILED = 14; + */ + public static final int TRANSFER_FAILED_VALUE = 14; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static contractResult valueOf(int value) { + return forNumber(value); + } + + public static contractResult forNumber(int value) { + switch (value) { + case 0: return DEFAULT; + case 1: return SUCCESS; + case 2: return REVERT; + case 3: return BAD_JUMP_DESTINATION; + case 4: return OUT_OF_MEMORY; + case 5: return PRECOMPILED_CONTRACT; + case 6: return STACK_TOO_SMALL; + case 7: return STACK_TOO_LARGE; + case 8: return ILLEGAL_OPERATION; + case 9: return STACK_OVERFLOW; + case 10: return OUT_OF_ENERGY; + case 11: return OUT_OF_TIME; + case 12: return JVM_STACK_OVER_FLOW; + case 13: return UNKNOWN; + case 14: return TRANSFER_FAILED; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + contractResult> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public contractResult findValueByNumber(int number) { + return contractResult.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.Transaction.Result.getDescriptor().getEnumTypes().get(1); + } + + private static final contractResult[] VALUES = values(); + + public static contractResult valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private contractResult(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Transaction.Result.contractResult) + } + + public static final int FEE_FIELD_NUMBER = 1; + private long fee_; + /** + * int64 fee = 1; + */ + public long getFee() { + return fee_; + } + + public static final int RET_FIELD_NUMBER = 2; + private int ret_; + /** + * .protocol.Transaction.Result.code ret = 2; + */ + public int getRetValue() { + return ret_; + } + /** + * .protocol.Transaction.Result.code ret = 2; + */ + public org.tron.protos.Protocol.Transaction.Result.code getRet() { + org.tron.protos.Protocol.Transaction.Result.code result = org.tron.protos.Protocol.Transaction.Result.code.valueOf(ret_); + return result == null ? org.tron.protos.Protocol.Transaction.Result.code.UNRECOGNIZED : result; + } + + public static final int CONTRACTRET_FIELD_NUMBER = 3; + private int contractRet_; + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + public int getContractRetValue() { + return contractRet_; + } + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + public org.tron.protos.Protocol.Transaction.Result.contractResult getContractRet() { + org.tron.protos.Protocol.Transaction.Result.contractResult result = org.tron.protos.Protocol.Transaction.Result.contractResult.valueOf(contractRet_); + return result == null ? org.tron.protos.Protocol.Transaction.Result.contractResult.UNRECOGNIZED : result; + } + + public static final int ASSETISSUEID_FIELD_NUMBER = 14; + private volatile java.lang.Object assetIssueID_; + /** + * string assetIssueID = 14; + */ + public java.lang.String getAssetIssueID() { + java.lang.Object ref = assetIssueID_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetIssueID_ = s; + return s; + } + } + /** + * string assetIssueID = 14; + */ + public com.google.protobuf.ByteString + getAssetIssueIDBytes() { + java.lang.Object ref = assetIssueID_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetIssueID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int WITHDRAW_AMOUNT_FIELD_NUMBER = 15; + private long withdrawAmount_; + /** + * int64 withdraw_amount = 15; + */ + public long getWithdrawAmount() { + return withdrawAmount_; + } + + public static final int UNFREEZE_AMOUNT_FIELD_NUMBER = 16; + private long unfreezeAmount_; + /** + * int64 unfreeze_amount = 16; + */ + public long getUnfreezeAmount() { + return unfreezeAmount_; + } + + public static final int EXCHANGE_RECEIVED_AMOUNT_FIELD_NUMBER = 18; + private long exchangeReceivedAmount_; + /** + * int64 exchange_received_amount = 18; + */ + public long getExchangeReceivedAmount() { + return exchangeReceivedAmount_; + } + + public static final int EXCHANGE_INJECT_ANOTHER_AMOUNT_FIELD_NUMBER = 19; + private long exchangeInjectAnotherAmount_; + /** + * int64 exchange_inject_another_amount = 19; + */ + public long getExchangeInjectAnotherAmount() { + return exchangeInjectAnotherAmount_; + } + + public static final int EXCHANGE_WITHDRAW_ANOTHER_AMOUNT_FIELD_NUMBER = 20; + private long exchangeWithdrawAnotherAmount_; + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public long getExchangeWithdrawAnotherAmount() { + return exchangeWithdrawAnotherAmount_; + } + + public static final int EXCHANGE_ID_FIELD_NUMBER = 21; + private long exchangeId_; + /** + * int64 exchange_id = 21; + */ + public long getExchangeId() { + return exchangeId_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (fee_ != 0L) { + output.writeInt64(1, fee_); + } + if (ret_ != org.tron.protos.Protocol.Transaction.Result.code.SUCESS.getNumber()) { + output.writeEnum(2, ret_); + } + if (contractRet_ != org.tron.protos.Protocol.Transaction.Result.contractResult.DEFAULT.getNumber()) { + output.writeEnum(3, contractRet_); + } + if (!getAssetIssueIDBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 14, assetIssueID_); + } + if (withdrawAmount_ != 0L) { + output.writeInt64(15, withdrawAmount_); + } + if (unfreezeAmount_ != 0L) { + output.writeInt64(16, unfreezeAmount_); + } + if (exchangeReceivedAmount_ != 0L) { + output.writeInt64(18, exchangeReceivedAmount_); + } + if (exchangeInjectAnotherAmount_ != 0L) { + output.writeInt64(19, exchangeInjectAnotherAmount_); + } + if (exchangeWithdrawAnotherAmount_ != 0L) { + output.writeInt64(20, exchangeWithdrawAnotherAmount_); + } + if (exchangeId_ != 0L) { + output.writeInt64(21, exchangeId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (fee_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, fee_); + } + if (ret_ != org.tron.protos.Protocol.Transaction.Result.code.SUCESS.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, ret_); + } + if (contractRet_ != org.tron.protos.Protocol.Transaction.Result.contractResult.DEFAULT.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(3, contractRet_); + } + if (!getAssetIssueIDBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(14, assetIssueID_); + } + if (withdrawAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(15, withdrawAmount_); + } + if (unfreezeAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(16, unfreezeAmount_); + } + if (exchangeReceivedAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(18, exchangeReceivedAmount_); + } + if (exchangeInjectAnotherAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(19, exchangeInjectAnotherAmount_); + } + if (exchangeWithdrawAnotherAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(20, exchangeWithdrawAnotherAmount_); + } + if (exchangeId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(21, exchangeId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Transaction.Result)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Transaction.Result other = (org.tron.protos.Protocol.Transaction.Result) obj; + + boolean result = true; + result = result && (getFee() + == other.getFee()); + result = result && ret_ == other.ret_; + result = result && contractRet_ == other.contractRet_; + result = result && getAssetIssueID() + .equals(other.getAssetIssueID()); + result = result && (getWithdrawAmount() + == other.getWithdrawAmount()); + result = result && (getUnfreezeAmount() + == other.getUnfreezeAmount()); + result = result && (getExchangeReceivedAmount() + == other.getExchangeReceivedAmount()); + result = result && (getExchangeInjectAnotherAmount() + == other.getExchangeInjectAnotherAmount()); + result = result && (getExchangeWithdrawAnotherAmount() + == other.getExchangeWithdrawAnotherAmount()); + result = result && (getExchangeId() + == other.getExchangeId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FEE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFee()); + hash = (37 * hash) + RET_FIELD_NUMBER; + hash = (53 * hash) + ret_; + hash = (37 * hash) + CONTRACTRET_FIELD_NUMBER; + hash = (53 * hash) + contractRet_; + hash = (37 * hash) + ASSETISSUEID_FIELD_NUMBER; + hash = (53 * hash) + getAssetIssueID().hashCode(); + hash = (37 * hash) + WITHDRAW_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getWithdrawAmount()); + hash = (37 * hash) + UNFREEZE_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getUnfreezeAmount()); + hash = (37 * hash) + EXCHANGE_RECEIVED_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeReceivedAmount()); + hash = (37 * hash) + EXCHANGE_INJECT_ANOTHER_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeInjectAnotherAmount()); + hash = (37 * hash) + EXCHANGE_WITHDRAW_ANOTHER_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeWithdrawAnotherAmount()); + hash = (37 * hash) + EXCHANGE_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Result parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.Result parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.Result parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Transaction.Result prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Transaction.Result} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Transaction.Result) + org.tron.protos.Protocol.Transaction.ResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Result_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Result_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.Result.class, org.tron.protos.Protocol.Transaction.Result.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Transaction.Result.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + fee_ = 0L; + + ret_ = 0; + + contractRet_ = 0; + + assetIssueID_ = ""; + + withdrawAmount_ = 0L; + + unfreezeAmount_ = 0L; + + exchangeReceivedAmount_ = 0L; + + exchangeInjectAnotherAmount_ = 0L; + + exchangeWithdrawAnotherAmount_ = 0L; + + exchangeId_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_Result_descriptor; + } + + public org.tron.protos.Protocol.Transaction.Result getDefaultInstanceForType() { + return org.tron.protos.Protocol.Transaction.Result.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Transaction.Result build() { + org.tron.protos.Protocol.Transaction.Result result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Transaction.Result buildPartial() { + org.tron.protos.Protocol.Transaction.Result result = new org.tron.protos.Protocol.Transaction.Result(this); + result.fee_ = fee_; + result.ret_ = ret_; + result.contractRet_ = contractRet_; + result.assetIssueID_ = assetIssueID_; + result.withdrawAmount_ = withdrawAmount_; + result.unfreezeAmount_ = unfreezeAmount_; + result.exchangeReceivedAmount_ = exchangeReceivedAmount_; + result.exchangeInjectAnotherAmount_ = exchangeInjectAnotherAmount_; + result.exchangeWithdrawAnotherAmount_ = exchangeWithdrawAnotherAmount_; + result.exchangeId_ = exchangeId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Transaction.Result) { + return mergeFrom((org.tron.protos.Protocol.Transaction.Result)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Transaction.Result other) { + if (other == org.tron.protos.Protocol.Transaction.Result.getDefaultInstance()) return this; + if (other.getFee() != 0L) { + setFee(other.getFee()); + } + if (other.ret_ != 0) { + setRetValue(other.getRetValue()); + } + if (other.contractRet_ != 0) { + setContractRetValue(other.getContractRetValue()); + } + if (!other.getAssetIssueID().isEmpty()) { + assetIssueID_ = other.assetIssueID_; + onChanged(); + } + if (other.getWithdrawAmount() != 0L) { + setWithdrawAmount(other.getWithdrawAmount()); + } + if (other.getUnfreezeAmount() != 0L) { + setUnfreezeAmount(other.getUnfreezeAmount()); + } + if (other.getExchangeReceivedAmount() != 0L) { + setExchangeReceivedAmount(other.getExchangeReceivedAmount()); + } + if (other.getExchangeInjectAnotherAmount() != 0L) { + setExchangeInjectAnotherAmount(other.getExchangeInjectAnotherAmount()); + } + if (other.getExchangeWithdrawAnotherAmount() != 0L) { + setExchangeWithdrawAnotherAmount(other.getExchangeWithdrawAnotherAmount()); + } + if (other.getExchangeId() != 0L) { + setExchangeId(other.getExchangeId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Transaction.Result parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Transaction.Result) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long fee_ ; + /** + * int64 fee = 1; + */ + public long getFee() { + return fee_; + } + /** + * int64 fee = 1; + */ + public Builder setFee(long value) { + + fee_ = value; + onChanged(); + return this; + } + /** + * int64 fee = 1; + */ + public Builder clearFee() { + + fee_ = 0L; + onChanged(); + return this; + } + + private int ret_ = 0; + /** + * .protocol.Transaction.Result.code ret = 2; + */ + public int getRetValue() { + return ret_; + } + /** + * .protocol.Transaction.Result.code ret = 2; + */ + public Builder setRetValue(int value) { + ret_ = value; + onChanged(); + return this; + } + /** + * .protocol.Transaction.Result.code ret = 2; + */ + public org.tron.protos.Protocol.Transaction.Result.code getRet() { + org.tron.protos.Protocol.Transaction.Result.code result = org.tron.protos.Protocol.Transaction.Result.code.valueOf(ret_); + return result == null ? org.tron.protos.Protocol.Transaction.Result.code.UNRECOGNIZED : result; + } + /** + * .protocol.Transaction.Result.code ret = 2; + */ + public Builder setRet(org.tron.protos.Protocol.Transaction.Result.code value) { + if (value == null) { + throw new NullPointerException(); + } + + ret_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Transaction.Result.code ret = 2; + */ + public Builder clearRet() { + + ret_ = 0; + onChanged(); + return this; + } + + private int contractRet_ = 0; + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + public int getContractRetValue() { + return contractRet_; + } + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + public Builder setContractRetValue(int value) { + contractRet_ = value; + onChanged(); + return this; + } + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + public org.tron.protos.Protocol.Transaction.Result.contractResult getContractRet() { + org.tron.protos.Protocol.Transaction.Result.contractResult result = org.tron.protos.Protocol.Transaction.Result.contractResult.valueOf(contractRet_); + return result == null ? org.tron.protos.Protocol.Transaction.Result.contractResult.UNRECOGNIZED : result; + } + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + public Builder setContractRet(org.tron.protos.Protocol.Transaction.Result.contractResult value) { + if (value == null) { + throw new NullPointerException(); + } + + contractRet_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Transaction.Result.contractResult contractRet = 3; + */ + public Builder clearContractRet() { + + contractRet_ = 0; + onChanged(); + return this; + } + + private java.lang.Object assetIssueID_ = ""; + /** + * string assetIssueID = 14; + */ + public java.lang.String getAssetIssueID() { + java.lang.Object ref = assetIssueID_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetIssueID_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string assetIssueID = 14; + */ + public com.google.protobuf.ByteString + getAssetIssueIDBytes() { + java.lang.Object ref = assetIssueID_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetIssueID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string assetIssueID = 14; + */ + public Builder setAssetIssueID( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + assetIssueID_ = value; + onChanged(); + return this; + } + /** + * string assetIssueID = 14; + */ + public Builder clearAssetIssueID() { + + assetIssueID_ = getDefaultInstance().getAssetIssueID(); + onChanged(); + return this; + } + /** + * string assetIssueID = 14; + */ + public Builder setAssetIssueIDBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + assetIssueID_ = value; + onChanged(); + return this; + } + + private long withdrawAmount_ ; + /** + * int64 withdraw_amount = 15; + */ + public long getWithdrawAmount() { + return withdrawAmount_; + } + /** + * int64 withdraw_amount = 15; + */ + public Builder setWithdrawAmount(long value) { + + withdrawAmount_ = value; + onChanged(); + return this; + } + /** + * int64 withdraw_amount = 15; + */ + public Builder clearWithdrawAmount() { + + withdrawAmount_ = 0L; + onChanged(); + return this; + } + + private long unfreezeAmount_ ; + /** + * int64 unfreeze_amount = 16; + */ + public long getUnfreezeAmount() { + return unfreezeAmount_; + } + /** + * int64 unfreeze_amount = 16; + */ + public Builder setUnfreezeAmount(long value) { + + unfreezeAmount_ = value; + onChanged(); + return this; + } + /** + * int64 unfreeze_amount = 16; + */ + public Builder clearUnfreezeAmount() { + + unfreezeAmount_ = 0L; + onChanged(); + return this; + } + + private long exchangeReceivedAmount_ ; + /** + * int64 exchange_received_amount = 18; + */ + public long getExchangeReceivedAmount() { + return exchangeReceivedAmount_; + } + /** + * int64 exchange_received_amount = 18; + */ + public Builder setExchangeReceivedAmount(long value) { + + exchangeReceivedAmount_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_received_amount = 18; + */ + public Builder clearExchangeReceivedAmount() { + + exchangeReceivedAmount_ = 0L; + onChanged(); + return this; + } + + private long exchangeInjectAnotherAmount_ ; + /** + * int64 exchange_inject_another_amount = 19; + */ + public long getExchangeInjectAnotherAmount() { + return exchangeInjectAnotherAmount_; + } + /** + * int64 exchange_inject_another_amount = 19; + */ + public Builder setExchangeInjectAnotherAmount(long value) { + + exchangeInjectAnotherAmount_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_inject_another_amount = 19; + */ + public Builder clearExchangeInjectAnotherAmount() { + + exchangeInjectAnotherAmount_ = 0L; + onChanged(); + return this; + } + + private long exchangeWithdrawAnotherAmount_ ; + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public long getExchangeWithdrawAnotherAmount() { + return exchangeWithdrawAnotherAmount_; + } + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public Builder setExchangeWithdrawAnotherAmount(long value) { + + exchangeWithdrawAnotherAmount_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public Builder clearExchangeWithdrawAnotherAmount() { + + exchangeWithdrawAnotherAmount_ = 0L; + onChanged(); + return this; + } + + private long exchangeId_ ; + /** + * int64 exchange_id = 21; + */ + public long getExchangeId() { + return exchangeId_; + } + /** + * int64 exchange_id = 21; + */ + public Builder setExchangeId(long value) { + + exchangeId_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_id = 21; + */ + public Builder clearExchangeId() { + + exchangeId_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Transaction.Result) + } + + // @@protoc_insertion_point(class_scope:protocol.Transaction.Result) + private static final org.tron.protos.Protocol.Transaction.Result DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Transaction.Result(); + } + + public static org.tron.protos.Protocol.Transaction.Result getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Result parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Result(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Transaction.Result getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface rawOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Transaction.raw) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes ref_block_bytes = 1; + */ + com.google.protobuf.ByteString getRefBlockBytes(); + + /** + * int64 ref_block_num = 3; + */ + long getRefBlockNum(); + + /** + * bytes ref_block_hash = 4; + */ + com.google.protobuf.ByteString getRefBlockHash(); + + /** + * int64 expiration = 8; + */ + long getExpiration(); + + /** + * repeated .protocol.authority auths = 9; + */ + java.util.List + getAuthsList(); + /** + * repeated .protocol.authority auths = 9; + */ + org.tron.protos.Protocol.authority getAuths(int index); + /** + * repeated .protocol.authority auths = 9; + */ + int getAuthsCount(); + /** + * repeated .protocol.authority auths = 9; + */ + java.util.List + getAuthsOrBuilderList(); + /** + * repeated .protocol.authority auths = 9; + */ + org.tron.protos.Protocol.authorityOrBuilder getAuthsOrBuilder( + int index); + + /** + *
+       * data not used
+       * 
+ * + * bytes data = 10; + */ + com.google.protobuf.ByteString getData(); + + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + java.util.List + getContractList(); + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + org.tron.protos.Protocol.Transaction.Contract getContract(int index); + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + int getContractCount(); + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + java.util.List + getContractOrBuilderList(); + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + org.tron.protos.Protocol.Transaction.ContractOrBuilder getContractOrBuilder( + int index); + + /** + *
+       * scripts not used
+       * 
+ * + * bytes scripts = 12; + */ + com.google.protobuf.ByteString getScripts(); + + /** + * int64 timestamp = 14; + */ + long getTimestamp(); + + /** + * int64 fee_limit = 18; + */ + long getFeeLimit(); + } + /** + * Protobuf type {@code protocol.Transaction.raw} + */ + public static final class raw extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Transaction.raw) + rawOrBuilder { + private static final long serialVersionUID = 0L; + // Use raw.newBuilder() to construct. + private raw(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private raw() { + refBlockBytes_ = com.google.protobuf.ByteString.EMPTY; + refBlockNum_ = 0L; + refBlockHash_ = com.google.protobuf.ByteString.EMPTY; + expiration_ = 0L; + auths_ = java.util.Collections.emptyList(); + data_ = com.google.protobuf.ByteString.EMPTY; + contract_ = java.util.Collections.emptyList(); + scripts_ = com.google.protobuf.ByteString.EMPTY; + timestamp_ = 0L; + feeLimit_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private raw( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + refBlockBytes_ = input.readBytes(); + break; + } + case 24: { + + refBlockNum_ = input.readInt64(); + break; + } + case 34: { + + refBlockHash_ = input.readBytes(); + break; + } + case 64: { + + expiration_ = input.readInt64(); + break; + } + case 74: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + auths_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + auths_.add( + input.readMessage(org.tron.protos.Protocol.authority.parser(), extensionRegistry)); + break; + } + case 82: { + + data_ = input.readBytes(); + break; + } + case 90: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + contract_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + contract_.add( + input.readMessage(org.tron.protos.Protocol.Transaction.Contract.parser(), extensionRegistry)); + break; + } + case 98: { + + scripts_ = input.readBytes(); + break; + } + case 112: { + + timestamp_ = input.readInt64(); + break; + } + case 144: { + + feeLimit_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + auths_ = java.util.Collections.unmodifiableList(auths_); + } + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + contract_ = java.util.Collections.unmodifiableList(contract_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_raw_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_raw_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.raw.class, org.tron.protos.Protocol.Transaction.raw.Builder.class); + } + + private int bitField0_; + public static final int REF_BLOCK_BYTES_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString refBlockBytes_; + /** + * bytes ref_block_bytes = 1; + */ + public com.google.protobuf.ByteString getRefBlockBytes() { + return refBlockBytes_; + } + + public static final int REF_BLOCK_NUM_FIELD_NUMBER = 3; + private long refBlockNum_; + /** + * int64 ref_block_num = 3; + */ + public long getRefBlockNum() { + return refBlockNum_; + } + + public static final int REF_BLOCK_HASH_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString refBlockHash_; + /** + * bytes ref_block_hash = 4; + */ + public com.google.protobuf.ByteString getRefBlockHash() { + return refBlockHash_; + } + + public static final int EXPIRATION_FIELD_NUMBER = 8; + private long expiration_; + /** + * int64 expiration = 8; + */ + public long getExpiration() { + return expiration_; + } + + public static final int AUTHS_FIELD_NUMBER = 9; + private java.util.List auths_; + /** + * repeated .protocol.authority auths = 9; + */ + public java.util.List getAuthsList() { + return auths_; + } + /** + * repeated .protocol.authority auths = 9; + */ + public java.util.List + getAuthsOrBuilderList() { + return auths_; + } + /** + * repeated .protocol.authority auths = 9; + */ + public int getAuthsCount() { + return auths_.size(); + } + /** + * repeated .protocol.authority auths = 9; + */ + public org.tron.protos.Protocol.authority getAuths(int index) { + return auths_.get(index); + } + /** + * repeated .protocol.authority auths = 9; + */ + public org.tron.protos.Protocol.authorityOrBuilder getAuthsOrBuilder( + int index) { + return auths_.get(index); + } + + public static final int DATA_FIELD_NUMBER = 10; + private com.google.protobuf.ByteString data_; + /** + *
+       * data not used
+       * 
+ * + * bytes data = 10; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + + public static final int CONTRACT_FIELD_NUMBER = 11; + private java.util.List contract_; + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public java.util.List getContractList() { + return contract_; + } + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public java.util.List + getContractOrBuilderList() { + return contract_; + } + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public int getContractCount() { + return contract_.size(); + } + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public org.tron.protos.Protocol.Transaction.Contract getContract(int index) { + return contract_.get(index); + } + /** + *
+       *only support size = 1,  repeated list here for extension
+       * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public org.tron.protos.Protocol.Transaction.ContractOrBuilder getContractOrBuilder( + int index) { + return contract_.get(index); + } + + public static final int SCRIPTS_FIELD_NUMBER = 12; + private com.google.protobuf.ByteString scripts_; + /** + *
+       * scripts not used
+       * 
+ * + * bytes scripts = 12; + */ + public com.google.protobuf.ByteString getScripts() { + return scripts_; + } + + public static final int TIMESTAMP_FIELD_NUMBER = 14; + private long timestamp_; + /** + * int64 timestamp = 14; + */ + public long getTimestamp() { + return timestamp_; + } + + public static final int FEE_LIMIT_FIELD_NUMBER = 18; + private long feeLimit_; + /** + * int64 fee_limit = 18; + */ + public long getFeeLimit() { + return feeLimit_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!refBlockBytes_.isEmpty()) { + output.writeBytes(1, refBlockBytes_); + } + if (refBlockNum_ != 0L) { + output.writeInt64(3, refBlockNum_); + } + if (!refBlockHash_.isEmpty()) { + output.writeBytes(4, refBlockHash_); + } + if (expiration_ != 0L) { + output.writeInt64(8, expiration_); + } + for (int i = 0; i < auths_.size(); i++) { + output.writeMessage(9, auths_.get(i)); + } + if (!data_.isEmpty()) { + output.writeBytes(10, data_); + } + for (int i = 0; i < contract_.size(); i++) { + output.writeMessage(11, contract_.get(i)); + } + if (!scripts_.isEmpty()) { + output.writeBytes(12, scripts_); + } + if (timestamp_ != 0L) { + output.writeInt64(14, timestamp_); + } + if (feeLimit_ != 0L) { + output.writeInt64(18, feeLimit_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!refBlockBytes_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, refBlockBytes_); + } + if (refBlockNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, refBlockNum_); + } + if (!refBlockHash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, refBlockHash_); + } + if (expiration_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, expiration_); + } + for (int i = 0; i < auths_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(9, auths_.get(i)); + } + if (!data_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(10, data_); + } + for (int i = 0; i < contract_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(11, contract_.get(i)); + } + if (!scripts_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(12, scripts_); + } + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(14, timestamp_); + } + if (feeLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(18, feeLimit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Transaction.raw)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Transaction.raw other = (org.tron.protos.Protocol.Transaction.raw) obj; + + boolean result = true; + result = result && getRefBlockBytes() + .equals(other.getRefBlockBytes()); + result = result && (getRefBlockNum() + == other.getRefBlockNum()); + result = result && getRefBlockHash() + .equals(other.getRefBlockHash()); + result = result && (getExpiration() + == other.getExpiration()); + result = result && getAuthsList() + .equals(other.getAuthsList()); + result = result && getData() + .equals(other.getData()); + result = result && getContractList() + .equals(other.getContractList()); + result = result && getScripts() + .equals(other.getScripts()); + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && (getFeeLimit() + == other.getFeeLimit()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REF_BLOCK_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getRefBlockBytes().hashCode(); + hash = (37 * hash) + REF_BLOCK_NUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getRefBlockNum()); + hash = (37 * hash) + REF_BLOCK_HASH_FIELD_NUMBER; + hash = (53 * hash) + getRefBlockHash().hashCode(); + hash = (37 * hash) + EXPIRATION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExpiration()); + if (getAuthsCount() > 0) { + hash = (37 * hash) + AUTHS_FIELD_NUMBER; + hash = (53 * hash) + getAuthsList().hashCode(); + } + hash = (37 * hash) + DATA_FIELD_NUMBER; + hash = (53 * hash) + getData().hashCode(); + if (getContractCount() > 0) { + hash = (37 * hash) + CONTRACT_FIELD_NUMBER; + hash = (53 * hash) + getContractList().hashCode(); + } + hash = (37 * hash) + SCRIPTS_FIELD_NUMBER; + hash = (53 * hash) + getScripts().hashCode(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + hash = (37 * hash) + FEE_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFeeLimit()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.raw parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.raw parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction.raw parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Transaction.raw prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Transaction.raw} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Transaction.raw) + org.tron.protos.Protocol.Transaction.rawOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_raw_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_raw_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.raw.class, org.tron.protos.Protocol.Transaction.raw.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Transaction.raw.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getAuthsFieldBuilder(); + getContractFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + refBlockBytes_ = com.google.protobuf.ByteString.EMPTY; + + refBlockNum_ = 0L; + + refBlockHash_ = com.google.protobuf.ByteString.EMPTY; + + expiration_ = 0L; + + if (authsBuilder_ == null) { + auths_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + authsBuilder_.clear(); + } + data_ = com.google.protobuf.ByteString.EMPTY; + + if (contractBuilder_ == null) { + contract_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + } else { + contractBuilder_.clear(); + } + scripts_ = com.google.protobuf.ByteString.EMPTY; + + timestamp_ = 0L; + + feeLimit_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_raw_descriptor; + } + + public org.tron.protos.Protocol.Transaction.raw getDefaultInstanceForType() { + return org.tron.protos.Protocol.Transaction.raw.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Transaction.raw build() { + org.tron.protos.Protocol.Transaction.raw result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Transaction.raw buildPartial() { + org.tron.protos.Protocol.Transaction.raw result = new org.tron.protos.Protocol.Transaction.raw(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.refBlockBytes_ = refBlockBytes_; + result.refBlockNum_ = refBlockNum_; + result.refBlockHash_ = refBlockHash_; + result.expiration_ = expiration_; + if (authsBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + auths_ = java.util.Collections.unmodifiableList(auths_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.auths_ = auths_; + } else { + result.auths_ = authsBuilder_.build(); + } + result.data_ = data_; + if (contractBuilder_ == null) { + if (((bitField0_ & 0x00000040) == 0x00000040)) { + contract_ = java.util.Collections.unmodifiableList(contract_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.contract_ = contract_; + } else { + result.contract_ = contractBuilder_.build(); + } + result.scripts_ = scripts_; + result.timestamp_ = timestamp_; + result.feeLimit_ = feeLimit_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Transaction.raw) { + return mergeFrom((org.tron.protos.Protocol.Transaction.raw)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Transaction.raw other) { + if (other == org.tron.protos.Protocol.Transaction.raw.getDefaultInstance()) return this; + if (other.getRefBlockBytes() != com.google.protobuf.ByteString.EMPTY) { + setRefBlockBytes(other.getRefBlockBytes()); + } + if (other.getRefBlockNum() != 0L) { + setRefBlockNum(other.getRefBlockNum()); + } + if (other.getRefBlockHash() != com.google.protobuf.ByteString.EMPTY) { + setRefBlockHash(other.getRefBlockHash()); + } + if (other.getExpiration() != 0L) { + setExpiration(other.getExpiration()); + } + if (authsBuilder_ == null) { + if (!other.auths_.isEmpty()) { + if (auths_.isEmpty()) { + auths_ = other.auths_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureAuthsIsMutable(); + auths_.addAll(other.auths_); + } + onChanged(); + } + } else { + if (!other.auths_.isEmpty()) { + if (authsBuilder_.isEmpty()) { + authsBuilder_.dispose(); + authsBuilder_ = null; + auths_ = other.auths_; + bitField0_ = (bitField0_ & ~0x00000010); + authsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getAuthsFieldBuilder() : null; + } else { + authsBuilder_.addAllMessages(other.auths_); + } + } + } + if (other.getData() != com.google.protobuf.ByteString.EMPTY) { + setData(other.getData()); + } + if (contractBuilder_ == null) { + if (!other.contract_.isEmpty()) { + if (contract_.isEmpty()) { + contract_ = other.contract_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureContractIsMutable(); + contract_.addAll(other.contract_); + } + onChanged(); + } + } else { + if (!other.contract_.isEmpty()) { + if (contractBuilder_.isEmpty()) { + contractBuilder_.dispose(); + contractBuilder_ = null; + contract_ = other.contract_; + bitField0_ = (bitField0_ & ~0x00000040); + contractBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getContractFieldBuilder() : null; + } else { + contractBuilder_.addAllMessages(other.contract_); + } + } + } + if (other.getScripts() != com.google.protobuf.ByteString.EMPTY) { + setScripts(other.getScripts()); + } + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + if (other.getFeeLimit() != 0L) { + setFeeLimit(other.getFeeLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Transaction.raw parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Transaction.raw) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString refBlockBytes_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes ref_block_bytes = 1; + */ + public com.google.protobuf.ByteString getRefBlockBytes() { + return refBlockBytes_; + } + /** + * bytes ref_block_bytes = 1; + */ + public Builder setRefBlockBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + refBlockBytes_ = value; + onChanged(); + return this; + } + /** + * bytes ref_block_bytes = 1; + */ + public Builder clearRefBlockBytes() { + + refBlockBytes_ = getDefaultInstance().getRefBlockBytes(); + onChanged(); + return this; + } + + private long refBlockNum_ ; + /** + * int64 ref_block_num = 3; + */ + public long getRefBlockNum() { + return refBlockNum_; + } + /** + * int64 ref_block_num = 3; + */ + public Builder setRefBlockNum(long value) { + + refBlockNum_ = value; + onChanged(); + return this; + } + /** + * int64 ref_block_num = 3; + */ + public Builder clearRefBlockNum() { + + refBlockNum_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString refBlockHash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes ref_block_hash = 4; + */ + public com.google.protobuf.ByteString getRefBlockHash() { + return refBlockHash_; + } + /** + * bytes ref_block_hash = 4; + */ + public Builder setRefBlockHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + refBlockHash_ = value; + onChanged(); + return this; + } + /** + * bytes ref_block_hash = 4; + */ + public Builder clearRefBlockHash() { + + refBlockHash_ = getDefaultInstance().getRefBlockHash(); + onChanged(); + return this; + } + + private long expiration_ ; + /** + * int64 expiration = 8; + */ + public long getExpiration() { + return expiration_; + } + /** + * int64 expiration = 8; + */ + public Builder setExpiration(long value) { + + expiration_ = value; + onChanged(); + return this; + } + /** + * int64 expiration = 8; + */ + public Builder clearExpiration() { + + expiration_ = 0L; + onChanged(); + return this; + } + + private java.util.List auths_ = + java.util.Collections.emptyList(); + private void ensureAuthsIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + auths_ = new java.util.ArrayList(auths_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.authority, org.tron.protos.Protocol.authority.Builder, org.tron.protos.Protocol.authorityOrBuilder> authsBuilder_; + + /** + * repeated .protocol.authority auths = 9; + */ + public java.util.List getAuthsList() { + if (authsBuilder_ == null) { + return java.util.Collections.unmodifiableList(auths_); + } else { + return authsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.authority auths = 9; + */ + public int getAuthsCount() { + if (authsBuilder_ == null) { + return auths_.size(); + } else { + return authsBuilder_.getCount(); + } + } + /** + * repeated .protocol.authority auths = 9; + */ + public org.tron.protos.Protocol.authority getAuths(int index) { + if (authsBuilder_ == null) { + return auths_.get(index); + } else { + return authsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder setAuths( + int index, org.tron.protos.Protocol.authority value) { + if (authsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAuthsIsMutable(); + auths_.set(index, value); + onChanged(); + } else { + authsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder setAuths( + int index, org.tron.protos.Protocol.authority.Builder builderForValue) { + if (authsBuilder_ == null) { + ensureAuthsIsMutable(); + auths_.set(index, builderForValue.build()); + onChanged(); + } else { + authsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder addAuths(org.tron.protos.Protocol.authority value) { + if (authsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAuthsIsMutable(); + auths_.add(value); + onChanged(); + } else { + authsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder addAuths( + int index, org.tron.protos.Protocol.authority value) { + if (authsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAuthsIsMutable(); + auths_.add(index, value); + onChanged(); + } else { + authsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder addAuths( + org.tron.protos.Protocol.authority.Builder builderForValue) { + if (authsBuilder_ == null) { + ensureAuthsIsMutable(); + auths_.add(builderForValue.build()); + onChanged(); + } else { + authsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder addAuths( + int index, org.tron.protos.Protocol.authority.Builder builderForValue) { + if (authsBuilder_ == null) { + ensureAuthsIsMutable(); + auths_.add(index, builderForValue.build()); + onChanged(); + } else { + authsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder addAllAuths( + java.lang.Iterable values) { + if (authsBuilder_ == null) { + ensureAuthsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, auths_); + onChanged(); + } else { + authsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder clearAuths() { + if (authsBuilder_ == null) { + auths_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + authsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public Builder removeAuths(int index) { + if (authsBuilder_ == null) { + ensureAuthsIsMutable(); + auths_.remove(index); + onChanged(); + } else { + authsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.authority auths = 9; + */ + public org.tron.protos.Protocol.authority.Builder getAuthsBuilder( + int index) { + return getAuthsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.authority auths = 9; + */ + public org.tron.protos.Protocol.authorityOrBuilder getAuthsOrBuilder( + int index) { + if (authsBuilder_ == null) { + return auths_.get(index); } else { + return authsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.authority auths = 9; + */ + public java.util.List + getAuthsOrBuilderList() { + if (authsBuilder_ != null) { + return authsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(auths_); + } + } + /** + * repeated .protocol.authority auths = 9; + */ + public org.tron.protos.Protocol.authority.Builder addAuthsBuilder() { + return getAuthsFieldBuilder().addBuilder( + org.tron.protos.Protocol.authority.getDefaultInstance()); + } + /** + * repeated .protocol.authority auths = 9; + */ + public org.tron.protos.Protocol.authority.Builder addAuthsBuilder( + int index) { + return getAuthsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.authority.getDefaultInstance()); + } + /** + * repeated .protocol.authority auths = 9; + */ + public java.util.List + getAuthsBuilderList() { + return getAuthsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.authority, org.tron.protos.Protocol.authority.Builder, org.tron.protos.Protocol.authorityOrBuilder> + getAuthsFieldBuilder() { + if (authsBuilder_ == null) { + authsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.authority, org.tron.protos.Protocol.authority.Builder, org.tron.protos.Protocol.authorityOrBuilder>( + auths_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + auths_ = null; + } + return authsBuilder_; + } + + private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+         * data not used
+         * 
+ * + * bytes data = 10; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + /** + *
+         * data not used
+         * 
+ * + * bytes data = 10; + */ + public Builder setData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + data_ = value; + onChanged(); + return this; + } + /** + *
+         * data not used
+         * 
+ * + * bytes data = 10; + */ + public Builder clearData() { + + data_ = getDefaultInstance().getData(); + onChanged(); + return this; + } + + private java.util.List contract_ = + java.util.Collections.emptyList(); + private void ensureContractIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + contract_ = new java.util.ArrayList(contract_); + bitField0_ |= 0x00000040; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction.Contract, org.tron.protos.Protocol.Transaction.Contract.Builder, org.tron.protos.Protocol.Transaction.ContractOrBuilder> contractBuilder_; + + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public java.util.List getContractList() { + if (contractBuilder_ == null) { + return java.util.Collections.unmodifiableList(contract_); + } else { + return contractBuilder_.getMessageList(); + } + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public int getContractCount() { + if (contractBuilder_ == null) { + return contract_.size(); + } else { + return contractBuilder_.getCount(); + } + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public org.tron.protos.Protocol.Transaction.Contract getContract(int index) { + if (contractBuilder_ == null) { + return contract_.get(index); + } else { + return contractBuilder_.getMessage(index); + } + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder setContract( + int index, org.tron.protos.Protocol.Transaction.Contract value) { + if (contractBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureContractIsMutable(); + contract_.set(index, value); + onChanged(); + } else { + contractBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder setContract( + int index, org.tron.protos.Protocol.Transaction.Contract.Builder builderForValue) { + if (contractBuilder_ == null) { + ensureContractIsMutable(); + contract_.set(index, builderForValue.build()); + onChanged(); + } else { + contractBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder addContract(org.tron.protos.Protocol.Transaction.Contract value) { + if (contractBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureContractIsMutable(); + contract_.add(value); + onChanged(); + } else { + contractBuilder_.addMessage(value); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder addContract( + int index, org.tron.protos.Protocol.Transaction.Contract value) { + if (contractBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureContractIsMutable(); + contract_.add(index, value); + onChanged(); + } else { + contractBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder addContract( + org.tron.protos.Protocol.Transaction.Contract.Builder builderForValue) { + if (contractBuilder_ == null) { + ensureContractIsMutable(); + contract_.add(builderForValue.build()); + onChanged(); + } else { + contractBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder addContract( + int index, org.tron.protos.Protocol.Transaction.Contract.Builder builderForValue) { + if (contractBuilder_ == null) { + ensureContractIsMutable(); + contract_.add(index, builderForValue.build()); + onChanged(); + } else { + contractBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder addAllContract( + java.lang.Iterable values) { + if (contractBuilder_ == null) { + ensureContractIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, contract_); + onChanged(); + } else { + contractBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder clearContract() { + if (contractBuilder_ == null) { + contract_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + } else { + contractBuilder_.clear(); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public Builder removeContract(int index) { + if (contractBuilder_ == null) { + ensureContractIsMutable(); + contract_.remove(index); + onChanged(); + } else { + contractBuilder_.remove(index); + } + return this; + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public org.tron.protos.Protocol.Transaction.Contract.Builder getContractBuilder( + int index) { + return getContractFieldBuilder().getBuilder(index); + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public org.tron.protos.Protocol.Transaction.ContractOrBuilder getContractOrBuilder( + int index) { + if (contractBuilder_ == null) { + return contract_.get(index); } else { + return contractBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public java.util.List + getContractOrBuilderList() { + if (contractBuilder_ != null) { + return contractBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(contract_); + } + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public org.tron.protos.Protocol.Transaction.Contract.Builder addContractBuilder() { + return getContractFieldBuilder().addBuilder( + org.tron.protos.Protocol.Transaction.Contract.getDefaultInstance()); + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public org.tron.protos.Protocol.Transaction.Contract.Builder addContractBuilder( + int index) { + return getContractFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Transaction.Contract.getDefaultInstance()); + } + /** + *
+         *only support size = 1,  repeated list here for extension
+         * 
+ * + * repeated .protocol.Transaction.Contract contract = 11; + */ + public java.util.List + getContractBuilderList() { + return getContractFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction.Contract, org.tron.protos.Protocol.Transaction.Contract.Builder, org.tron.protos.Protocol.Transaction.ContractOrBuilder> + getContractFieldBuilder() { + if (contractBuilder_ == null) { + contractBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction.Contract, org.tron.protos.Protocol.Transaction.Contract.Builder, org.tron.protos.Protocol.Transaction.ContractOrBuilder>( + contract_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + contract_ = null; + } + return contractBuilder_; + } + + private com.google.protobuf.ByteString scripts_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+         * scripts not used
+         * 
+ * + * bytes scripts = 12; + */ + public com.google.protobuf.ByteString getScripts() { + return scripts_; + } + /** + *
+         * scripts not used
+         * 
+ * + * bytes scripts = 12; + */ + public Builder setScripts(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + scripts_ = value; + onChanged(); + return this; + } + /** + *
+         * scripts not used
+         * 
+ * + * bytes scripts = 12; + */ + public Builder clearScripts() { + + scripts_ = getDefaultInstance().getScripts(); + onChanged(); + return this; + } + + private long timestamp_ ; + /** + * int64 timestamp = 14; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 14; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 14; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + + private long feeLimit_ ; + /** + * int64 fee_limit = 18; + */ + public long getFeeLimit() { + return feeLimit_; + } + /** + * int64 fee_limit = 18; + */ + public Builder setFeeLimit(long value) { + + feeLimit_ = value; + onChanged(); + return this; + } + /** + * int64 fee_limit = 18; + */ + public Builder clearFeeLimit() { + + feeLimit_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Transaction.raw) + } + + // @@protoc_insertion_point(class_scope:protocol.Transaction.raw) + private static final org.tron.protos.Protocol.Transaction.raw DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Transaction.raw(); + } + + public static org.tron.protos.Protocol.Transaction.raw getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public raw parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new raw(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Transaction.raw getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int RAW_DATA_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.Transaction.raw rawData_; + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public boolean hasRawData() { + return rawData_ != null; + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public org.tron.protos.Protocol.Transaction.raw getRawData() { + return rawData_ == null ? org.tron.protos.Protocol.Transaction.raw.getDefaultInstance() : rawData_; + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public org.tron.protos.Protocol.Transaction.rawOrBuilder getRawDataOrBuilder() { + return getRawData(); + } + + public static final int SIGNATURE_FIELD_NUMBER = 2; + private java.util.List signature_; + /** + *
+     * only support size = 1,  repeated list here for muti-sig extension
+     * 
+ * + * repeated bytes signature = 2; + */ + public java.util.List + getSignatureList() { + return signature_; + } + /** + *
+     * only support size = 1,  repeated list here for muti-sig extension
+     * 
+ * + * repeated bytes signature = 2; + */ + public int getSignatureCount() { + return signature_.size(); + } + /** + *
+     * only support size = 1,  repeated list here for muti-sig extension
+     * 
+ * + * repeated bytes signature = 2; + */ + public com.google.protobuf.ByteString getSignature(int index) { + return signature_.get(index); + } + + public static final int RET_FIELD_NUMBER = 5; + private java.util.List ret_; + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public java.util.List getRetList() { + return ret_; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public java.util.List + getRetOrBuilderList() { + return ret_; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public int getRetCount() { + return ret_.size(); + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public org.tron.protos.Protocol.Transaction.Result getRet(int index) { + return ret_.get(index); + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public org.tron.protos.Protocol.Transaction.ResultOrBuilder getRetOrBuilder( + int index) { + return ret_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (rawData_ != null) { + output.writeMessage(1, getRawData()); + } + for (int i = 0; i < signature_.size(); i++) { + output.writeBytes(2, signature_.get(i)); + } + for (int i = 0; i < ret_.size(); i++) { + output.writeMessage(5, ret_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (rawData_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getRawData()); + } + { + int dataSize = 0; + for (int i = 0; i < signature_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(signature_.get(i)); + } + size += dataSize; + size += 1 * getSignatureList().size(); + } + for (int i = 0; i < ret_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, ret_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Transaction)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Transaction other = (org.tron.protos.Protocol.Transaction) obj; + + boolean result = true; + result = result && (hasRawData() == other.hasRawData()); + if (hasRawData()) { + result = result && getRawData() + .equals(other.getRawData()); + } + result = result && getSignatureList() + .equals(other.getSignatureList()); + result = result && getRetList() + .equals(other.getRetList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasRawData()) { + hash = (37 * hash) + RAW_DATA_FIELD_NUMBER; + hash = (53 * hash) + getRawData().hashCode(); + } + if (getSignatureCount() > 0) { + hash = (37 * hash) + SIGNATURE_FIELD_NUMBER; + hash = (53 * hash) + getSignatureList().hashCode(); + } + if (getRetCount() > 0) { + hash = (37 * hash) + RET_FIELD_NUMBER; + hash = (53 * hash) + getRetList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Transaction parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Transaction prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Transaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Transaction) + org.tron.protos.Protocol.TransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transaction.class, org.tron.protos.Protocol.Transaction.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Transaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getRetFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (rawDataBuilder_ == null) { + rawData_ = null; + } else { + rawData_ = null; + rawDataBuilder_ = null; + } + signature_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + if (retBuilder_ == null) { + ret_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + retBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Transaction_descriptor; + } + + public org.tron.protos.Protocol.Transaction getDefaultInstanceForType() { + return org.tron.protos.Protocol.Transaction.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Transaction build() { + org.tron.protos.Protocol.Transaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Transaction buildPartial() { + org.tron.protos.Protocol.Transaction result = new org.tron.protos.Protocol.Transaction(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (rawDataBuilder_ == null) { + result.rawData_ = rawData_; + } else { + result.rawData_ = rawDataBuilder_.build(); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + signature_ = java.util.Collections.unmodifiableList(signature_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.signature_ = signature_; + if (retBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + ret_ = java.util.Collections.unmodifiableList(ret_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.ret_ = ret_; + } else { + result.ret_ = retBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Transaction) { + return mergeFrom((org.tron.protos.Protocol.Transaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Transaction other) { + if (other == org.tron.protos.Protocol.Transaction.getDefaultInstance()) return this; + if (other.hasRawData()) { + mergeRawData(other.getRawData()); + } + if (!other.signature_.isEmpty()) { + if (signature_.isEmpty()) { + signature_ = other.signature_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureSignatureIsMutable(); + signature_.addAll(other.signature_); + } + onChanged(); + } + if (retBuilder_ == null) { + if (!other.ret_.isEmpty()) { + if (ret_.isEmpty()) { + ret_ = other.ret_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureRetIsMutable(); + ret_.addAll(other.ret_); + } + onChanged(); + } + } else { + if (!other.ret_.isEmpty()) { + if (retBuilder_.isEmpty()) { + retBuilder_.dispose(); + retBuilder_ = null; + ret_ = other.ret_; + bitField0_ = (bitField0_ & ~0x00000004); + retBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getRetFieldBuilder() : null; + } else { + retBuilder_.addAllMessages(other.ret_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Transaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Transaction) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private org.tron.protos.Protocol.Transaction.raw rawData_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction.raw, org.tron.protos.Protocol.Transaction.raw.Builder, org.tron.protos.Protocol.Transaction.rawOrBuilder> rawDataBuilder_; + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public boolean hasRawData() { + return rawDataBuilder_ != null || rawData_ != null; + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public org.tron.protos.Protocol.Transaction.raw getRawData() { + if (rawDataBuilder_ == null) { + return rawData_ == null ? org.tron.protos.Protocol.Transaction.raw.getDefaultInstance() : rawData_; + } else { + return rawDataBuilder_.getMessage(); + } + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public Builder setRawData(org.tron.protos.Protocol.Transaction.raw value) { + if (rawDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + rawData_ = value; + onChanged(); + } else { + rawDataBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public Builder setRawData( + org.tron.protos.Protocol.Transaction.raw.Builder builderForValue) { + if (rawDataBuilder_ == null) { + rawData_ = builderForValue.build(); + onChanged(); + } else { + rawDataBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public Builder mergeRawData(org.tron.protos.Protocol.Transaction.raw value) { + if (rawDataBuilder_ == null) { + if (rawData_ != null) { + rawData_ = + org.tron.protos.Protocol.Transaction.raw.newBuilder(rawData_).mergeFrom(value).buildPartial(); + } else { + rawData_ = value; + } + onChanged(); + } else { + rawDataBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public Builder clearRawData() { + if (rawDataBuilder_ == null) { + rawData_ = null; + onChanged(); + } else { + rawData_ = null; + rawDataBuilder_ = null; + } + + return this; + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public org.tron.protos.Protocol.Transaction.raw.Builder getRawDataBuilder() { + + onChanged(); + return getRawDataFieldBuilder().getBuilder(); + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + public org.tron.protos.Protocol.Transaction.rawOrBuilder getRawDataOrBuilder() { + if (rawDataBuilder_ != null) { + return rawDataBuilder_.getMessageOrBuilder(); + } else { + return rawData_ == null ? + org.tron.protos.Protocol.Transaction.raw.getDefaultInstance() : rawData_; + } + } + /** + * .protocol.Transaction.raw raw_data = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction.raw, org.tron.protos.Protocol.Transaction.raw.Builder, org.tron.protos.Protocol.Transaction.rawOrBuilder> + getRawDataFieldBuilder() { + if (rawDataBuilder_ == null) { + rawDataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction.raw, org.tron.protos.Protocol.Transaction.raw.Builder, org.tron.protos.Protocol.Transaction.rawOrBuilder>( + getRawData(), + getParentForChildren(), + isClean()); + rawData_ = null; + } + return rawDataBuilder_; + } + + private java.util.List signature_ = java.util.Collections.emptyList(); + private void ensureSignatureIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + signature_ = new java.util.ArrayList(signature_); + bitField0_ |= 0x00000002; + } + } + /** + *
+       * only support size = 1,  repeated list here for muti-sig extension
+       * 
+ * + * repeated bytes signature = 2; + */ + public java.util.List + getSignatureList() { + return java.util.Collections.unmodifiableList(signature_); + } + /** + *
+       * only support size = 1,  repeated list here for muti-sig extension
+       * 
+ * + * repeated bytes signature = 2; + */ + public int getSignatureCount() { + return signature_.size(); + } + /** + *
+       * only support size = 1,  repeated list here for muti-sig extension
+       * 
+ * + * repeated bytes signature = 2; + */ + public com.google.protobuf.ByteString getSignature(int index) { + return signature_.get(index); + } + /** + *
+       * only support size = 1,  repeated list here for muti-sig extension
+       * 
+ * + * repeated bytes signature = 2; + */ + public Builder setSignature( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSignatureIsMutable(); + signature_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * only support size = 1,  repeated list here for muti-sig extension
+       * 
+ * + * repeated bytes signature = 2; + */ + public Builder addSignature(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSignatureIsMutable(); + signature_.add(value); + onChanged(); + return this; + } + /** + *
+       * only support size = 1,  repeated list here for muti-sig extension
+       * 
+ * + * repeated bytes signature = 2; + */ + public Builder addAllSignature( + java.lang.Iterable values) { + ensureSignatureIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, signature_); + onChanged(); + return this; + } + /** + *
+       * only support size = 1,  repeated list here for muti-sig extension
+       * 
+ * + * repeated bytes signature = 2; + */ + public Builder clearSignature() { + signature_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private java.util.List ret_ = + java.util.Collections.emptyList(); + private void ensureRetIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + ret_ = new java.util.ArrayList(ret_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction.Result, org.tron.protos.Protocol.Transaction.Result.Builder, org.tron.protos.Protocol.Transaction.ResultOrBuilder> retBuilder_; + + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public java.util.List getRetList() { + if (retBuilder_ == null) { + return java.util.Collections.unmodifiableList(ret_); + } else { + return retBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public int getRetCount() { + if (retBuilder_ == null) { + return ret_.size(); + } else { + return retBuilder_.getCount(); + } + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public org.tron.protos.Protocol.Transaction.Result getRet(int index) { + if (retBuilder_ == null) { + return ret_.get(index); + } else { + return retBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder setRet( + int index, org.tron.protos.Protocol.Transaction.Result value) { + if (retBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRetIsMutable(); + ret_.set(index, value); + onChanged(); + } else { + retBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder setRet( + int index, org.tron.protos.Protocol.Transaction.Result.Builder builderForValue) { + if (retBuilder_ == null) { + ensureRetIsMutable(); + ret_.set(index, builderForValue.build()); + onChanged(); + } else { + retBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder addRet(org.tron.protos.Protocol.Transaction.Result value) { + if (retBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRetIsMutable(); + ret_.add(value); + onChanged(); + } else { + retBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder addRet( + int index, org.tron.protos.Protocol.Transaction.Result value) { + if (retBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRetIsMutable(); + ret_.add(index, value); + onChanged(); + } else { + retBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder addRet( + org.tron.protos.Protocol.Transaction.Result.Builder builderForValue) { + if (retBuilder_ == null) { + ensureRetIsMutable(); + ret_.add(builderForValue.build()); + onChanged(); + } else { + retBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder addRet( + int index, org.tron.protos.Protocol.Transaction.Result.Builder builderForValue) { + if (retBuilder_ == null) { + ensureRetIsMutable(); + ret_.add(index, builderForValue.build()); + onChanged(); + } else { + retBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder addAllRet( + java.lang.Iterable values) { + if (retBuilder_ == null) { + ensureRetIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, ret_); + onChanged(); + } else { + retBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder clearRet() { + if (retBuilder_ == null) { + ret_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + retBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public Builder removeRet(int index) { + if (retBuilder_ == null) { + ensureRetIsMutable(); + ret_.remove(index); + onChanged(); + } else { + retBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public org.tron.protos.Protocol.Transaction.Result.Builder getRetBuilder( + int index) { + return getRetFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public org.tron.protos.Protocol.Transaction.ResultOrBuilder getRetOrBuilder( + int index) { + if (retBuilder_ == null) { + return ret_.get(index); } else { + return retBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public java.util.List + getRetOrBuilderList() { + if (retBuilder_ != null) { + return retBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(ret_); + } + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public org.tron.protos.Protocol.Transaction.Result.Builder addRetBuilder() { + return getRetFieldBuilder().addBuilder( + org.tron.protos.Protocol.Transaction.Result.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public org.tron.protos.Protocol.Transaction.Result.Builder addRetBuilder( + int index) { + return getRetFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Transaction.Result.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction.Result ret = 5; + */ + public java.util.List + getRetBuilderList() { + return getRetFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction.Result, org.tron.protos.Protocol.Transaction.Result.Builder, org.tron.protos.Protocol.Transaction.ResultOrBuilder> + getRetFieldBuilder() { + if (retBuilder_ == null) { + retBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction.Result, org.tron.protos.Protocol.Transaction.Result.Builder, org.tron.protos.Protocol.Transaction.ResultOrBuilder>( + ret_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + ret_ = null; + } + return retBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Transaction) + } + + // @@protoc_insertion_point(class_scope:protocol.Transaction) + private static final org.tron.protos.Protocol.Transaction DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Transaction(); + } + + public static org.tron.protos.Protocol.Transaction getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Transaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Transaction(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Transaction getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes id = 1; + */ + com.google.protobuf.ByteString getId(); + + /** + * int64 fee = 2; + */ + long getFee(); + + /** + * int64 blockNumber = 3; + */ + long getBlockNumber(); + + /** + * int64 blockTimeStamp = 4; + */ + long getBlockTimeStamp(); + + /** + * repeated bytes contractResult = 5; + */ + java.util.List getContractResultList(); + /** + * repeated bytes contractResult = 5; + */ + int getContractResultCount(); + /** + * repeated bytes contractResult = 5; + */ + com.google.protobuf.ByteString getContractResult(int index); + + /** + * bytes contract_address = 6; + */ + com.google.protobuf.ByteString getContractAddress(); + + /** + * .protocol.ResourceReceipt receipt = 7; + */ + boolean hasReceipt(); + /** + * .protocol.ResourceReceipt receipt = 7; + */ + org.tron.protos.Protocol.ResourceReceipt getReceipt(); + /** + * .protocol.ResourceReceipt receipt = 7; + */ + org.tron.protos.Protocol.ResourceReceiptOrBuilder getReceiptOrBuilder(); + + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + java.util.List + getLogList(); + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + org.tron.protos.Protocol.TransactionInfo.Log getLog(int index); + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + int getLogCount(); + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + java.util.List + getLogOrBuilderList(); + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + org.tron.protos.Protocol.TransactionInfo.LogOrBuilder getLogOrBuilder( + int index); + + /** + * .protocol.TransactionInfo.code result = 9; + */ + int getResultValue(); + /** + * .protocol.TransactionInfo.code result = 9; + */ + org.tron.protos.Protocol.TransactionInfo.code getResult(); + + /** + * bytes resMessage = 10; + */ + com.google.protobuf.ByteString getResMessage(); + + /** + * string assetIssueID = 14; + */ + java.lang.String getAssetIssueID(); + /** + * string assetIssueID = 14; + */ + com.google.protobuf.ByteString + getAssetIssueIDBytes(); + + /** + * int64 withdraw_amount = 15; + */ + long getWithdrawAmount(); + + /** + * int64 unfreeze_amount = 16; + */ + long getUnfreezeAmount(); + + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + java.util.List + getInternalTransactionsList(); + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + org.tron.protos.Protocol.InternalTransaction getInternalTransactions(int index); + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + int getInternalTransactionsCount(); + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + java.util.List + getInternalTransactionsOrBuilderList(); + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + org.tron.protos.Protocol.InternalTransactionOrBuilder getInternalTransactionsOrBuilder( + int index); + + /** + * int64 exchange_received_amount = 18; + */ + long getExchangeReceivedAmount(); + + /** + * int64 exchange_inject_another_amount = 19; + */ + long getExchangeInjectAnotherAmount(); + + /** + * int64 exchange_withdraw_another_amount = 20; + */ + long getExchangeWithdrawAnotherAmount(); + + /** + * int64 exchange_id = 21; + */ + long getExchangeId(); + } + /** + * Protobuf type {@code protocol.TransactionInfo} + */ + public static final class TransactionInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionInfo) + TransactionInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionInfo.newBuilder() to construct. + private TransactionInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionInfo() { + id_ = com.google.protobuf.ByteString.EMPTY; + fee_ = 0L; + blockNumber_ = 0L; + blockTimeStamp_ = 0L; + contractResult_ = java.util.Collections.emptyList(); + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + log_ = java.util.Collections.emptyList(); + result_ = 0; + resMessage_ = com.google.protobuf.ByteString.EMPTY; + assetIssueID_ = ""; + withdrawAmount_ = 0L; + unfreezeAmount_ = 0L; + internalTransactions_ = java.util.Collections.emptyList(); + exchangeReceivedAmount_ = 0L; + exchangeInjectAnotherAmount_ = 0L; + exchangeWithdrawAnotherAmount_ = 0L; + exchangeId_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + id_ = input.readBytes(); + break; + } + case 16: { + + fee_ = input.readInt64(); + break; + } + case 24: { + + blockNumber_ = input.readInt64(); + break; + } + case 32: { + + blockTimeStamp_ = input.readInt64(); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + contractResult_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + contractResult_.add(input.readBytes()); + break; + } + case 50: { + + contractAddress_ = input.readBytes(); + break; + } + case 58: { + org.tron.protos.Protocol.ResourceReceipt.Builder subBuilder = null; + if (receipt_ != null) { + subBuilder = receipt_.toBuilder(); + } + receipt_ = input.readMessage(org.tron.protos.Protocol.ResourceReceipt.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(receipt_); + receipt_ = subBuilder.buildPartial(); + } + + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + log_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000080; + } + log_.add( + input.readMessage(org.tron.protos.Protocol.TransactionInfo.Log.parser(), extensionRegistry)); + break; + } + case 72: { + int rawValue = input.readEnum(); + + result_ = rawValue; + break; + } + case 82: { + + resMessage_ = input.readBytes(); + break; + } + case 114: { + java.lang.String s = input.readStringRequireUtf8(); + + assetIssueID_ = s; + break; + } + case 120: { + + withdrawAmount_ = input.readInt64(); + break; + } + case 128: { + + unfreezeAmount_ = input.readInt64(); + break; + } + case 138: { + if (!((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + internalTransactions_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00002000; + } + internalTransactions_.add( + input.readMessage(org.tron.protos.Protocol.InternalTransaction.parser(), extensionRegistry)); + break; + } + case 144: { + + exchangeReceivedAmount_ = input.readInt64(); + break; + } + case 152: { + + exchangeInjectAnotherAmount_ = input.readInt64(); + break; + } + case 160: { + + exchangeWithdrawAnotherAmount_ = input.readInt64(); + break; + } + case 168: { + + exchangeId_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + contractResult_ = java.util.Collections.unmodifiableList(contractResult_); + } + if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + log_ = java.util.Collections.unmodifiableList(log_); + } + if (((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + internalTransactions_ = java.util.Collections.unmodifiableList(internalTransactions_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionInfo.class, org.tron.protos.Protocol.TransactionInfo.Builder.class); + } + + /** + * Protobuf enum {@code protocol.TransactionInfo.code} + */ + public enum code + implements com.google.protobuf.ProtocolMessageEnum { + /** + * SUCESS = 0; + */ + SUCESS(0), + /** + * FAILED = 1; + */ + FAILED(1), + UNRECOGNIZED(-1), + ; + + /** + * SUCESS = 0; + */ + public static final int SUCESS_VALUE = 0; + /** + * FAILED = 1; + */ + public static final int FAILED_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static code valueOf(int value) { + return forNumber(value); + } + + public static code forNumber(int value) { + switch (value) { + case 0: return SUCESS; + case 1: return FAILED; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public code findValueByNumber(int number) { + return code.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.TransactionInfo.getDescriptor().getEnumTypes().get(0); + } + + private static final code[] VALUES = values(); + + public static code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private code(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.TransactionInfo.code) + } + + public interface LogOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionInfo.Log) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes address = 1; + */ + com.google.protobuf.ByteString getAddress(); + + /** + * repeated bytes topics = 2; + */ + java.util.List getTopicsList(); + /** + * repeated bytes topics = 2; + */ + int getTopicsCount(); + /** + * repeated bytes topics = 2; + */ + com.google.protobuf.ByteString getTopics(int index); + + /** + * bytes data = 3; + */ + com.google.protobuf.ByteString getData(); + } + /** + * Protobuf type {@code protocol.TransactionInfo.Log} + */ + public static final class Log extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionInfo.Log) + LogOrBuilder { + private static final long serialVersionUID = 0L; + // Use Log.newBuilder() to construct. + private Log(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Log() { + address_ = com.google.protobuf.ByteString.EMPTY; + topics_ = java.util.Collections.emptyList(); + data_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Log( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + address_ = input.readBytes(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + topics_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + topics_.add(input.readBytes()); + break; + } + case 26: { + + data_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + topics_ = java.util.Collections.unmodifiableList(topics_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_Log_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_Log_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionInfo.Log.class, org.tron.protos.Protocol.TransactionInfo.Log.Builder.class); + } + + private int bitField0_; + public static final int ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString address_; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + + public static final int TOPICS_FIELD_NUMBER = 2; + private java.util.List topics_; + /** + * repeated bytes topics = 2; + */ + public java.util.List + getTopicsList() { + return topics_; + } + /** + * repeated bytes topics = 2; + */ + public int getTopicsCount() { + return topics_.size(); + } + /** + * repeated bytes topics = 2; + */ + public com.google.protobuf.ByteString getTopics(int index) { + return topics_.get(index); + } + + public static final int DATA_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString data_; + /** + * bytes data = 3; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!address_.isEmpty()) { + output.writeBytes(1, address_); + } + for (int i = 0; i < topics_.size(); i++) { + output.writeBytes(2, topics_.get(i)); + } + if (!data_.isEmpty()) { + output.writeBytes(3, data_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!address_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, address_); + } + { + int dataSize = 0; + for (int i = 0; i < topics_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(topics_.get(i)); + } + size += dataSize; + size += 1 * getTopicsList().size(); + } + if (!data_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, data_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TransactionInfo.Log)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TransactionInfo.Log other = (org.tron.protos.Protocol.TransactionInfo.Log) obj; + + boolean result = true; + result = result && getAddress() + .equals(other.getAddress()); + result = result && getTopicsList() + .equals(other.getTopicsList()); + result = result && getData() + .equals(other.getData()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getAddress().hashCode(); + if (getTopicsCount() > 0) { + hash = (37 * hash) + TOPICS_FIELD_NUMBER; + hash = (53 * hash) + getTopicsList().hashCode(); + } + hash = (37 * hash) + DATA_FIELD_NUMBER; + hash = (53 * hash) + getData().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionInfo.Log parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TransactionInfo.Log prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionInfo.Log} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionInfo.Log) + org.tron.protos.Protocol.TransactionInfo.LogOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_Log_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_Log_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionInfo.Log.class, org.tron.protos.Protocol.TransactionInfo.Log.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TransactionInfo.Log.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + address_ = com.google.protobuf.ByteString.EMPTY; + + topics_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + data_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_Log_descriptor; + } + + public org.tron.protos.Protocol.TransactionInfo.Log getDefaultInstanceForType() { + return org.tron.protos.Protocol.TransactionInfo.Log.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TransactionInfo.Log build() { + org.tron.protos.Protocol.TransactionInfo.Log result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TransactionInfo.Log buildPartial() { + org.tron.protos.Protocol.TransactionInfo.Log result = new org.tron.protos.Protocol.TransactionInfo.Log(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.address_ = address_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + topics_ = java.util.Collections.unmodifiableList(topics_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.topics_ = topics_; + result.data_ = data_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TransactionInfo.Log) { + return mergeFrom((org.tron.protos.Protocol.TransactionInfo.Log)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TransactionInfo.Log other) { + if (other == org.tron.protos.Protocol.TransactionInfo.Log.getDefaultInstance()) return this; + if (other.getAddress() != com.google.protobuf.ByteString.EMPTY) { + setAddress(other.getAddress()); + } + if (!other.topics_.isEmpty()) { + if (topics_.isEmpty()) { + topics_ = other.topics_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureTopicsIsMutable(); + topics_.addAll(other.topics_); + } + onChanged(); + } + if (other.getData() != com.google.protobuf.ByteString.EMPTY) { + setData(other.getData()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TransactionInfo.Log parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TransactionInfo.Log) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString address_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes address = 1; + */ + public com.google.protobuf.ByteString getAddress() { + return address_; + } + /** + * bytes address = 1; + */ + public Builder setAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + address_ = value; + onChanged(); + return this; + } + /** + * bytes address = 1; + */ + public Builder clearAddress() { + + address_ = getDefaultInstance().getAddress(); + onChanged(); + return this; + } + + private java.util.List topics_ = java.util.Collections.emptyList(); + private void ensureTopicsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + topics_ = new java.util.ArrayList(topics_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes topics = 2; + */ + public java.util.List + getTopicsList() { + return java.util.Collections.unmodifiableList(topics_); + } + /** + * repeated bytes topics = 2; + */ + public int getTopicsCount() { + return topics_.size(); + } + /** + * repeated bytes topics = 2; + */ + public com.google.protobuf.ByteString getTopics(int index) { + return topics_.get(index); + } + /** + * repeated bytes topics = 2; + */ + public Builder setTopics( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTopicsIsMutable(); + topics_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes topics = 2; + */ + public Builder addTopics(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTopicsIsMutable(); + topics_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes topics = 2; + */ + public Builder addAllTopics( + java.lang.Iterable values) { + ensureTopicsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, topics_); + onChanged(); + return this; + } + /** + * repeated bytes topics = 2; + */ + public Builder clearTopics() { + topics_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes data = 3; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + /** + * bytes data = 3; + */ + public Builder setData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + data_ = value; + onChanged(); + return this; + } + /** + * bytes data = 3; + */ + public Builder clearData() { + + data_ = getDefaultInstance().getData(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionInfo.Log) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionInfo.Log) + private static final org.tron.protos.Protocol.TransactionInfo.Log DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TransactionInfo.Log(); + } + + public static org.tron.protos.Protocol.TransactionInfo.Log getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Log parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Log(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TransactionInfo.Log getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int ID_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString id_; + /** + * bytes id = 1; + */ + public com.google.protobuf.ByteString getId() { + return id_; + } + + public static final int FEE_FIELD_NUMBER = 2; + private long fee_; + /** + * int64 fee = 2; + */ + public long getFee() { + return fee_; + } + + public static final int BLOCKNUMBER_FIELD_NUMBER = 3; + private long blockNumber_; + /** + * int64 blockNumber = 3; + */ + public long getBlockNumber() { + return blockNumber_; + } + + public static final int BLOCKTIMESTAMP_FIELD_NUMBER = 4; + private long blockTimeStamp_; + /** + * int64 blockTimeStamp = 4; + */ + public long getBlockTimeStamp() { + return blockTimeStamp_; + } + + public static final int CONTRACTRESULT_FIELD_NUMBER = 5; + private java.util.List contractResult_; + /** + * repeated bytes contractResult = 5; + */ + public java.util.List + getContractResultList() { + return contractResult_; + } + /** + * repeated bytes contractResult = 5; + */ + public int getContractResultCount() { + return contractResult_.size(); + } + /** + * repeated bytes contractResult = 5; + */ + public com.google.protobuf.ByteString getContractResult(int index) { + return contractResult_.get(index); + } + + public static final int CONTRACT_ADDRESS_FIELD_NUMBER = 6; + private com.google.protobuf.ByteString contractAddress_; + /** + * bytes contract_address = 6; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + + public static final int RECEIPT_FIELD_NUMBER = 7; + private org.tron.protos.Protocol.ResourceReceipt receipt_; + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public boolean hasReceipt() { + return receipt_ != null; + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public org.tron.protos.Protocol.ResourceReceipt getReceipt() { + return receipt_ == null ? org.tron.protos.Protocol.ResourceReceipt.getDefaultInstance() : receipt_; + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public org.tron.protos.Protocol.ResourceReceiptOrBuilder getReceiptOrBuilder() { + return getReceipt(); + } + + public static final int LOG_FIELD_NUMBER = 8; + private java.util.List log_; + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public java.util.List getLogList() { + return log_; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public java.util.List + getLogOrBuilderList() { + return log_; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public int getLogCount() { + return log_.size(); + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public org.tron.protos.Protocol.TransactionInfo.Log getLog(int index) { + return log_.get(index); + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public org.tron.protos.Protocol.TransactionInfo.LogOrBuilder getLogOrBuilder( + int index) { + return log_.get(index); + } + + public static final int RESULT_FIELD_NUMBER = 9; + private int result_; + /** + * .protocol.TransactionInfo.code result = 9; + */ + public int getResultValue() { + return result_; + } + /** + * .protocol.TransactionInfo.code result = 9; + */ + public org.tron.protos.Protocol.TransactionInfo.code getResult() { + org.tron.protos.Protocol.TransactionInfo.code result = org.tron.protos.Protocol.TransactionInfo.code.valueOf(result_); + return result == null ? org.tron.protos.Protocol.TransactionInfo.code.UNRECOGNIZED : result; + } + + public static final int RESMESSAGE_FIELD_NUMBER = 10; + private com.google.protobuf.ByteString resMessage_; + /** + * bytes resMessage = 10; + */ + public com.google.protobuf.ByteString getResMessage() { + return resMessage_; + } + + public static final int ASSETISSUEID_FIELD_NUMBER = 14; + private volatile java.lang.Object assetIssueID_; + /** + * string assetIssueID = 14; + */ + public java.lang.String getAssetIssueID() { + java.lang.Object ref = assetIssueID_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetIssueID_ = s; + return s; + } + } + /** + * string assetIssueID = 14; + */ + public com.google.protobuf.ByteString + getAssetIssueIDBytes() { + java.lang.Object ref = assetIssueID_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetIssueID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int WITHDRAW_AMOUNT_FIELD_NUMBER = 15; + private long withdrawAmount_; + /** + * int64 withdraw_amount = 15; + */ + public long getWithdrawAmount() { + return withdrawAmount_; + } + + public static final int UNFREEZE_AMOUNT_FIELD_NUMBER = 16; + private long unfreezeAmount_; + /** + * int64 unfreeze_amount = 16; + */ + public long getUnfreezeAmount() { + return unfreezeAmount_; + } + + public static final int INTERNAL_TRANSACTIONS_FIELD_NUMBER = 17; + private java.util.List internalTransactions_; + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public java.util.List getInternalTransactionsList() { + return internalTransactions_; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public java.util.List + getInternalTransactionsOrBuilderList() { + return internalTransactions_; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public int getInternalTransactionsCount() { + return internalTransactions_.size(); + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public org.tron.protos.Protocol.InternalTransaction getInternalTransactions(int index) { + return internalTransactions_.get(index); + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public org.tron.protos.Protocol.InternalTransactionOrBuilder getInternalTransactionsOrBuilder( + int index) { + return internalTransactions_.get(index); + } + + public static final int EXCHANGE_RECEIVED_AMOUNT_FIELD_NUMBER = 18; + private long exchangeReceivedAmount_; + /** + * int64 exchange_received_amount = 18; + */ + public long getExchangeReceivedAmount() { + return exchangeReceivedAmount_; + } + + public static final int EXCHANGE_INJECT_ANOTHER_AMOUNT_FIELD_NUMBER = 19; + private long exchangeInjectAnotherAmount_; + /** + * int64 exchange_inject_another_amount = 19; + */ + public long getExchangeInjectAnotherAmount() { + return exchangeInjectAnotherAmount_; + } + + public static final int EXCHANGE_WITHDRAW_ANOTHER_AMOUNT_FIELD_NUMBER = 20; + private long exchangeWithdrawAnotherAmount_; + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public long getExchangeWithdrawAnotherAmount() { + return exchangeWithdrawAnotherAmount_; + } + + public static final int EXCHANGE_ID_FIELD_NUMBER = 21; + private long exchangeId_; + /** + * int64 exchange_id = 21; + */ + public long getExchangeId() { + return exchangeId_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!id_.isEmpty()) { + output.writeBytes(1, id_); + } + if (fee_ != 0L) { + output.writeInt64(2, fee_); + } + if (blockNumber_ != 0L) { + output.writeInt64(3, blockNumber_); + } + if (blockTimeStamp_ != 0L) { + output.writeInt64(4, blockTimeStamp_); + } + for (int i = 0; i < contractResult_.size(); i++) { + output.writeBytes(5, contractResult_.get(i)); + } + if (!contractAddress_.isEmpty()) { + output.writeBytes(6, contractAddress_); + } + if (receipt_ != null) { + output.writeMessage(7, getReceipt()); + } + for (int i = 0; i < log_.size(); i++) { + output.writeMessage(8, log_.get(i)); + } + if (result_ != org.tron.protos.Protocol.TransactionInfo.code.SUCESS.getNumber()) { + output.writeEnum(9, result_); + } + if (!resMessage_.isEmpty()) { + output.writeBytes(10, resMessage_); + } + if (!getAssetIssueIDBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 14, assetIssueID_); + } + if (withdrawAmount_ != 0L) { + output.writeInt64(15, withdrawAmount_); + } + if (unfreezeAmount_ != 0L) { + output.writeInt64(16, unfreezeAmount_); + } + for (int i = 0; i < internalTransactions_.size(); i++) { + output.writeMessage(17, internalTransactions_.get(i)); + } + if (exchangeReceivedAmount_ != 0L) { + output.writeInt64(18, exchangeReceivedAmount_); + } + if (exchangeInjectAnotherAmount_ != 0L) { + output.writeInt64(19, exchangeInjectAnotherAmount_); + } + if (exchangeWithdrawAnotherAmount_ != 0L) { + output.writeInt64(20, exchangeWithdrawAnotherAmount_); + } + if (exchangeId_ != 0L) { + output.writeInt64(21, exchangeId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!id_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, id_); + } + if (fee_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, fee_); + } + if (blockNumber_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, blockNumber_); + } + if (blockTimeStamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, blockTimeStamp_); + } + { + int dataSize = 0; + for (int i = 0; i < contractResult_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(contractResult_.get(i)); + } + size += dataSize; + size += 1 * getContractResultList().size(); + } + if (!contractAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(6, contractAddress_); + } + if (receipt_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, getReceipt()); + } + for (int i = 0; i < log_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, log_.get(i)); + } + if (result_ != org.tron.protos.Protocol.TransactionInfo.code.SUCESS.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(9, result_); + } + if (!resMessage_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(10, resMessage_); + } + if (!getAssetIssueIDBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(14, assetIssueID_); + } + if (withdrawAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(15, withdrawAmount_); + } + if (unfreezeAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(16, unfreezeAmount_); + } + for (int i = 0; i < internalTransactions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(17, internalTransactions_.get(i)); + } + if (exchangeReceivedAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(18, exchangeReceivedAmount_); + } + if (exchangeInjectAnotherAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(19, exchangeInjectAnotherAmount_); + } + if (exchangeWithdrawAnotherAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(20, exchangeWithdrawAnotherAmount_); + } + if (exchangeId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(21, exchangeId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TransactionInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TransactionInfo other = (org.tron.protos.Protocol.TransactionInfo) obj; + + boolean result = true; + result = result && getId() + .equals(other.getId()); + result = result && (getFee() + == other.getFee()); + result = result && (getBlockNumber() + == other.getBlockNumber()); + result = result && (getBlockTimeStamp() + == other.getBlockTimeStamp()); + result = result && getContractResultList() + .equals(other.getContractResultList()); + result = result && getContractAddress() + .equals(other.getContractAddress()); + result = result && (hasReceipt() == other.hasReceipt()); + if (hasReceipt()) { + result = result && getReceipt() + .equals(other.getReceipt()); + } + result = result && getLogList() + .equals(other.getLogList()); + result = result && result_ == other.result_; + result = result && getResMessage() + .equals(other.getResMessage()); + result = result && getAssetIssueID() + .equals(other.getAssetIssueID()); + result = result && (getWithdrawAmount() + == other.getWithdrawAmount()); + result = result && (getUnfreezeAmount() + == other.getUnfreezeAmount()); + result = result && getInternalTransactionsList() + .equals(other.getInternalTransactionsList()); + result = result && (getExchangeReceivedAmount() + == other.getExchangeReceivedAmount()); + result = result && (getExchangeInjectAnotherAmount() + == other.getExchangeInjectAnotherAmount()); + result = result && (getExchangeWithdrawAnotherAmount() + == other.getExchangeWithdrawAnotherAmount()); + result = result && (getExchangeId() + == other.getExchangeId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + hash = (37 * hash) + FEE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFee()); + hash = (37 * hash) + BLOCKNUMBER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBlockNumber()); + hash = (37 * hash) + BLOCKTIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBlockTimeStamp()); + if (getContractResultCount() > 0) { + hash = (37 * hash) + CONTRACTRESULT_FIELD_NUMBER; + hash = (53 * hash) + getContractResultList().hashCode(); + } + hash = (37 * hash) + CONTRACT_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getContractAddress().hashCode(); + if (hasReceipt()) { + hash = (37 * hash) + RECEIPT_FIELD_NUMBER; + hash = (53 * hash) + getReceipt().hashCode(); + } + if (getLogCount() > 0) { + hash = (37 * hash) + LOG_FIELD_NUMBER; + hash = (53 * hash) + getLogList().hashCode(); + } + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + result_; + hash = (37 * hash) + RESMESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getResMessage().hashCode(); + hash = (37 * hash) + ASSETISSUEID_FIELD_NUMBER; + hash = (53 * hash) + getAssetIssueID().hashCode(); + hash = (37 * hash) + WITHDRAW_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getWithdrawAmount()); + hash = (37 * hash) + UNFREEZE_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getUnfreezeAmount()); + if (getInternalTransactionsCount() > 0) { + hash = (37 * hash) + INTERNAL_TRANSACTIONS_FIELD_NUMBER; + hash = (53 * hash) + getInternalTransactionsList().hashCode(); + } + hash = (37 * hash) + EXCHANGE_RECEIVED_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeReceivedAmount()); + hash = (37 * hash) + EXCHANGE_INJECT_ANOTHER_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeInjectAnotherAmount()); + hash = (37 * hash) + EXCHANGE_WITHDRAW_ANOTHER_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeWithdrawAnotherAmount()); + hash = (37 * hash) + EXCHANGE_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getExchangeId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TransactionInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionInfo) + org.tron.protos.Protocol.TransactionInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionInfo.class, org.tron.protos.Protocol.TransactionInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TransactionInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getLogFieldBuilder(); + getInternalTransactionsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + id_ = com.google.protobuf.ByteString.EMPTY; + + fee_ = 0L; + + blockNumber_ = 0L; + + blockTimeStamp_ = 0L; + + contractResult_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + + if (receiptBuilder_ == null) { + receipt_ = null; + } else { + receipt_ = null; + receiptBuilder_ = null; + } + if (logBuilder_ == null) { + log_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + } else { + logBuilder_.clear(); + } + result_ = 0; + + resMessage_ = com.google.protobuf.ByteString.EMPTY; + + assetIssueID_ = ""; + + withdrawAmount_ = 0L; + + unfreezeAmount_ = 0L; + + if (internalTransactionsBuilder_ == null) { + internalTransactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + } else { + internalTransactionsBuilder_.clear(); + } + exchangeReceivedAmount_ = 0L; + + exchangeInjectAnotherAmount_ = 0L; + + exchangeWithdrawAnotherAmount_ = 0L; + + exchangeId_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionInfo_descriptor; + } + + public org.tron.protos.Protocol.TransactionInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.TransactionInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TransactionInfo build() { + org.tron.protos.Protocol.TransactionInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TransactionInfo buildPartial() { + org.tron.protos.Protocol.TransactionInfo result = new org.tron.protos.Protocol.TransactionInfo(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.id_ = id_; + result.fee_ = fee_; + result.blockNumber_ = blockNumber_; + result.blockTimeStamp_ = blockTimeStamp_; + if (((bitField0_ & 0x00000010) == 0x00000010)) { + contractResult_ = java.util.Collections.unmodifiableList(contractResult_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.contractResult_ = contractResult_; + result.contractAddress_ = contractAddress_; + if (receiptBuilder_ == null) { + result.receipt_ = receipt_; + } else { + result.receipt_ = receiptBuilder_.build(); + } + if (logBuilder_ == null) { + if (((bitField0_ & 0x00000080) == 0x00000080)) { + log_ = java.util.Collections.unmodifiableList(log_); + bitField0_ = (bitField0_ & ~0x00000080); + } + result.log_ = log_; + } else { + result.log_ = logBuilder_.build(); + } + result.result_ = result_; + result.resMessage_ = resMessage_; + result.assetIssueID_ = assetIssueID_; + result.withdrawAmount_ = withdrawAmount_; + result.unfreezeAmount_ = unfreezeAmount_; + if (internalTransactionsBuilder_ == null) { + if (((bitField0_ & 0x00002000) == 0x00002000)) { + internalTransactions_ = java.util.Collections.unmodifiableList(internalTransactions_); + bitField0_ = (bitField0_ & ~0x00002000); + } + result.internalTransactions_ = internalTransactions_; + } else { + result.internalTransactions_ = internalTransactionsBuilder_.build(); + } + result.exchangeReceivedAmount_ = exchangeReceivedAmount_; + result.exchangeInjectAnotherAmount_ = exchangeInjectAnotherAmount_; + result.exchangeWithdrawAnotherAmount_ = exchangeWithdrawAnotherAmount_; + result.exchangeId_ = exchangeId_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TransactionInfo) { + return mergeFrom((org.tron.protos.Protocol.TransactionInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TransactionInfo other) { + if (other == org.tron.protos.Protocol.TransactionInfo.getDefaultInstance()) return this; + if (other.getId() != com.google.protobuf.ByteString.EMPTY) { + setId(other.getId()); + } + if (other.getFee() != 0L) { + setFee(other.getFee()); + } + if (other.getBlockNumber() != 0L) { + setBlockNumber(other.getBlockNumber()); + } + if (other.getBlockTimeStamp() != 0L) { + setBlockTimeStamp(other.getBlockTimeStamp()); + } + if (!other.contractResult_.isEmpty()) { + if (contractResult_.isEmpty()) { + contractResult_ = other.contractResult_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureContractResultIsMutable(); + contractResult_.addAll(other.contractResult_); + } + onChanged(); + } + if (other.getContractAddress() != com.google.protobuf.ByteString.EMPTY) { + setContractAddress(other.getContractAddress()); + } + if (other.hasReceipt()) { + mergeReceipt(other.getReceipt()); + } + if (logBuilder_ == null) { + if (!other.log_.isEmpty()) { + if (log_.isEmpty()) { + log_ = other.log_; + bitField0_ = (bitField0_ & ~0x00000080); + } else { + ensureLogIsMutable(); + log_.addAll(other.log_); + } + onChanged(); + } + } else { + if (!other.log_.isEmpty()) { + if (logBuilder_.isEmpty()) { + logBuilder_.dispose(); + logBuilder_ = null; + log_ = other.log_; + bitField0_ = (bitField0_ & ~0x00000080); + logBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getLogFieldBuilder() : null; + } else { + logBuilder_.addAllMessages(other.log_); + } + } + } + if (other.result_ != 0) { + setResultValue(other.getResultValue()); + } + if (other.getResMessage() != com.google.protobuf.ByteString.EMPTY) { + setResMessage(other.getResMessage()); + } + if (!other.getAssetIssueID().isEmpty()) { + assetIssueID_ = other.assetIssueID_; + onChanged(); + } + if (other.getWithdrawAmount() != 0L) { + setWithdrawAmount(other.getWithdrawAmount()); + } + if (other.getUnfreezeAmount() != 0L) { + setUnfreezeAmount(other.getUnfreezeAmount()); + } + if (internalTransactionsBuilder_ == null) { + if (!other.internalTransactions_.isEmpty()) { + if (internalTransactions_.isEmpty()) { + internalTransactions_ = other.internalTransactions_; + bitField0_ = (bitField0_ & ~0x00002000); + } else { + ensureInternalTransactionsIsMutable(); + internalTransactions_.addAll(other.internalTransactions_); + } + onChanged(); + } + } else { + if (!other.internalTransactions_.isEmpty()) { + if (internalTransactionsBuilder_.isEmpty()) { + internalTransactionsBuilder_.dispose(); + internalTransactionsBuilder_ = null; + internalTransactions_ = other.internalTransactions_; + bitField0_ = (bitField0_ & ~0x00002000); + internalTransactionsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getInternalTransactionsFieldBuilder() : null; + } else { + internalTransactionsBuilder_.addAllMessages(other.internalTransactions_); + } + } + } + if (other.getExchangeReceivedAmount() != 0L) { + setExchangeReceivedAmount(other.getExchangeReceivedAmount()); + } + if (other.getExchangeInjectAnotherAmount() != 0L) { + setExchangeInjectAnotherAmount(other.getExchangeInjectAnotherAmount()); + } + if (other.getExchangeWithdrawAnotherAmount() != 0L) { + setExchangeWithdrawAnotherAmount(other.getExchangeWithdrawAnotherAmount()); + } + if (other.getExchangeId() != 0L) { + setExchangeId(other.getExchangeId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TransactionInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TransactionInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString id_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes id = 1; + */ + public com.google.protobuf.ByteString getId() { + return id_; + } + /** + * bytes id = 1; + */ + public Builder setId(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + id_ = value; + onChanged(); + return this; + } + /** + * bytes id = 1; + */ + public Builder clearId() { + + id_ = getDefaultInstance().getId(); + onChanged(); + return this; + } + + private long fee_ ; + /** + * int64 fee = 2; + */ + public long getFee() { + return fee_; + } + /** + * int64 fee = 2; + */ + public Builder setFee(long value) { + + fee_ = value; + onChanged(); + return this; + } + /** + * int64 fee = 2; + */ + public Builder clearFee() { + + fee_ = 0L; + onChanged(); + return this; + } + + private long blockNumber_ ; + /** + * int64 blockNumber = 3; + */ + public long getBlockNumber() { + return blockNumber_; + } + /** + * int64 blockNumber = 3; + */ + public Builder setBlockNumber(long value) { + + blockNumber_ = value; + onChanged(); + return this; + } + /** + * int64 blockNumber = 3; + */ + public Builder clearBlockNumber() { + + blockNumber_ = 0L; + onChanged(); + return this; + } + + private long blockTimeStamp_ ; + /** + * int64 blockTimeStamp = 4; + */ + public long getBlockTimeStamp() { + return blockTimeStamp_; + } + /** + * int64 blockTimeStamp = 4; + */ + public Builder setBlockTimeStamp(long value) { + + blockTimeStamp_ = value; + onChanged(); + return this; + } + /** + * int64 blockTimeStamp = 4; + */ + public Builder clearBlockTimeStamp() { + + blockTimeStamp_ = 0L; + onChanged(); + return this; + } + + private java.util.List contractResult_ = java.util.Collections.emptyList(); + private void ensureContractResultIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + contractResult_ = new java.util.ArrayList(contractResult_); + bitField0_ |= 0x00000010; + } + } + /** + * repeated bytes contractResult = 5; + */ + public java.util.List + getContractResultList() { + return java.util.Collections.unmodifiableList(contractResult_); + } + /** + * repeated bytes contractResult = 5; + */ + public int getContractResultCount() { + return contractResult_.size(); + } + /** + * repeated bytes contractResult = 5; + */ + public com.google.protobuf.ByteString getContractResult(int index) { + return contractResult_.get(index); + } + /** + * repeated bytes contractResult = 5; + */ + public Builder setContractResult( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureContractResultIsMutable(); + contractResult_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes contractResult = 5; + */ + public Builder addContractResult(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureContractResultIsMutable(); + contractResult_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes contractResult = 5; + */ + public Builder addAllContractResult( + java.lang.Iterable values) { + ensureContractResultIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, contractResult_); + onChanged(); + return this; + } + /** + * repeated bytes contractResult = 5; + */ + public Builder clearContractResult() { + contractResult_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString contractAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes contract_address = 6; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + /** + * bytes contract_address = 6; + */ + public Builder setContractAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + contractAddress_ = value; + onChanged(); + return this; + } + /** + * bytes contract_address = 6; + */ + public Builder clearContractAddress() { + + contractAddress_ = getDefaultInstance().getContractAddress(); + onChanged(); + return this; + } + + private org.tron.protos.Protocol.ResourceReceipt receipt_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.ResourceReceipt, org.tron.protos.Protocol.ResourceReceipt.Builder, org.tron.protos.Protocol.ResourceReceiptOrBuilder> receiptBuilder_; + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public boolean hasReceipt() { + return receiptBuilder_ != null || receipt_ != null; + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public org.tron.protos.Protocol.ResourceReceipt getReceipt() { + if (receiptBuilder_ == null) { + return receipt_ == null ? org.tron.protos.Protocol.ResourceReceipt.getDefaultInstance() : receipt_; + } else { + return receiptBuilder_.getMessage(); + } + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public Builder setReceipt(org.tron.protos.Protocol.ResourceReceipt value) { + if (receiptBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + receipt_ = value; + onChanged(); + } else { + receiptBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public Builder setReceipt( + org.tron.protos.Protocol.ResourceReceipt.Builder builderForValue) { + if (receiptBuilder_ == null) { + receipt_ = builderForValue.build(); + onChanged(); + } else { + receiptBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public Builder mergeReceipt(org.tron.protos.Protocol.ResourceReceipt value) { + if (receiptBuilder_ == null) { + if (receipt_ != null) { + receipt_ = + org.tron.protos.Protocol.ResourceReceipt.newBuilder(receipt_).mergeFrom(value).buildPartial(); + } else { + receipt_ = value; + } + onChanged(); + } else { + receiptBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public Builder clearReceipt() { + if (receiptBuilder_ == null) { + receipt_ = null; + onChanged(); + } else { + receipt_ = null; + receiptBuilder_ = null; + } + + return this; + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public org.tron.protos.Protocol.ResourceReceipt.Builder getReceiptBuilder() { + + onChanged(); + return getReceiptFieldBuilder().getBuilder(); + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + public org.tron.protos.Protocol.ResourceReceiptOrBuilder getReceiptOrBuilder() { + if (receiptBuilder_ != null) { + return receiptBuilder_.getMessageOrBuilder(); + } else { + return receipt_ == null ? + org.tron.protos.Protocol.ResourceReceipt.getDefaultInstance() : receipt_; + } + } + /** + * .protocol.ResourceReceipt receipt = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.ResourceReceipt, org.tron.protos.Protocol.ResourceReceipt.Builder, org.tron.protos.Protocol.ResourceReceiptOrBuilder> + getReceiptFieldBuilder() { + if (receiptBuilder_ == null) { + receiptBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.ResourceReceipt, org.tron.protos.Protocol.ResourceReceipt.Builder, org.tron.protos.Protocol.ResourceReceiptOrBuilder>( + getReceipt(), + getParentForChildren(), + isClean()); + receipt_ = null; + } + return receiptBuilder_; + } + + private java.util.List log_ = + java.util.Collections.emptyList(); + private void ensureLogIsMutable() { + if (!((bitField0_ & 0x00000080) == 0x00000080)) { + log_ = new java.util.ArrayList(log_); + bitField0_ |= 0x00000080; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TransactionInfo.Log, org.tron.protos.Protocol.TransactionInfo.Log.Builder, org.tron.protos.Protocol.TransactionInfo.LogOrBuilder> logBuilder_; + + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public java.util.List getLogList() { + if (logBuilder_ == null) { + return java.util.Collections.unmodifiableList(log_); + } else { + return logBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public int getLogCount() { + if (logBuilder_ == null) { + return log_.size(); + } else { + return logBuilder_.getCount(); + } + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public org.tron.protos.Protocol.TransactionInfo.Log getLog(int index) { + if (logBuilder_ == null) { + return log_.get(index); + } else { + return logBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder setLog( + int index, org.tron.protos.Protocol.TransactionInfo.Log value) { + if (logBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogIsMutable(); + log_.set(index, value); + onChanged(); + } else { + logBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder setLog( + int index, org.tron.protos.Protocol.TransactionInfo.Log.Builder builderForValue) { + if (logBuilder_ == null) { + ensureLogIsMutable(); + log_.set(index, builderForValue.build()); + onChanged(); + } else { + logBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder addLog(org.tron.protos.Protocol.TransactionInfo.Log value) { + if (logBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogIsMutable(); + log_.add(value); + onChanged(); + } else { + logBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder addLog( + int index, org.tron.protos.Protocol.TransactionInfo.Log value) { + if (logBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogIsMutable(); + log_.add(index, value); + onChanged(); + } else { + logBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder addLog( + org.tron.protos.Protocol.TransactionInfo.Log.Builder builderForValue) { + if (logBuilder_ == null) { + ensureLogIsMutable(); + log_.add(builderForValue.build()); + onChanged(); + } else { + logBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder addLog( + int index, org.tron.protos.Protocol.TransactionInfo.Log.Builder builderForValue) { + if (logBuilder_ == null) { + ensureLogIsMutable(); + log_.add(index, builderForValue.build()); + onChanged(); + } else { + logBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder addAllLog( + java.lang.Iterable values) { + if (logBuilder_ == null) { + ensureLogIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, log_); + onChanged(); + } else { + logBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder clearLog() { + if (logBuilder_ == null) { + log_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + onChanged(); + } else { + logBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public Builder removeLog(int index) { + if (logBuilder_ == null) { + ensureLogIsMutable(); + log_.remove(index); + onChanged(); + } else { + logBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public org.tron.protos.Protocol.TransactionInfo.Log.Builder getLogBuilder( + int index) { + return getLogFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public org.tron.protos.Protocol.TransactionInfo.LogOrBuilder getLogOrBuilder( + int index) { + if (logBuilder_ == null) { + return log_.get(index); } else { + return logBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public java.util.List + getLogOrBuilderList() { + if (logBuilder_ != null) { + return logBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(log_); + } + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public org.tron.protos.Protocol.TransactionInfo.Log.Builder addLogBuilder() { + return getLogFieldBuilder().addBuilder( + org.tron.protos.Protocol.TransactionInfo.Log.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public org.tron.protos.Protocol.TransactionInfo.Log.Builder addLogBuilder( + int index) { + return getLogFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.TransactionInfo.Log.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionInfo.Log log = 8; + */ + public java.util.List + getLogBuilderList() { + return getLogFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TransactionInfo.Log, org.tron.protos.Protocol.TransactionInfo.Log.Builder, org.tron.protos.Protocol.TransactionInfo.LogOrBuilder> + getLogFieldBuilder() { + if (logBuilder_ == null) { + logBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TransactionInfo.Log, org.tron.protos.Protocol.TransactionInfo.Log.Builder, org.tron.protos.Protocol.TransactionInfo.LogOrBuilder>( + log_, + ((bitField0_ & 0x00000080) == 0x00000080), + getParentForChildren(), + isClean()); + log_ = null; + } + return logBuilder_; + } + + private int result_ = 0; + /** + * .protocol.TransactionInfo.code result = 9; + */ + public int getResultValue() { + return result_; + } + /** + * .protocol.TransactionInfo.code result = 9; + */ + public Builder setResultValue(int value) { + result_ = value; + onChanged(); + return this; + } + /** + * .protocol.TransactionInfo.code result = 9; + */ + public org.tron.protos.Protocol.TransactionInfo.code getResult() { + org.tron.protos.Protocol.TransactionInfo.code result = org.tron.protos.Protocol.TransactionInfo.code.valueOf(result_); + return result == null ? org.tron.protos.Protocol.TransactionInfo.code.UNRECOGNIZED : result; + } + /** + * .protocol.TransactionInfo.code result = 9; + */ + public Builder setResult(org.tron.protos.Protocol.TransactionInfo.code value) { + if (value == null) { + throw new NullPointerException(); + } + + result_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.TransactionInfo.code result = 9; + */ + public Builder clearResult() { + + result_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString resMessage_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes resMessage = 10; + */ + public com.google.protobuf.ByteString getResMessage() { + return resMessage_; + } + /** + * bytes resMessage = 10; + */ + public Builder setResMessage(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + resMessage_ = value; + onChanged(); + return this; + } + /** + * bytes resMessage = 10; + */ + public Builder clearResMessage() { + + resMessage_ = getDefaultInstance().getResMessage(); + onChanged(); + return this; + } + + private java.lang.Object assetIssueID_ = ""; + /** + * string assetIssueID = 14; + */ + public java.lang.String getAssetIssueID() { + java.lang.Object ref = assetIssueID_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + assetIssueID_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string assetIssueID = 14; + */ + public com.google.protobuf.ByteString + getAssetIssueIDBytes() { + java.lang.Object ref = assetIssueID_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + assetIssueID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string assetIssueID = 14; + */ + public Builder setAssetIssueID( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + assetIssueID_ = value; + onChanged(); + return this; + } + /** + * string assetIssueID = 14; + */ + public Builder clearAssetIssueID() { + + assetIssueID_ = getDefaultInstance().getAssetIssueID(); + onChanged(); + return this; + } + /** + * string assetIssueID = 14; + */ + public Builder setAssetIssueIDBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + assetIssueID_ = value; + onChanged(); + return this; + } + + private long withdrawAmount_ ; + /** + * int64 withdraw_amount = 15; + */ + public long getWithdrawAmount() { + return withdrawAmount_; + } + /** + * int64 withdraw_amount = 15; + */ + public Builder setWithdrawAmount(long value) { + + withdrawAmount_ = value; + onChanged(); + return this; + } + /** + * int64 withdraw_amount = 15; + */ + public Builder clearWithdrawAmount() { + + withdrawAmount_ = 0L; + onChanged(); + return this; + } + + private long unfreezeAmount_ ; + /** + * int64 unfreeze_amount = 16; + */ + public long getUnfreezeAmount() { + return unfreezeAmount_; + } + /** + * int64 unfreeze_amount = 16; + */ + public Builder setUnfreezeAmount(long value) { + + unfreezeAmount_ = value; + onChanged(); + return this; + } + /** + * int64 unfreeze_amount = 16; + */ + public Builder clearUnfreezeAmount() { + + unfreezeAmount_ = 0L; + onChanged(); + return this; + } + + private java.util.List internalTransactions_ = + java.util.Collections.emptyList(); + private void ensureInternalTransactionsIsMutable() { + if (!((bitField0_ & 0x00002000) == 0x00002000)) { + internalTransactions_ = new java.util.ArrayList(internalTransactions_); + bitField0_ |= 0x00002000; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.InternalTransaction, org.tron.protos.Protocol.InternalTransaction.Builder, org.tron.protos.Protocol.InternalTransactionOrBuilder> internalTransactionsBuilder_; + + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public java.util.List getInternalTransactionsList() { + if (internalTransactionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(internalTransactions_); + } else { + return internalTransactionsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public int getInternalTransactionsCount() { + if (internalTransactionsBuilder_ == null) { + return internalTransactions_.size(); + } else { + return internalTransactionsBuilder_.getCount(); + } + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public org.tron.protos.Protocol.InternalTransaction getInternalTransactions(int index) { + if (internalTransactionsBuilder_ == null) { + return internalTransactions_.get(index); + } else { + return internalTransactionsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder setInternalTransactions( + int index, org.tron.protos.Protocol.InternalTransaction value) { + if (internalTransactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInternalTransactionsIsMutable(); + internalTransactions_.set(index, value); + onChanged(); + } else { + internalTransactionsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder setInternalTransactions( + int index, org.tron.protos.Protocol.InternalTransaction.Builder builderForValue) { + if (internalTransactionsBuilder_ == null) { + ensureInternalTransactionsIsMutable(); + internalTransactions_.set(index, builderForValue.build()); + onChanged(); + } else { + internalTransactionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder addInternalTransactions(org.tron.protos.Protocol.InternalTransaction value) { + if (internalTransactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInternalTransactionsIsMutable(); + internalTransactions_.add(value); + onChanged(); + } else { + internalTransactionsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder addInternalTransactions( + int index, org.tron.protos.Protocol.InternalTransaction value) { + if (internalTransactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInternalTransactionsIsMutable(); + internalTransactions_.add(index, value); + onChanged(); + } else { + internalTransactionsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder addInternalTransactions( + org.tron.protos.Protocol.InternalTransaction.Builder builderForValue) { + if (internalTransactionsBuilder_ == null) { + ensureInternalTransactionsIsMutable(); + internalTransactions_.add(builderForValue.build()); + onChanged(); + } else { + internalTransactionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder addInternalTransactions( + int index, org.tron.protos.Protocol.InternalTransaction.Builder builderForValue) { + if (internalTransactionsBuilder_ == null) { + ensureInternalTransactionsIsMutable(); + internalTransactions_.add(index, builderForValue.build()); + onChanged(); + } else { + internalTransactionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder addAllInternalTransactions( + java.lang.Iterable values) { + if (internalTransactionsBuilder_ == null) { + ensureInternalTransactionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, internalTransactions_); + onChanged(); + } else { + internalTransactionsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder clearInternalTransactions() { + if (internalTransactionsBuilder_ == null) { + internalTransactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + onChanged(); + } else { + internalTransactionsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public Builder removeInternalTransactions(int index) { + if (internalTransactionsBuilder_ == null) { + ensureInternalTransactionsIsMutable(); + internalTransactions_.remove(index); + onChanged(); + } else { + internalTransactionsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public org.tron.protos.Protocol.InternalTransaction.Builder getInternalTransactionsBuilder( + int index) { + return getInternalTransactionsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public org.tron.protos.Protocol.InternalTransactionOrBuilder getInternalTransactionsOrBuilder( + int index) { + if (internalTransactionsBuilder_ == null) { + return internalTransactions_.get(index); } else { + return internalTransactionsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public java.util.List + getInternalTransactionsOrBuilderList() { + if (internalTransactionsBuilder_ != null) { + return internalTransactionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(internalTransactions_); + } + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public org.tron.protos.Protocol.InternalTransaction.Builder addInternalTransactionsBuilder() { + return getInternalTransactionsFieldBuilder().addBuilder( + org.tron.protos.Protocol.InternalTransaction.getDefaultInstance()); + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public org.tron.protos.Protocol.InternalTransaction.Builder addInternalTransactionsBuilder( + int index) { + return getInternalTransactionsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.InternalTransaction.getDefaultInstance()); + } + /** + * repeated .protocol.InternalTransaction internal_transactions = 17; + */ + public java.util.List + getInternalTransactionsBuilderList() { + return getInternalTransactionsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.InternalTransaction, org.tron.protos.Protocol.InternalTransaction.Builder, org.tron.protos.Protocol.InternalTransactionOrBuilder> + getInternalTransactionsFieldBuilder() { + if (internalTransactionsBuilder_ == null) { + internalTransactionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.InternalTransaction, org.tron.protos.Protocol.InternalTransaction.Builder, org.tron.protos.Protocol.InternalTransactionOrBuilder>( + internalTransactions_, + ((bitField0_ & 0x00002000) == 0x00002000), + getParentForChildren(), + isClean()); + internalTransactions_ = null; + } + return internalTransactionsBuilder_; + } + + private long exchangeReceivedAmount_ ; + /** + * int64 exchange_received_amount = 18; + */ + public long getExchangeReceivedAmount() { + return exchangeReceivedAmount_; + } + /** + * int64 exchange_received_amount = 18; + */ + public Builder setExchangeReceivedAmount(long value) { + + exchangeReceivedAmount_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_received_amount = 18; + */ + public Builder clearExchangeReceivedAmount() { + + exchangeReceivedAmount_ = 0L; + onChanged(); + return this; + } + + private long exchangeInjectAnotherAmount_ ; + /** + * int64 exchange_inject_another_amount = 19; + */ + public long getExchangeInjectAnotherAmount() { + return exchangeInjectAnotherAmount_; + } + /** + * int64 exchange_inject_another_amount = 19; + */ + public Builder setExchangeInjectAnotherAmount(long value) { + + exchangeInjectAnotherAmount_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_inject_another_amount = 19; + */ + public Builder clearExchangeInjectAnotherAmount() { + + exchangeInjectAnotherAmount_ = 0L; + onChanged(); + return this; + } + + private long exchangeWithdrawAnotherAmount_ ; + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public long getExchangeWithdrawAnotherAmount() { + return exchangeWithdrawAnotherAmount_; + } + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public Builder setExchangeWithdrawAnotherAmount(long value) { + + exchangeWithdrawAnotherAmount_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_withdraw_another_amount = 20; + */ + public Builder clearExchangeWithdrawAnotherAmount() { + + exchangeWithdrawAnotherAmount_ = 0L; + onChanged(); + return this; + } + + private long exchangeId_ ; + /** + * int64 exchange_id = 21; + */ + public long getExchangeId() { + return exchangeId_; + } + /** + * int64 exchange_id = 21; + */ + public Builder setExchangeId(long value) { + + exchangeId_ = value; + onChanged(); + return this; + } + /** + * int64 exchange_id = 21; + */ + public Builder clearExchangeId() { + + exchangeId_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionInfo) + private static final org.tron.protos.Protocol.TransactionInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TransactionInfo(); + } + + public static org.tron.protos.Protocol.TransactionInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TransactionInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionRetOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionRet) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 blockNumber = 1; + */ + long getBlockNumber(); + + /** + * int64 blockTimeStamp = 2; + */ + long getBlockTimeStamp(); + + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + java.util.List + getTransactioninfoList(); + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + org.tron.protos.Protocol.TransactionInfo getTransactioninfo(int index); + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + int getTransactioninfoCount(); + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + java.util.List + getTransactioninfoOrBuilderList(); + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + org.tron.protos.Protocol.TransactionInfoOrBuilder getTransactioninfoOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.TransactionRet} + */ + public static final class TransactionRet extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionRet) + TransactionRetOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionRet.newBuilder() to construct. + private TransactionRet(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionRet() { + blockNumber_ = 0L; + blockTimeStamp_ = 0L; + transactioninfo_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionRet( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + blockNumber_ = input.readInt64(); + break; + } + case 16: { + + blockTimeStamp_ = input.readInt64(); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + transactioninfo_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + transactioninfo_.add( + input.readMessage(org.tron.protos.Protocol.TransactionInfo.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + transactioninfo_ = java.util.Collections.unmodifiableList(transactioninfo_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionRet_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionRet_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionRet.class, org.tron.protos.Protocol.TransactionRet.Builder.class); + } + + private int bitField0_; + public static final int BLOCKNUMBER_FIELD_NUMBER = 1; + private long blockNumber_; + /** + * int64 blockNumber = 1; + */ + public long getBlockNumber() { + return blockNumber_; + } + + public static final int BLOCKTIMESTAMP_FIELD_NUMBER = 2; + private long blockTimeStamp_; + /** + * int64 blockTimeStamp = 2; + */ + public long getBlockTimeStamp() { + return blockTimeStamp_; + } + + public static final int TRANSACTIONINFO_FIELD_NUMBER = 3; + private java.util.List transactioninfo_; + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public java.util.List getTransactioninfoList() { + return transactioninfo_; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public java.util.List + getTransactioninfoOrBuilderList() { + return transactioninfo_; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public int getTransactioninfoCount() { + return transactioninfo_.size(); + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public org.tron.protos.Protocol.TransactionInfo getTransactioninfo(int index) { + return transactioninfo_.get(index); + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public org.tron.protos.Protocol.TransactionInfoOrBuilder getTransactioninfoOrBuilder( + int index) { + return transactioninfo_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (blockNumber_ != 0L) { + output.writeInt64(1, blockNumber_); + } + if (blockTimeStamp_ != 0L) { + output.writeInt64(2, blockTimeStamp_); + } + for (int i = 0; i < transactioninfo_.size(); i++) { + output.writeMessage(3, transactioninfo_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (blockNumber_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, blockNumber_); + } + if (blockTimeStamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, blockTimeStamp_); + } + for (int i = 0; i < transactioninfo_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, transactioninfo_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TransactionRet)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TransactionRet other = (org.tron.protos.Protocol.TransactionRet) obj; + + boolean result = true; + result = result && (getBlockNumber() + == other.getBlockNumber()); + result = result && (getBlockTimeStamp() + == other.getBlockTimeStamp()); + result = result && getTransactioninfoList() + .equals(other.getTransactioninfoList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BLOCKNUMBER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBlockNumber()); + hash = (37 * hash) + BLOCKTIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBlockTimeStamp()); + if (getTransactioninfoCount() > 0) { + hash = (37 * hash) + TRANSACTIONINFO_FIELD_NUMBER; + hash = (53 * hash) + getTransactioninfoList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TransactionRet parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionRet parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionRet parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionRet parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TransactionRet prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionRet} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionRet) + org.tron.protos.Protocol.TransactionRetOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionRet_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionRet_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionRet.class, org.tron.protos.Protocol.TransactionRet.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TransactionRet.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTransactioninfoFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + blockNumber_ = 0L; + + blockTimeStamp_ = 0L; + + if (transactioninfoBuilder_ == null) { + transactioninfo_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + transactioninfoBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionRet_descriptor; + } + + public org.tron.protos.Protocol.TransactionRet getDefaultInstanceForType() { + return org.tron.protos.Protocol.TransactionRet.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TransactionRet build() { + org.tron.protos.Protocol.TransactionRet result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TransactionRet buildPartial() { + org.tron.protos.Protocol.TransactionRet result = new org.tron.protos.Protocol.TransactionRet(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.blockNumber_ = blockNumber_; + result.blockTimeStamp_ = blockTimeStamp_; + if (transactioninfoBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + transactioninfo_ = java.util.Collections.unmodifiableList(transactioninfo_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.transactioninfo_ = transactioninfo_; + } else { + result.transactioninfo_ = transactioninfoBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TransactionRet) { + return mergeFrom((org.tron.protos.Protocol.TransactionRet)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TransactionRet other) { + if (other == org.tron.protos.Protocol.TransactionRet.getDefaultInstance()) return this; + if (other.getBlockNumber() != 0L) { + setBlockNumber(other.getBlockNumber()); + } + if (other.getBlockTimeStamp() != 0L) { + setBlockTimeStamp(other.getBlockTimeStamp()); + } + if (transactioninfoBuilder_ == null) { + if (!other.transactioninfo_.isEmpty()) { + if (transactioninfo_.isEmpty()) { + transactioninfo_ = other.transactioninfo_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureTransactioninfoIsMutable(); + transactioninfo_.addAll(other.transactioninfo_); + } + onChanged(); + } + } else { + if (!other.transactioninfo_.isEmpty()) { + if (transactioninfoBuilder_.isEmpty()) { + transactioninfoBuilder_.dispose(); + transactioninfoBuilder_ = null; + transactioninfo_ = other.transactioninfo_; + bitField0_ = (bitField0_ & ~0x00000004); + transactioninfoBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTransactioninfoFieldBuilder() : null; + } else { + transactioninfoBuilder_.addAllMessages(other.transactioninfo_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TransactionRet parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TransactionRet) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long blockNumber_ ; + /** + * int64 blockNumber = 1; + */ + public long getBlockNumber() { + return blockNumber_; + } + /** + * int64 blockNumber = 1; + */ + public Builder setBlockNumber(long value) { + + blockNumber_ = value; + onChanged(); + return this; + } + /** + * int64 blockNumber = 1; + */ + public Builder clearBlockNumber() { + + blockNumber_ = 0L; + onChanged(); + return this; + } + + private long blockTimeStamp_ ; + /** + * int64 blockTimeStamp = 2; + */ + public long getBlockTimeStamp() { + return blockTimeStamp_; + } + /** + * int64 blockTimeStamp = 2; + */ + public Builder setBlockTimeStamp(long value) { + + blockTimeStamp_ = value; + onChanged(); + return this; + } + /** + * int64 blockTimeStamp = 2; + */ + public Builder clearBlockTimeStamp() { + + blockTimeStamp_ = 0L; + onChanged(); + return this; + } + + private java.util.List transactioninfo_ = + java.util.Collections.emptyList(); + private void ensureTransactioninfoIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + transactioninfo_ = new java.util.ArrayList(transactioninfo_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TransactionInfo, org.tron.protos.Protocol.TransactionInfo.Builder, org.tron.protos.Protocol.TransactionInfoOrBuilder> transactioninfoBuilder_; + + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public java.util.List getTransactioninfoList() { + if (transactioninfoBuilder_ == null) { + return java.util.Collections.unmodifiableList(transactioninfo_); + } else { + return transactioninfoBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public int getTransactioninfoCount() { + if (transactioninfoBuilder_ == null) { + return transactioninfo_.size(); + } else { + return transactioninfoBuilder_.getCount(); + } + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public org.tron.protos.Protocol.TransactionInfo getTransactioninfo(int index) { + if (transactioninfoBuilder_ == null) { + return transactioninfo_.get(index); + } else { + return transactioninfoBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder setTransactioninfo( + int index, org.tron.protos.Protocol.TransactionInfo value) { + if (transactioninfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactioninfoIsMutable(); + transactioninfo_.set(index, value); + onChanged(); + } else { + transactioninfoBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder setTransactioninfo( + int index, org.tron.protos.Protocol.TransactionInfo.Builder builderForValue) { + if (transactioninfoBuilder_ == null) { + ensureTransactioninfoIsMutable(); + transactioninfo_.set(index, builderForValue.build()); + onChanged(); + } else { + transactioninfoBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder addTransactioninfo(org.tron.protos.Protocol.TransactionInfo value) { + if (transactioninfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactioninfoIsMutable(); + transactioninfo_.add(value); + onChanged(); + } else { + transactioninfoBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder addTransactioninfo( + int index, org.tron.protos.Protocol.TransactionInfo value) { + if (transactioninfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactioninfoIsMutable(); + transactioninfo_.add(index, value); + onChanged(); + } else { + transactioninfoBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder addTransactioninfo( + org.tron.protos.Protocol.TransactionInfo.Builder builderForValue) { + if (transactioninfoBuilder_ == null) { + ensureTransactioninfoIsMutable(); + transactioninfo_.add(builderForValue.build()); + onChanged(); + } else { + transactioninfoBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder addTransactioninfo( + int index, org.tron.protos.Protocol.TransactionInfo.Builder builderForValue) { + if (transactioninfoBuilder_ == null) { + ensureTransactioninfoIsMutable(); + transactioninfo_.add(index, builderForValue.build()); + onChanged(); + } else { + transactioninfoBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder addAllTransactioninfo( + java.lang.Iterable values) { + if (transactioninfoBuilder_ == null) { + ensureTransactioninfoIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, transactioninfo_); + onChanged(); + } else { + transactioninfoBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder clearTransactioninfo() { + if (transactioninfoBuilder_ == null) { + transactioninfo_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + transactioninfoBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public Builder removeTransactioninfo(int index) { + if (transactioninfoBuilder_ == null) { + ensureTransactioninfoIsMutable(); + transactioninfo_.remove(index); + onChanged(); + } else { + transactioninfoBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public org.tron.protos.Protocol.TransactionInfo.Builder getTransactioninfoBuilder( + int index) { + return getTransactioninfoFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public org.tron.protos.Protocol.TransactionInfoOrBuilder getTransactioninfoOrBuilder( + int index) { + if (transactioninfoBuilder_ == null) { + return transactioninfo_.get(index); } else { + return transactioninfoBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public java.util.List + getTransactioninfoOrBuilderList() { + if (transactioninfoBuilder_ != null) { + return transactioninfoBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transactioninfo_); + } + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public org.tron.protos.Protocol.TransactionInfo.Builder addTransactioninfoBuilder() { + return getTransactioninfoFieldBuilder().addBuilder( + org.tron.protos.Protocol.TransactionInfo.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public org.tron.protos.Protocol.TransactionInfo.Builder addTransactioninfoBuilder( + int index) { + return getTransactioninfoFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.TransactionInfo.getDefaultInstance()); + } + /** + * repeated .protocol.TransactionInfo transactioninfo = 3; + */ + public java.util.List + getTransactioninfoBuilderList() { + return getTransactioninfoFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TransactionInfo, org.tron.protos.Protocol.TransactionInfo.Builder, org.tron.protos.Protocol.TransactionInfoOrBuilder> + getTransactioninfoFieldBuilder() { + if (transactioninfoBuilder_ == null) { + transactioninfoBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.TransactionInfo, org.tron.protos.Protocol.TransactionInfo.Builder, org.tron.protos.Protocol.TransactionInfoOrBuilder>( + transactioninfo_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + transactioninfo_ = null; + } + return transactioninfoBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionRet) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionRet) + private static final org.tron.protos.Protocol.TransactionRet DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TransactionRet(); + } + + public static org.tron.protos.Protocol.TransactionRet getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionRet parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionRet(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TransactionRet getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionsOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Transactions) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Transaction transactions = 1; + */ + java.util.List + getTransactionsList(); + /** + * repeated .protocol.Transaction transactions = 1; + */ + org.tron.protos.Protocol.Transaction getTransactions(int index); + /** + * repeated .protocol.Transaction transactions = 1; + */ + int getTransactionsCount(); + /** + * repeated .protocol.Transaction transactions = 1; + */ + java.util.List + getTransactionsOrBuilderList(); + /** + * repeated .protocol.Transaction transactions = 1; + */ + org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.Transactions} + */ + public static final class Transactions extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Transactions) + TransactionsOrBuilder { + private static final long serialVersionUID = 0L; + // Use Transactions.newBuilder() to construct. + private Transactions(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Transactions() { + transactions_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Transactions( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + transactions_.add( + input.readMessage(org.tron.protos.Protocol.Transaction.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transactions_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transactions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transactions.class, org.tron.protos.Protocol.Transactions.Builder.class); + } + + public static final int TRANSACTIONS_FIELD_NUMBER = 1; + private java.util.List transactions_; + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List getTransactionsList() { + return transactions_; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List + getTransactionsOrBuilderList() { + return transactions_; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public int getTransactionsCount() { + return transactions_.size(); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction getTransactions(int index) { + return transactions_.get(index); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index) { + return transactions_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < transactions_.size(); i++) { + output.writeMessage(1, transactions_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < transactions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, transactions_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Transactions)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Transactions other = (org.tron.protos.Protocol.Transactions) obj; + + boolean result = true; + result = result && getTransactionsList() + .equals(other.getTransactionsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTransactionsCount() > 0) { + hash = (37 * hash) + TRANSACTIONS_FIELD_NUMBER; + hash = (53 * hash) + getTransactionsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Transactions parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transactions parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transactions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transactions parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transactions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Transactions parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Transactions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transactions parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transactions parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transactions parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Transactions parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Transactions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Transactions prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Transactions} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Transactions) + org.tron.protos.Protocol.TransactionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Transactions_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Transactions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Transactions.class, org.tron.protos.Protocol.Transactions.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Transactions.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTransactionsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + transactionsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Transactions_descriptor; + } + + public org.tron.protos.Protocol.Transactions getDefaultInstanceForType() { + return org.tron.protos.Protocol.Transactions.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Transactions build() { + org.tron.protos.Protocol.Transactions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Transactions buildPartial() { + org.tron.protos.Protocol.Transactions result = new org.tron.protos.Protocol.Transactions(this); + int from_bitField0_ = bitField0_; + if (transactionsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.transactions_ = transactions_; + } else { + result.transactions_ = transactionsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Transactions) { + return mergeFrom((org.tron.protos.Protocol.Transactions)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Transactions other) { + if (other == org.tron.protos.Protocol.Transactions.getDefaultInstance()) return this; + if (transactionsBuilder_ == null) { + if (!other.transactions_.isEmpty()) { + if (transactions_.isEmpty()) { + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTransactionsIsMutable(); + transactions_.addAll(other.transactions_); + } + onChanged(); + } + } else { + if (!other.transactions_.isEmpty()) { + if (transactionsBuilder_.isEmpty()) { + transactionsBuilder_.dispose(); + transactionsBuilder_ = null; + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000001); + transactionsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTransactionsFieldBuilder() : null; + } else { + transactionsBuilder_.addAllMessages(other.transactions_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Transactions parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Transactions) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List transactions_ = + java.util.Collections.emptyList(); + private void ensureTransactionsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = new java.util.ArrayList(transactions_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> transactionsBuilder_; + + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List getTransactionsList() { + if (transactionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(transactions_); + } else { + return transactionsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public int getTransactionsCount() { + if (transactionsBuilder_ == null) { + return transactions_.size(); + } else { + return transactionsBuilder_.getCount(); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction getTransactions(int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); + } else { + return transactionsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder setTransactions( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.set(index, value); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder setTransactions( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.set(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions(org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(value); + onChanged(); + } else { + transactionsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(index, value); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions( + org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addAllTransactions( + java.lang.Iterable values) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, transactions_); + onChanged(); + } else { + transactionsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder clearTransactions() { + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + transactionsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder removeTransactions(int index) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.remove(index); + onChanged(); + } else { + transactionsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder getTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); } else { + return transactionsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List + getTransactionsOrBuilderList() { + if (transactionsBuilder_ != null) { + return transactionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transactions_); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionsBuilder() { + return getTransactionsFieldBuilder().addBuilder( + org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List + getTransactionsBuilderList() { + return getTransactionsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> + getTransactionsFieldBuilder() { + if (transactionsBuilder_ == null) { + transactionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder>( + transactions_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + transactions_ = null; + } + return transactionsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Transactions) + } + + // @@protoc_insertion_point(class_scope:protocol.Transactions) + private static final org.tron.protos.Protocol.Transactions DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Transactions(); + } + + public static org.tron.protos.Protocol.Transactions getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Transactions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Transactions(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Transactions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TransactionSignOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.TransactionSign) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Transaction transaction = 1; + */ + boolean hasTransaction(); + /** + * .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.Transaction getTransaction(); + /** + * .protocol.Transaction transaction = 1; + */ + org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder(); + + /** + * bytes privateKey = 2; + */ + com.google.protobuf.ByteString getPrivateKey(); + } + /** + * Protobuf type {@code protocol.TransactionSign} + */ + public static final class TransactionSign extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.TransactionSign) + TransactionSignOrBuilder { + private static final long serialVersionUID = 0L; + // Use TransactionSign.newBuilder() to construct. + private TransactionSign(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TransactionSign() { + privateKey_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TransactionSign( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.Transaction.Builder subBuilder = null; + if (transaction_ != null) { + subBuilder = transaction_.toBuilder(); + } + transaction_ = input.readMessage(org.tron.protos.Protocol.Transaction.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(transaction_); + transaction_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + + privateKey_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionSign_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionSign_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionSign.class, org.tron.protos.Protocol.TransactionSign.Builder.class); + } + + public static final int TRANSACTION_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.Transaction transaction_; + /** + * .protocol.Transaction transaction = 1; + */ + public boolean hasTransaction() { + return transaction_ != null; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction() { + return transaction_ == null ? org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder() { + return getTransaction(); + } + + public static final int PRIVATEKEY_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString privateKey_; + /** + * bytes privateKey = 2; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (transaction_ != null) { + output.writeMessage(1, getTransaction()); + } + if (!privateKey_.isEmpty()) { + output.writeBytes(2, privateKey_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (transaction_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getTransaction()); + } + if (!privateKey_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, privateKey_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.TransactionSign)) { + return super.equals(obj); + } + org.tron.protos.Protocol.TransactionSign other = (org.tron.protos.Protocol.TransactionSign) obj; + + boolean result = true; + result = result && (hasTransaction() == other.hasTransaction()); + if (hasTransaction()) { + result = result && getTransaction() + .equals(other.getTransaction()); + } + result = result && getPrivateKey() + .equals(other.getPrivateKey()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasTransaction()) { + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + } + hash = (37 * hash) + PRIVATEKEY_FIELD_NUMBER; + hash = (53 * hash) + getPrivateKey().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.TransactionSign parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionSign parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionSign parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.TransactionSign parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.TransactionSign prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.TransactionSign} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.TransactionSign) + org.tron.protos.Protocol.TransactionSignOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionSign_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionSign_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.TransactionSign.class, org.tron.protos.Protocol.TransactionSign.Builder.class); + } + + // Construct using org.tron.protos.Protocol.TransactionSign.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (transactionBuilder_ == null) { + transaction_ = null; + } else { + transaction_ = null; + transactionBuilder_ = null; + } + privateKey_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_TransactionSign_descriptor; + } + + public org.tron.protos.Protocol.TransactionSign getDefaultInstanceForType() { + return org.tron.protos.Protocol.TransactionSign.getDefaultInstance(); + } + + public org.tron.protos.Protocol.TransactionSign build() { + org.tron.protos.Protocol.TransactionSign result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.TransactionSign buildPartial() { + org.tron.protos.Protocol.TransactionSign result = new org.tron.protos.Protocol.TransactionSign(this); + if (transactionBuilder_ == null) { + result.transaction_ = transaction_; + } else { + result.transaction_ = transactionBuilder_.build(); + } + result.privateKey_ = privateKey_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.TransactionSign) { + return mergeFrom((org.tron.protos.Protocol.TransactionSign)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.TransactionSign other) { + if (other == org.tron.protos.Protocol.TransactionSign.getDefaultInstance()) return this; + if (other.hasTransaction()) { + mergeTransaction(other.getTransaction()); + } + if (other.getPrivateKey() != com.google.protobuf.ByteString.EMPTY) { + setPrivateKey(other.getPrivateKey()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.TransactionSign parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.TransactionSign) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Protocol.Transaction transaction_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> transactionBuilder_; + /** + * .protocol.Transaction transaction = 1; + */ + public boolean hasTransaction() { + return transactionBuilder_ != null || transaction_ != null; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction getTransaction() { + if (transactionBuilder_ == null) { + return transaction_ == null ? org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } else { + return transactionBuilder_.getMessage(); + } + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder setTransaction(org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + onChanged(); + } else { + transactionBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder setTransaction( + org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionBuilder_ == null) { + transaction_ = builderForValue.build(); + onChanged(); + } else { + transactionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder mergeTransaction(org.tron.protos.Protocol.Transaction value) { + if (transactionBuilder_ == null) { + if (transaction_ != null) { + transaction_ = + org.tron.protos.Protocol.Transaction.newBuilder(transaction_).mergeFrom(value).buildPartial(); + } else { + transaction_ = value; + } + onChanged(); + } else { + transactionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public Builder clearTransaction() { + if (transactionBuilder_ == null) { + transaction_ = null; + onChanged(); + } else { + transaction_ = null; + transactionBuilder_ = null; + } + + return this; + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder getTransactionBuilder() { + + onChanged(); + return getTransactionFieldBuilder().getBuilder(); + } + /** + * .protocol.Transaction transaction = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionOrBuilder() { + if (transactionBuilder_ != null) { + return transactionBuilder_.getMessageOrBuilder(); + } else { + return transaction_ == null ? + org.tron.protos.Protocol.Transaction.getDefaultInstance() : transaction_; + } + } + /** + * .protocol.Transaction transaction = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> + getTransactionFieldBuilder() { + if (transactionBuilder_ == null) { + transactionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder>( + getTransaction(), + getParentForChildren(), + isClean()); + transaction_ = null; + } + return transactionBuilder_; + } + + private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes privateKey = 2; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + /** + * bytes privateKey = 2; + */ + public Builder setPrivateKey(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + privateKey_ = value; + onChanged(); + return this; + } + /** + * bytes privateKey = 2; + */ + public Builder clearPrivateKey() { + + privateKey_ = getDefaultInstance().getPrivateKey(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.TransactionSign) + } + + // @@protoc_insertion_point(class_scope:protocol.TransactionSign) + private static final org.tron.protos.Protocol.TransactionSign DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.TransactionSign(); + } + + public static org.tron.protos.Protocol.TransactionSign getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TransactionSign parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TransactionSign(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.TransactionSign getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockHeaderOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockHeader) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + boolean hasRawData(); + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + org.tron.protos.Protocol.BlockHeader.raw getRawData(); + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + org.tron.protos.Protocol.BlockHeader.rawOrBuilder getRawDataOrBuilder(); + + /** + * bytes witness_signature = 2; + */ + com.google.protobuf.ByteString getWitnessSignature(); + } + /** + * Protobuf type {@code protocol.BlockHeader} + */ + public static final class BlockHeader extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockHeader) + BlockHeaderOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockHeader.newBuilder() to construct. + private BlockHeader(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockHeader() { + witnessSignature_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockHeader( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Protocol.BlockHeader.raw.Builder subBuilder = null; + if (rawData_ != null) { + subBuilder = rawData_.toBuilder(); + } + rawData_ = input.readMessage(org.tron.protos.Protocol.BlockHeader.raw.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(rawData_); + rawData_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + + witnessSignature_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockHeader.class, org.tron.protos.Protocol.BlockHeader.Builder.class); + } + + public interface rawOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockHeader.raw) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 timestamp = 1; + */ + long getTimestamp(); + + /** + * bytes txTrieRoot = 2; + */ + com.google.protobuf.ByteString getTxTrieRoot(); + + /** + * bytes parentHash = 3; + */ + com.google.protobuf.ByteString getParentHash(); + + /** + *
+       *bytes nonce = 5;
+       *bytes difficulty = 6;
+       * 
+ * + * int64 number = 7; + */ + long getNumber(); + + /** + * int64 witness_id = 8; + */ + long getWitnessId(); + + /** + * bytes witness_address = 9; + */ + com.google.protobuf.ByteString getWitnessAddress(); + + /** + * int32 version = 10; + */ + int getVersion(); + + /** + * bytes accountStateRoot = 11; + */ + com.google.protobuf.ByteString getAccountStateRoot(); + } + /** + * Protobuf type {@code protocol.BlockHeader.raw} + */ + public static final class raw extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockHeader.raw) + rawOrBuilder { + private static final long serialVersionUID = 0L; + // Use raw.newBuilder() to construct. + private raw(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private raw() { + timestamp_ = 0L; + txTrieRoot_ = com.google.protobuf.ByteString.EMPTY; + parentHash_ = com.google.protobuf.ByteString.EMPTY; + number_ = 0L; + witnessId_ = 0L; + witnessAddress_ = com.google.protobuf.ByteString.EMPTY; + version_ = 0; + accountStateRoot_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private raw( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + timestamp_ = input.readInt64(); + break; + } + case 18: { + + txTrieRoot_ = input.readBytes(); + break; + } + case 26: { + + parentHash_ = input.readBytes(); + break; + } + case 56: { + + number_ = input.readInt64(); + break; + } + case 64: { + + witnessId_ = input.readInt64(); + break; + } + case 74: { + + witnessAddress_ = input.readBytes(); + break; + } + case 80: { + + version_ = input.readInt32(); + break; + } + case 90: { + + accountStateRoot_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_raw_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_raw_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockHeader.raw.class, org.tron.protos.Protocol.BlockHeader.raw.Builder.class); + } + + public static final int TIMESTAMP_FIELD_NUMBER = 1; + private long timestamp_; + /** + * int64 timestamp = 1; + */ + public long getTimestamp() { + return timestamp_; + } + + public static final int TXTRIEROOT_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString txTrieRoot_; + /** + * bytes txTrieRoot = 2; + */ + public com.google.protobuf.ByteString getTxTrieRoot() { + return txTrieRoot_; + } + + public static final int PARENTHASH_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString parentHash_; + /** + * bytes parentHash = 3; + */ + public com.google.protobuf.ByteString getParentHash() { + return parentHash_; + } + + public static final int NUMBER_FIELD_NUMBER = 7; + private long number_; + /** + *
+       *bytes nonce = 5;
+       *bytes difficulty = 6;
+       * 
+ * + * int64 number = 7; + */ + public long getNumber() { + return number_; + } + + public static final int WITNESS_ID_FIELD_NUMBER = 8; + private long witnessId_; + /** + * int64 witness_id = 8; + */ + public long getWitnessId() { + return witnessId_; + } + + public static final int WITNESS_ADDRESS_FIELD_NUMBER = 9; + private com.google.protobuf.ByteString witnessAddress_; + /** + * bytes witness_address = 9; + */ + public com.google.protobuf.ByteString getWitnessAddress() { + return witnessAddress_; + } + + public static final int VERSION_FIELD_NUMBER = 10; + private int version_; + /** + * int32 version = 10; + */ + public int getVersion() { + return version_; + } + + public static final int ACCOUNTSTATEROOT_FIELD_NUMBER = 11; + private com.google.protobuf.ByteString accountStateRoot_; + /** + * bytes accountStateRoot = 11; + */ + public com.google.protobuf.ByteString getAccountStateRoot() { + return accountStateRoot_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (timestamp_ != 0L) { + output.writeInt64(1, timestamp_); + } + if (!txTrieRoot_.isEmpty()) { + output.writeBytes(2, txTrieRoot_); + } + if (!parentHash_.isEmpty()) { + output.writeBytes(3, parentHash_); + } + if (number_ != 0L) { + output.writeInt64(7, number_); + } + if (witnessId_ != 0L) { + output.writeInt64(8, witnessId_); + } + if (!witnessAddress_.isEmpty()) { + output.writeBytes(9, witnessAddress_); + } + if (version_ != 0) { + output.writeInt32(10, version_); + } + if (!accountStateRoot_.isEmpty()) { + output.writeBytes(11, accountStateRoot_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, timestamp_); + } + if (!txTrieRoot_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, txTrieRoot_); + } + if (!parentHash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, parentHash_); + } + if (number_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, number_); + } + if (witnessId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, witnessId_); + } + if (!witnessAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(9, witnessAddress_); + } + if (version_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(10, version_); + } + if (!accountStateRoot_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(11, accountStateRoot_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.BlockHeader.raw)) { + return super.equals(obj); + } + org.tron.protos.Protocol.BlockHeader.raw other = (org.tron.protos.Protocol.BlockHeader.raw) obj; + + boolean result = true; + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && getTxTrieRoot() + .equals(other.getTxTrieRoot()); + result = result && getParentHash() + .equals(other.getParentHash()); + result = result && (getNumber() + == other.getNumber()); + result = result && (getWitnessId() + == other.getWitnessId()); + result = result && getWitnessAddress() + .equals(other.getWitnessAddress()); + result = result && (getVersion() + == other.getVersion()); + result = result && getAccountStateRoot() + .equals(other.getAccountStateRoot()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + hash = (37 * hash) + TXTRIEROOT_FIELD_NUMBER; + hash = (53 * hash) + getTxTrieRoot().hashCode(); + hash = (37 * hash) + PARENTHASH_FIELD_NUMBER; + hash = (53 * hash) + getParentHash().hashCode(); + hash = (37 * hash) + NUMBER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNumber()); + hash = (37 * hash) + WITNESS_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getWitnessId()); + hash = (37 * hash) + WITNESS_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getWitnessAddress().hashCode(); + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion(); + hash = (37 * hash) + ACCOUNTSTATEROOT_FIELD_NUMBER; + hash = (53 * hash) + getAccountStateRoot().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockHeader.raw parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.BlockHeader.raw prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockHeader.raw} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockHeader.raw) + org.tron.protos.Protocol.BlockHeader.rawOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_raw_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_raw_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockHeader.raw.class, org.tron.protos.Protocol.BlockHeader.raw.Builder.class); + } + + // Construct using org.tron.protos.Protocol.BlockHeader.raw.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + timestamp_ = 0L; + + txTrieRoot_ = com.google.protobuf.ByteString.EMPTY; + + parentHash_ = com.google.protobuf.ByteString.EMPTY; + + number_ = 0L; + + witnessId_ = 0L; + + witnessAddress_ = com.google.protobuf.ByteString.EMPTY; + + version_ = 0; + + accountStateRoot_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_raw_descriptor; + } + + public org.tron.protos.Protocol.BlockHeader.raw getDefaultInstanceForType() { + return org.tron.protos.Protocol.BlockHeader.raw.getDefaultInstance(); + } + + public org.tron.protos.Protocol.BlockHeader.raw build() { + org.tron.protos.Protocol.BlockHeader.raw result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.BlockHeader.raw buildPartial() { + org.tron.protos.Protocol.BlockHeader.raw result = new org.tron.protos.Protocol.BlockHeader.raw(this); + result.timestamp_ = timestamp_; + result.txTrieRoot_ = txTrieRoot_; + result.parentHash_ = parentHash_; + result.number_ = number_; + result.witnessId_ = witnessId_; + result.witnessAddress_ = witnessAddress_; + result.version_ = version_; + result.accountStateRoot_ = accountStateRoot_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.BlockHeader.raw) { + return mergeFrom((org.tron.protos.Protocol.BlockHeader.raw)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.BlockHeader.raw other) { + if (other == org.tron.protos.Protocol.BlockHeader.raw.getDefaultInstance()) return this; + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + if (other.getTxTrieRoot() != com.google.protobuf.ByteString.EMPTY) { + setTxTrieRoot(other.getTxTrieRoot()); + } + if (other.getParentHash() != com.google.protobuf.ByteString.EMPTY) { + setParentHash(other.getParentHash()); + } + if (other.getNumber() != 0L) { + setNumber(other.getNumber()); + } + if (other.getWitnessId() != 0L) { + setWitnessId(other.getWitnessId()); + } + if (other.getWitnessAddress() != com.google.protobuf.ByteString.EMPTY) { + setWitnessAddress(other.getWitnessAddress()); + } + if (other.getVersion() != 0) { + setVersion(other.getVersion()); + } + if (other.getAccountStateRoot() != com.google.protobuf.ByteString.EMPTY) { + setAccountStateRoot(other.getAccountStateRoot()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.BlockHeader.raw parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.BlockHeader.raw) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long timestamp_ ; + /** + * int64 timestamp = 1; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 1; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 1; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString txTrieRoot_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes txTrieRoot = 2; + */ + public com.google.protobuf.ByteString getTxTrieRoot() { + return txTrieRoot_; + } + /** + * bytes txTrieRoot = 2; + */ + public Builder setTxTrieRoot(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + txTrieRoot_ = value; + onChanged(); + return this; + } + /** + * bytes txTrieRoot = 2; + */ + public Builder clearTxTrieRoot() { + + txTrieRoot_ = getDefaultInstance().getTxTrieRoot(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString parentHash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes parentHash = 3; + */ + public com.google.protobuf.ByteString getParentHash() { + return parentHash_; + } + /** + * bytes parentHash = 3; + */ + public Builder setParentHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + parentHash_ = value; + onChanged(); + return this; + } + /** + * bytes parentHash = 3; + */ + public Builder clearParentHash() { + + parentHash_ = getDefaultInstance().getParentHash(); + onChanged(); + return this; + } + + private long number_ ; + /** + *
+         *bytes nonce = 5;
+         *bytes difficulty = 6;
+         * 
+ * + * int64 number = 7; + */ + public long getNumber() { + return number_; + } + /** + *
+         *bytes nonce = 5;
+         *bytes difficulty = 6;
+         * 
+ * + * int64 number = 7; + */ + public Builder setNumber(long value) { + + number_ = value; + onChanged(); + return this; + } + /** + *
+         *bytes nonce = 5;
+         *bytes difficulty = 6;
+         * 
+ * + * int64 number = 7; + */ + public Builder clearNumber() { + + number_ = 0L; + onChanged(); + return this; + } + + private long witnessId_ ; + /** + * int64 witness_id = 8; + */ + public long getWitnessId() { + return witnessId_; + } + /** + * int64 witness_id = 8; + */ + public Builder setWitnessId(long value) { + + witnessId_ = value; + onChanged(); + return this; + } + /** + * int64 witness_id = 8; + */ + public Builder clearWitnessId() { + + witnessId_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString witnessAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes witness_address = 9; + */ + public com.google.protobuf.ByteString getWitnessAddress() { + return witnessAddress_; + } + /** + * bytes witness_address = 9; + */ + public Builder setWitnessAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + witnessAddress_ = value; + onChanged(); + return this; + } + /** + * bytes witness_address = 9; + */ + public Builder clearWitnessAddress() { + + witnessAddress_ = getDefaultInstance().getWitnessAddress(); + onChanged(); + return this; + } + + private int version_ ; + /** + * int32 version = 10; + */ + public int getVersion() { + return version_; + } + /** + * int32 version = 10; + */ + public Builder setVersion(int value) { + + version_ = value; + onChanged(); + return this; + } + /** + * int32 version = 10; + */ + public Builder clearVersion() { + + version_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString accountStateRoot_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes accountStateRoot = 11; + */ + public com.google.protobuf.ByteString getAccountStateRoot() { + return accountStateRoot_; + } + /** + * bytes accountStateRoot = 11; + */ + public Builder setAccountStateRoot(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + accountStateRoot_ = value; + onChanged(); + return this; + } + /** + * bytes accountStateRoot = 11; + */ + public Builder clearAccountStateRoot() { + + accountStateRoot_ = getDefaultInstance().getAccountStateRoot(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockHeader.raw) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockHeader.raw) + private static final org.tron.protos.Protocol.BlockHeader.raw DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.BlockHeader.raw(); + } + + public static org.tron.protos.Protocol.BlockHeader.raw getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public raw parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new raw(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.BlockHeader.raw getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int RAW_DATA_FIELD_NUMBER = 1; + private org.tron.protos.Protocol.BlockHeader.raw rawData_; + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public boolean hasRawData() { + return rawData_ != null; + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public org.tron.protos.Protocol.BlockHeader.raw getRawData() { + return rawData_ == null ? org.tron.protos.Protocol.BlockHeader.raw.getDefaultInstance() : rawData_; + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public org.tron.protos.Protocol.BlockHeader.rawOrBuilder getRawDataOrBuilder() { + return getRawData(); + } + + public static final int WITNESS_SIGNATURE_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString witnessSignature_; + /** + * bytes witness_signature = 2; + */ + public com.google.protobuf.ByteString getWitnessSignature() { + return witnessSignature_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (rawData_ != null) { + output.writeMessage(1, getRawData()); + } + if (!witnessSignature_.isEmpty()) { + output.writeBytes(2, witnessSignature_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (rawData_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getRawData()); + } + if (!witnessSignature_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, witnessSignature_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.BlockHeader)) { + return super.equals(obj); + } + org.tron.protos.Protocol.BlockHeader other = (org.tron.protos.Protocol.BlockHeader) obj; + + boolean result = true; + result = result && (hasRawData() == other.hasRawData()); + if (hasRawData()) { + result = result && getRawData() + .equals(other.getRawData()); + } + result = result && getWitnessSignature() + .equals(other.getWitnessSignature()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasRawData()) { + hash = (37 * hash) + RAW_DATA_FIELD_NUMBER; + hash = (53 * hash) + getRawData().hashCode(); + } + hash = (37 * hash) + WITNESS_SIGNATURE_FIELD_NUMBER; + hash = (53 * hash) + getWitnessSignature().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.BlockHeader parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockHeader parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockHeader parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.BlockHeader prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockHeader} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockHeader) + org.tron.protos.Protocol.BlockHeaderOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockHeader.class, org.tron.protos.Protocol.BlockHeader.Builder.class); + } + + // Construct using org.tron.protos.Protocol.BlockHeader.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (rawDataBuilder_ == null) { + rawData_ = null; + } else { + rawData_ = null; + rawDataBuilder_ = null; + } + witnessSignature_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_BlockHeader_descriptor; + } + + public org.tron.protos.Protocol.BlockHeader getDefaultInstanceForType() { + return org.tron.protos.Protocol.BlockHeader.getDefaultInstance(); + } + + public org.tron.protos.Protocol.BlockHeader build() { + org.tron.protos.Protocol.BlockHeader result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.BlockHeader buildPartial() { + org.tron.protos.Protocol.BlockHeader result = new org.tron.protos.Protocol.BlockHeader(this); + if (rawDataBuilder_ == null) { + result.rawData_ = rawData_; + } else { + result.rawData_ = rawDataBuilder_.build(); + } + result.witnessSignature_ = witnessSignature_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.BlockHeader) { + return mergeFrom((org.tron.protos.Protocol.BlockHeader)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.BlockHeader other) { + if (other == org.tron.protos.Protocol.BlockHeader.getDefaultInstance()) return this; + if (other.hasRawData()) { + mergeRawData(other.getRawData()); + } + if (other.getWitnessSignature() != com.google.protobuf.ByteString.EMPTY) { + setWitnessSignature(other.getWitnessSignature()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.BlockHeader parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.BlockHeader) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Protocol.BlockHeader.raw rawData_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader.raw, org.tron.protos.Protocol.BlockHeader.raw.Builder, org.tron.protos.Protocol.BlockHeader.rawOrBuilder> rawDataBuilder_; + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public boolean hasRawData() { + return rawDataBuilder_ != null || rawData_ != null; + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public org.tron.protos.Protocol.BlockHeader.raw getRawData() { + if (rawDataBuilder_ == null) { + return rawData_ == null ? org.tron.protos.Protocol.BlockHeader.raw.getDefaultInstance() : rawData_; + } else { + return rawDataBuilder_.getMessage(); + } + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public Builder setRawData(org.tron.protos.Protocol.BlockHeader.raw value) { + if (rawDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + rawData_ = value; + onChanged(); + } else { + rawDataBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public Builder setRawData( + org.tron.protos.Protocol.BlockHeader.raw.Builder builderForValue) { + if (rawDataBuilder_ == null) { + rawData_ = builderForValue.build(); + onChanged(); + } else { + rawDataBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public Builder mergeRawData(org.tron.protos.Protocol.BlockHeader.raw value) { + if (rawDataBuilder_ == null) { + if (rawData_ != null) { + rawData_ = + org.tron.protos.Protocol.BlockHeader.raw.newBuilder(rawData_).mergeFrom(value).buildPartial(); + } else { + rawData_ = value; + } + onChanged(); + } else { + rawDataBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public Builder clearRawData() { + if (rawDataBuilder_ == null) { + rawData_ = null; + onChanged(); + } else { + rawData_ = null; + rawDataBuilder_ = null; + } + + return this; + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public org.tron.protos.Protocol.BlockHeader.raw.Builder getRawDataBuilder() { + + onChanged(); + return getRawDataFieldBuilder().getBuilder(); + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + public org.tron.protos.Protocol.BlockHeader.rawOrBuilder getRawDataOrBuilder() { + if (rawDataBuilder_ != null) { + return rawDataBuilder_.getMessageOrBuilder(); + } else { + return rawData_ == null ? + org.tron.protos.Protocol.BlockHeader.raw.getDefaultInstance() : rawData_; + } + } + /** + * .protocol.BlockHeader.raw raw_data = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader.raw, org.tron.protos.Protocol.BlockHeader.raw.Builder, org.tron.protos.Protocol.BlockHeader.rawOrBuilder> + getRawDataFieldBuilder() { + if (rawDataBuilder_ == null) { + rawDataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader.raw, org.tron.protos.Protocol.BlockHeader.raw.Builder, org.tron.protos.Protocol.BlockHeader.rawOrBuilder>( + getRawData(), + getParentForChildren(), + isClean()); + rawData_ = null; + } + return rawDataBuilder_; + } + + private com.google.protobuf.ByteString witnessSignature_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes witness_signature = 2; + */ + public com.google.protobuf.ByteString getWitnessSignature() { + return witnessSignature_; + } + /** + * bytes witness_signature = 2; + */ + public Builder setWitnessSignature(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + witnessSignature_ = value; + onChanged(); + return this; + } + /** + * bytes witness_signature = 2; + */ + public Builder clearWitnessSignature() { + + witnessSignature_ = getDefaultInstance().getWitnessSignature(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockHeader) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockHeader) + private static final org.tron.protos.Protocol.BlockHeader DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.BlockHeader(); + } + + public static org.tron.protos.Protocol.BlockHeader getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockHeader parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockHeader(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.BlockHeader getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Block) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.Transaction transactions = 1; + */ + java.util.List + getTransactionsList(); + /** + * repeated .protocol.Transaction transactions = 1; + */ + org.tron.protos.Protocol.Transaction getTransactions(int index); + /** + * repeated .protocol.Transaction transactions = 1; + */ + int getTransactionsCount(); + /** + * repeated .protocol.Transaction transactions = 1; + */ + java.util.List + getTransactionsOrBuilderList(); + /** + * repeated .protocol.Transaction transactions = 1; + */ + org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index); + + /** + * .protocol.BlockHeader block_header = 2; + */ + boolean hasBlockHeader(); + /** + * .protocol.BlockHeader block_header = 2; + */ + org.tron.protos.Protocol.BlockHeader getBlockHeader(); + /** + * .protocol.BlockHeader block_header = 2; + */ + org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeaderOrBuilder(); + } + /** + *
+   * block
+   * 
+ * + * Protobuf type {@code protocol.Block} + */ + public static final class Block extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Block) + BlockOrBuilder { + private static final long serialVersionUID = 0L; + // Use Block.newBuilder() to construct. + private Block(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Block() { + transactions_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Block( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + transactions_.add( + input.readMessage(org.tron.protos.Protocol.Transaction.parser(), extensionRegistry)); + break; + } + case 18: { + org.tron.protos.Protocol.BlockHeader.Builder subBuilder = null; + if (blockHeader_ != null) { + subBuilder = blockHeader_.toBuilder(); + } + blockHeader_ = input.readMessage(org.tron.protos.Protocol.BlockHeader.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(blockHeader_); + blockHeader_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Block_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Block_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Block.class, org.tron.protos.Protocol.Block.Builder.class); + } + + private int bitField0_; + public static final int TRANSACTIONS_FIELD_NUMBER = 1; + private java.util.List transactions_; + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List getTransactionsList() { + return transactions_; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List + getTransactionsOrBuilderList() { + return transactions_; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public int getTransactionsCount() { + return transactions_.size(); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction getTransactions(int index) { + return transactions_.get(index); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index) { + return transactions_.get(index); + } + + public static final int BLOCK_HEADER_FIELD_NUMBER = 2; + private org.tron.protos.Protocol.BlockHeader blockHeader_; + /** + * .protocol.BlockHeader block_header = 2; + */ + public boolean hasBlockHeader() { + return blockHeader_ != null; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeader getBlockHeader() { + return blockHeader_ == null ? org.tron.protos.Protocol.BlockHeader.getDefaultInstance() : blockHeader_; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeaderOrBuilder() { + return getBlockHeader(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < transactions_.size(); i++) { + output.writeMessage(1, transactions_.get(i)); + } + if (blockHeader_ != null) { + output.writeMessage(2, getBlockHeader()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < transactions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, transactions_.get(i)); + } + if (blockHeader_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getBlockHeader()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Block)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Block other = (org.tron.protos.Protocol.Block) obj; + + boolean result = true; + result = result && getTransactionsList() + .equals(other.getTransactionsList()); + result = result && (hasBlockHeader() == other.hasBlockHeader()); + if (hasBlockHeader()) { + result = result && getBlockHeader() + .equals(other.getBlockHeader()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTransactionsCount() > 0) { + hash = (37 * hash) + TRANSACTIONS_FIELD_NUMBER; + hash = (53 * hash) + getTransactionsList().hashCode(); + } + if (hasBlockHeader()) { + hash = (37 * hash) + BLOCK_HEADER_FIELD_NUMBER; + hash = (53 * hash) + getBlockHeader().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Block parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Block parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Block parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Block parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Block parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Block parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Block parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Block parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Block parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Block parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Block parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Block parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Block prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * block
+     * 
+ * + * Protobuf type {@code protocol.Block} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Block) + org.tron.protos.Protocol.BlockOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Block_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Block_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Block.class, org.tron.protos.Protocol.Block.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Block.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTransactionsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + transactionsBuilder_.clear(); + } + if (blockHeaderBuilder_ == null) { + blockHeader_ = null; + } else { + blockHeader_ = null; + blockHeaderBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Block_descriptor; + } + + public org.tron.protos.Protocol.Block getDefaultInstanceForType() { + return org.tron.protos.Protocol.Block.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Block build() { + org.tron.protos.Protocol.Block result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Block buildPartial() { + org.tron.protos.Protocol.Block result = new org.tron.protos.Protocol.Block(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (transactionsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.transactions_ = transactions_; + } else { + result.transactions_ = transactionsBuilder_.build(); + } + if (blockHeaderBuilder_ == null) { + result.blockHeader_ = blockHeader_; + } else { + result.blockHeader_ = blockHeaderBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Block) { + return mergeFrom((org.tron.protos.Protocol.Block)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Block other) { + if (other == org.tron.protos.Protocol.Block.getDefaultInstance()) return this; + if (transactionsBuilder_ == null) { + if (!other.transactions_.isEmpty()) { + if (transactions_.isEmpty()) { + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTransactionsIsMutable(); + transactions_.addAll(other.transactions_); + } + onChanged(); + } + } else { + if (!other.transactions_.isEmpty()) { + if (transactionsBuilder_.isEmpty()) { + transactionsBuilder_.dispose(); + transactionsBuilder_ = null; + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000001); + transactionsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTransactionsFieldBuilder() : null; + } else { + transactionsBuilder_.addAllMessages(other.transactions_); + } + } + } + if (other.hasBlockHeader()) { + mergeBlockHeader(other.getBlockHeader()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Block parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Block) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List transactions_ = + java.util.Collections.emptyList(); + private void ensureTransactionsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + transactions_ = new java.util.ArrayList(transactions_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> transactionsBuilder_; + + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List getTransactionsList() { + if (transactionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(transactions_); + } else { + return transactionsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public int getTransactionsCount() { + if (transactionsBuilder_ == null) { + return transactions_.size(); + } else { + return transactionsBuilder_.getCount(); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction getTransactions(int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); + } else { + return transactionsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder setTransactions( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.set(index, value); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder setTransactions( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.set(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions(org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(value); + onChanged(); + } else { + transactionsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(index, value); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions( + org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addTransactions( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder addAllTransactions( + java.lang.Iterable values) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, transactions_); + onChanged(); + } else { + transactionsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder clearTransactions() { + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + transactionsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public Builder removeTransactions(int index) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.remove(index); + onChanged(); + } else { + transactionsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder getTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); } else { + return transactionsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List + getTransactionsOrBuilderList() { + if (transactionsBuilder_ != null) { + return transactionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transactions_); + } + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionsBuilder() { + return getTransactionsFieldBuilder().addBuilder( + org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transactions = 1; + */ + public java.util.List + getTransactionsBuilderList() { + return getTransactionsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> + getTransactionsFieldBuilder() { + if (transactionsBuilder_ == null) { + transactionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder>( + transactions_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + transactions_ = null; + } + return transactionsBuilder_; + } + + private org.tron.protos.Protocol.BlockHeader blockHeader_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder> blockHeaderBuilder_; + /** + * .protocol.BlockHeader block_header = 2; + */ + public boolean hasBlockHeader() { + return blockHeaderBuilder_ != null || blockHeader_ != null; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeader getBlockHeader() { + if (blockHeaderBuilder_ == null) { + return blockHeader_ == null ? org.tron.protos.Protocol.BlockHeader.getDefaultInstance() : blockHeader_; + } else { + return blockHeaderBuilder_.getMessage(); + } + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder setBlockHeader(org.tron.protos.Protocol.BlockHeader value) { + if (blockHeaderBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + blockHeader_ = value; + onChanged(); + } else { + blockHeaderBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder setBlockHeader( + org.tron.protos.Protocol.BlockHeader.Builder builderForValue) { + if (blockHeaderBuilder_ == null) { + blockHeader_ = builderForValue.build(); + onChanged(); + } else { + blockHeaderBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder mergeBlockHeader(org.tron.protos.Protocol.BlockHeader value) { + if (blockHeaderBuilder_ == null) { + if (blockHeader_ != null) { + blockHeader_ = + org.tron.protos.Protocol.BlockHeader.newBuilder(blockHeader_).mergeFrom(value).buildPartial(); + } else { + blockHeader_ = value; + } + onChanged(); + } else { + blockHeaderBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public Builder clearBlockHeader() { + if (blockHeaderBuilder_ == null) { + blockHeader_ = null; + onChanged(); + } else { + blockHeader_ = null; + blockHeaderBuilder_ = null; + } + + return this; + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeader.Builder getBlockHeaderBuilder() { + + onChanged(); + return getBlockHeaderFieldBuilder().getBuilder(); + } + /** + * .protocol.BlockHeader block_header = 2; + */ + public org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeaderOrBuilder() { + if (blockHeaderBuilder_ != null) { + return blockHeaderBuilder_.getMessageOrBuilder(); + } else { + return blockHeader_ == null ? + org.tron.protos.Protocol.BlockHeader.getDefaultInstance() : blockHeader_; + } + } + /** + * .protocol.BlockHeader block_header = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder> + getBlockHeaderFieldBuilder() { + if (blockHeaderBuilder_ == null) { + blockHeaderBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder>( + getBlockHeader(), + getParentForChildren(), + isClean()); + blockHeader_ = null; + } + return blockHeaderBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Block) + } + + // @@protoc_insertion_point(class_scope:protocol.Block) + private static final org.tron.protos.Protocol.Block DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Block(); + } + + public static org.tron.protos.Protocol.Block getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Block parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Block(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Block getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ChainInventoryOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ChainInventory) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + java.util.List + getIdsList(); + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + org.tron.protos.Protocol.ChainInventory.BlockId getIds(int index); + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + int getIdsCount(); + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + java.util.List + getIdsOrBuilderList(); + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + org.tron.protos.Protocol.ChainInventory.BlockIdOrBuilder getIdsOrBuilder( + int index); + + /** + * int64 remain_num = 2; + */ + long getRemainNum(); + } + /** + * Protobuf type {@code protocol.ChainInventory} + */ + public static final class ChainInventory extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ChainInventory) + ChainInventoryOrBuilder { + private static final long serialVersionUID = 0L; + // Use ChainInventory.newBuilder() to construct. + private ChainInventory(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ChainInventory() { + ids_ = java.util.Collections.emptyList(); + remainNum_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ChainInventory( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + ids_.add( + input.readMessage(org.tron.protos.Protocol.ChainInventory.BlockId.parser(), extensionRegistry)); + break; + } + case 16: { + + remainNum_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = java.util.Collections.unmodifiableList(ids_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainInventory.class, org.tron.protos.Protocol.ChainInventory.Builder.class); + } + + public interface BlockIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.ChainInventory.BlockId) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes hash = 1; + */ + com.google.protobuf.ByteString getHash(); + + /** + * int64 number = 2; + */ + long getNumber(); + } + /** + * Protobuf type {@code protocol.ChainInventory.BlockId} + */ + public static final class BlockId extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.ChainInventory.BlockId) + BlockIdOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockId.newBuilder() to construct. + private BlockId(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockId() { + hash_ = com.google.protobuf.ByteString.EMPTY; + number_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockId( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + hash_ = input.readBytes(); + break; + } + case 16: { + + number_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_BlockId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_BlockId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainInventory.BlockId.class, org.tron.protos.Protocol.ChainInventory.BlockId.Builder.class); + } + + public static final int HASH_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString hash_; + /** + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + + public static final int NUMBER_FIELD_NUMBER = 2; + private long number_; + /** + * int64 number = 2; + */ + public long getNumber() { + return number_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!hash_.isEmpty()) { + output.writeBytes(1, hash_); + } + if (number_ != 0L) { + output.writeInt64(2, number_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, hash_); + } + if (number_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, number_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.ChainInventory.BlockId)) { + return super.equals(obj); + } + org.tron.protos.Protocol.ChainInventory.BlockId other = (org.tron.protos.Protocol.ChainInventory.BlockId) obj; + + boolean result = true; + result = result && getHash() + .equals(other.getHash()); + result = result && (getNumber() + == other.getNumber()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + HASH_FIELD_NUMBER; + hash = (53 * hash) + getHash().hashCode(); + hash = (37 * hash) + NUMBER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNumber()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainInventory.BlockId parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.ChainInventory.BlockId prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ChainInventory.BlockId} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ChainInventory.BlockId) + org.tron.protos.Protocol.ChainInventory.BlockIdOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_BlockId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_BlockId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainInventory.BlockId.class, org.tron.protos.Protocol.ChainInventory.BlockId.Builder.class); + } + + // Construct using org.tron.protos.Protocol.ChainInventory.BlockId.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + hash_ = com.google.protobuf.ByteString.EMPTY; + + number_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_BlockId_descriptor; + } + + public org.tron.protos.Protocol.ChainInventory.BlockId getDefaultInstanceForType() { + return org.tron.protos.Protocol.ChainInventory.BlockId.getDefaultInstance(); + } + + public org.tron.protos.Protocol.ChainInventory.BlockId build() { + org.tron.protos.Protocol.ChainInventory.BlockId result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.ChainInventory.BlockId buildPartial() { + org.tron.protos.Protocol.ChainInventory.BlockId result = new org.tron.protos.Protocol.ChainInventory.BlockId(this); + result.hash_ = hash_; + result.number_ = number_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.ChainInventory.BlockId) { + return mergeFrom((org.tron.protos.Protocol.ChainInventory.BlockId)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.ChainInventory.BlockId other) { + if (other == org.tron.protos.Protocol.ChainInventory.BlockId.getDefaultInstance()) return this; + if (other.getHash() != com.google.protobuf.ByteString.EMPTY) { + setHash(other.getHash()); + } + if (other.getNumber() != 0L) { + setNumber(other.getNumber()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.ChainInventory.BlockId parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.ChainInventory.BlockId) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString hash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + * bytes hash = 1; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + onChanged(); + return this; + } + /** + * bytes hash = 1; + */ + public Builder clearHash() { + + hash_ = getDefaultInstance().getHash(); + onChanged(); + return this; + } + + private long number_ ; + /** + * int64 number = 2; + */ + public long getNumber() { + return number_; + } + /** + * int64 number = 2; + */ + public Builder setNumber(long value) { + + number_ = value; + onChanged(); + return this; + } + /** + * int64 number = 2; + */ + public Builder clearNumber() { + + number_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ChainInventory.BlockId) + } + + // @@protoc_insertion_point(class_scope:protocol.ChainInventory.BlockId) + private static final org.tron.protos.Protocol.ChainInventory.BlockId DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.ChainInventory.BlockId(); + } + + public static org.tron.protos.Protocol.ChainInventory.BlockId getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockId parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockId(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.ChainInventory.BlockId getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int IDS_FIELD_NUMBER = 1; + private java.util.List ids_; + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public java.util.List getIdsList() { + return ids_; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public java.util.List + getIdsOrBuilderList() { + return ids_; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public int getIdsCount() { + return ids_.size(); + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.ChainInventory.BlockId getIds(int index) { + return ids_.get(index); + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.ChainInventory.BlockIdOrBuilder getIdsOrBuilder( + int index) { + return ids_.get(index); + } + + public static final int REMAIN_NUM_FIELD_NUMBER = 2; + private long remainNum_; + /** + * int64 remain_num = 2; + */ + public long getRemainNum() { + return remainNum_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < ids_.size(); i++) { + output.writeMessage(1, ids_.get(i)); + } + if (remainNum_ != 0L) { + output.writeInt64(2, remainNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < ids_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, ids_.get(i)); + } + if (remainNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, remainNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.ChainInventory)) { + return super.equals(obj); + } + org.tron.protos.Protocol.ChainInventory other = (org.tron.protos.Protocol.ChainInventory) obj; + + boolean result = true; + result = result && getIdsList() + .equals(other.getIdsList()); + result = result && (getRemainNum() + == other.getRemainNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getIdsCount() > 0) { + hash = (37 * hash) + IDS_FIELD_NUMBER; + hash = (53 * hash) + getIdsList().hashCode(); + } + hash = (37 * hash) + REMAIN_NUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getRemainNum()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.ChainInventory parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainInventory parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.ChainInventory parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.ChainInventory prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.ChainInventory} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.ChainInventory) + org.tron.protos.Protocol.ChainInventoryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.ChainInventory.class, org.tron.protos.Protocol.ChainInventory.Builder.class); + } + + // Construct using org.tron.protos.Protocol.ChainInventory.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getIdsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (idsBuilder_ == null) { + ids_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + idsBuilder_.clear(); + } + remainNum_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_ChainInventory_descriptor; + } + + public org.tron.protos.Protocol.ChainInventory getDefaultInstanceForType() { + return org.tron.protos.Protocol.ChainInventory.getDefaultInstance(); + } + + public org.tron.protos.Protocol.ChainInventory build() { + org.tron.protos.Protocol.ChainInventory result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.ChainInventory buildPartial() { + org.tron.protos.Protocol.ChainInventory result = new org.tron.protos.Protocol.ChainInventory(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (idsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = java.util.Collections.unmodifiableList(ids_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.ids_ = ids_; + } else { + result.ids_ = idsBuilder_.build(); + } + result.remainNum_ = remainNum_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.ChainInventory) { + return mergeFrom((org.tron.protos.Protocol.ChainInventory)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.ChainInventory other) { + if (other == org.tron.protos.Protocol.ChainInventory.getDefaultInstance()) return this; + if (idsBuilder_ == null) { + if (!other.ids_.isEmpty()) { + if (ids_.isEmpty()) { + ids_ = other.ids_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIdsIsMutable(); + ids_.addAll(other.ids_); + } + onChanged(); + } + } else { + if (!other.ids_.isEmpty()) { + if (idsBuilder_.isEmpty()) { + idsBuilder_.dispose(); + idsBuilder_ = null; + ids_ = other.ids_; + bitField0_ = (bitField0_ & ~0x00000001); + idsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getIdsFieldBuilder() : null; + } else { + idsBuilder_.addAllMessages(other.ids_); + } + } + } + if (other.getRemainNum() != 0L) { + setRemainNum(other.getRemainNum()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.ChainInventory parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.ChainInventory) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List ids_ = + java.util.Collections.emptyList(); + private void ensureIdsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = new java.util.ArrayList(ids_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.ChainInventory.BlockId, org.tron.protos.Protocol.ChainInventory.BlockId.Builder, org.tron.protos.Protocol.ChainInventory.BlockIdOrBuilder> idsBuilder_; + + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public java.util.List getIdsList() { + if (idsBuilder_ == null) { + return java.util.Collections.unmodifiableList(ids_); + } else { + return idsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public int getIdsCount() { + if (idsBuilder_ == null) { + return ids_.size(); + } else { + return idsBuilder_.getCount(); + } + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.ChainInventory.BlockId getIds(int index) { + if (idsBuilder_ == null) { + return ids_.get(index); + } else { + return idsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder setIds( + int index, org.tron.protos.Protocol.ChainInventory.BlockId value) { + if (idsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.set(index, value); + onChanged(); + } else { + idsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder setIds( + int index, org.tron.protos.Protocol.ChainInventory.BlockId.Builder builderForValue) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.set(index, builderForValue.build()); + onChanged(); + } else { + idsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder addIds(org.tron.protos.Protocol.ChainInventory.BlockId value) { + if (idsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.add(value); + onChanged(); + } else { + idsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder addIds( + int index, org.tron.protos.Protocol.ChainInventory.BlockId value) { + if (idsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.add(index, value); + onChanged(); + } else { + idsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder addIds( + org.tron.protos.Protocol.ChainInventory.BlockId.Builder builderForValue) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.add(builderForValue.build()); + onChanged(); + } else { + idsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder addIds( + int index, org.tron.protos.Protocol.ChainInventory.BlockId.Builder builderForValue) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.add(index, builderForValue.build()); + onChanged(); + } else { + idsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder addAllIds( + java.lang.Iterable values) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, ids_); + onChanged(); + } else { + idsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder clearIds() { + if (idsBuilder_ == null) { + ids_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + idsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public Builder removeIds(int index) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.remove(index); + onChanged(); + } else { + idsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.ChainInventory.BlockId.Builder getIdsBuilder( + int index) { + return getIdsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.ChainInventory.BlockIdOrBuilder getIdsOrBuilder( + int index) { + if (idsBuilder_ == null) { + return ids_.get(index); } else { + return idsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public java.util.List + getIdsOrBuilderList() { + if (idsBuilder_ != null) { + return idsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(ids_); + } + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.ChainInventory.BlockId.Builder addIdsBuilder() { + return getIdsFieldBuilder().addBuilder( + org.tron.protos.Protocol.ChainInventory.BlockId.getDefaultInstance()); + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.ChainInventory.BlockId.Builder addIdsBuilder( + int index) { + return getIdsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.ChainInventory.BlockId.getDefaultInstance()); + } + /** + * repeated .protocol.ChainInventory.BlockId ids = 1; + */ + public java.util.List + getIdsBuilderList() { + return getIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.ChainInventory.BlockId, org.tron.protos.Protocol.ChainInventory.BlockId.Builder, org.tron.protos.Protocol.ChainInventory.BlockIdOrBuilder> + getIdsFieldBuilder() { + if (idsBuilder_ == null) { + idsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.ChainInventory.BlockId, org.tron.protos.Protocol.ChainInventory.BlockId.Builder, org.tron.protos.Protocol.ChainInventory.BlockIdOrBuilder>( + ids_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + ids_ = null; + } + return idsBuilder_; + } + + private long remainNum_ ; + /** + * int64 remain_num = 2; + */ + public long getRemainNum() { + return remainNum_; + } + /** + * int64 remain_num = 2; + */ + public Builder setRemainNum(long value) { + + remainNum_ = value; + onChanged(); + return this; + } + /** + * int64 remain_num = 2; + */ + public Builder clearRemainNum() { + + remainNum_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.ChainInventory) + } + + // @@protoc_insertion_point(class_scope:protocol.ChainInventory) + private static final org.tron.protos.Protocol.ChainInventory DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.ChainInventory(); + } + + public static org.tron.protos.Protocol.ChainInventory getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ChainInventory parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ChainInventory(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.ChainInventory getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface BlockInventoryOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockInventory) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + java.util.List + getIdsList(); + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + org.tron.protos.Protocol.BlockInventory.BlockId getIds(int index); + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + int getIdsCount(); + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + java.util.List + getIdsOrBuilderList(); + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + org.tron.protos.Protocol.BlockInventory.BlockIdOrBuilder getIdsOrBuilder( + int index); + + /** + * .protocol.BlockInventory.Type type = 2; + */ + int getTypeValue(); + /** + * .protocol.BlockInventory.Type type = 2; + */ + org.tron.protos.Protocol.BlockInventory.Type getType(); + } + /** + *
+   * Inventory
+   * 
+ * + * Protobuf type {@code protocol.BlockInventory} + */ + public static final class BlockInventory extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockInventory) + BlockInventoryOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockInventory.newBuilder() to construct. + private BlockInventory(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockInventory() { + ids_ = java.util.Collections.emptyList(); + type_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockInventory( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + ids_.add( + input.readMessage(org.tron.protos.Protocol.BlockInventory.BlockId.parser(), extensionRegistry)); + break; + } + case 16: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = java.util.Collections.unmodifiableList(ids_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockInventory.class, org.tron.protos.Protocol.BlockInventory.Builder.class); + } + + /** + * Protobuf enum {@code protocol.BlockInventory.Type} + */ + public enum Type + implements com.google.protobuf.ProtocolMessageEnum { + /** + * SYNC = 0; + */ + SYNC(0), + /** + * ADVTISE = 1; + */ + ADVTISE(1), + /** + * FETCH = 2; + */ + FETCH(2), + UNRECOGNIZED(-1), + ; + + /** + * SYNC = 0; + */ + public static final int SYNC_VALUE = 0; + /** + * ADVTISE = 1; + */ + public static final int ADVTISE_VALUE = 1; + /** + * FETCH = 2; + */ + public static final int FETCH_VALUE = 2; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Type valueOf(int value) { + return forNumber(value); + } + + public static Type forNumber(int value) { + switch (value) { + case 0: return SYNC; + case 1: return ADVTISE; + case 2: return FETCH; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + Type> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Type findValueByNumber(int number) { + return Type.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.BlockInventory.getDescriptor().getEnumTypes().get(0); + } + + private static final Type[] VALUES = values(); + + public static Type valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Type(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.BlockInventory.Type) + } + + public interface BlockIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.BlockInventory.BlockId) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes hash = 1; + */ + com.google.protobuf.ByteString getHash(); + + /** + * int64 number = 2; + */ + long getNumber(); + } + /** + * Protobuf type {@code protocol.BlockInventory.BlockId} + */ + public static final class BlockId extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.BlockInventory.BlockId) + BlockIdOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockId.newBuilder() to construct. + private BlockId(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockId() { + hash_ = com.google.protobuf.ByteString.EMPTY; + number_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockId( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + hash_ = input.readBytes(); + break; + } + case 16: { + + number_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_BlockId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_BlockId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockInventory.BlockId.class, org.tron.protos.Protocol.BlockInventory.BlockId.Builder.class); + } + + public static final int HASH_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString hash_; + /** + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + + public static final int NUMBER_FIELD_NUMBER = 2; + private long number_; + /** + * int64 number = 2; + */ + public long getNumber() { + return number_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!hash_.isEmpty()) { + output.writeBytes(1, hash_); + } + if (number_ != 0L) { + output.writeInt64(2, number_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, hash_); + } + if (number_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, number_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.BlockInventory.BlockId)) { + return super.equals(obj); + } + org.tron.protos.Protocol.BlockInventory.BlockId other = (org.tron.protos.Protocol.BlockInventory.BlockId) obj; + + boolean result = true; + result = result && getHash() + .equals(other.getHash()); + result = result && (getNumber() + == other.getNumber()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + HASH_FIELD_NUMBER; + hash = (53 * hash) + getHash().hashCode(); + hash = (37 * hash) + NUMBER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNumber()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockInventory.BlockId parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.BlockInventory.BlockId prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.BlockInventory.BlockId} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockInventory.BlockId) + org.tron.protos.Protocol.BlockInventory.BlockIdOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_BlockId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_BlockId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockInventory.BlockId.class, org.tron.protos.Protocol.BlockInventory.BlockId.Builder.class); + } + + // Construct using org.tron.protos.Protocol.BlockInventory.BlockId.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + hash_ = com.google.protobuf.ByteString.EMPTY; + + number_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_BlockId_descriptor; + } + + public org.tron.protos.Protocol.BlockInventory.BlockId getDefaultInstanceForType() { + return org.tron.protos.Protocol.BlockInventory.BlockId.getDefaultInstance(); + } + + public org.tron.protos.Protocol.BlockInventory.BlockId build() { + org.tron.protos.Protocol.BlockInventory.BlockId result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.BlockInventory.BlockId buildPartial() { + org.tron.protos.Protocol.BlockInventory.BlockId result = new org.tron.protos.Protocol.BlockInventory.BlockId(this); + result.hash_ = hash_; + result.number_ = number_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.BlockInventory.BlockId) { + return mergeFrom((org.tron.protos.Protocol.BlockInventory.BlockId)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.BlockInventory.BlockId other) { + if (other == org.tron.protos.Protocol.BlockInventory.BlockId.getDefaultInstance()) return this; + if (other.getHash() != com.google.protobuf.ByteString.EMPTY) { + setHash(other.getHash()); + } + if (other.getNumber() != 0L) { + setNumber(other.getNumber()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.BlockInventory.BlockId parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.BlockInventory.BlockId) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString hash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + * bytes hash = 1; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + onChanged(); + return this; + } + /** + * bytes hash = 1; + */ + public Builder clearHash() { + + hash_ = getDefaultInstance().getHash(); + onChanged(); + return this; + } + + private long number_ ; + /** + * int64 number = 2; + */ + public long getNumber() { + return number_; + } + /** + * int64 number = 2; + */ + public Builder setNumber(long value) { + + number_ = value; + onChanged(); + return this; + } + /** + * int64 number = 2; + */ + public Builder clearNumber() { + + number_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockInventory.BlockId) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockInventory.BlockId) + private static final org.tron.protos.Protocol.BlockInventory.BlockId DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.BlockInventory.BlockId(); + } + + public static org.tron.protos.Protocol.BlockInventory.BlockId getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockId parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockId(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.BlockInventory.BlockId getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int IDS_FIELD_NUMBER = 1; + private java.util.List ids_; + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public java.util.List getIdsList() { + return ids_; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public java.util.List + getIdsOrBuilderList() { + return ids_; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public int getIdsCount() { + return ids_.size(); + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.BlockInventory.BlockId getIds(int index) { + return ids_.get(index); + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.BlockInventory.BlockIdOrBuilder getIdsOrBuilder( + int index) { + return ids_.get(index); + } + + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + /** + * .protocol.BlockInventory.Type type = 2; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.BlockInventory.Type type = 2; + */ + public org.tron.protos.Protocol.BlockInventory.Type getType() { + org.tron.protos.Protocol.BlockInventory.Type result = org.tron.protos.Protocol.BlockInventory.Type.valueOf(type_); + return result == null ? org.tron.protos.Protocol.BlockInventory.Type.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < ids_.size(); i++) { + output.writeMessage(1, ids_.get(i)); + } + if (type_ != org.tron.protos.Protocol.BlockInventory.Type.SYNC.getNumber()) { + output.writeEnum(2, type_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < ids_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, ids_.get(i)); + } + if (type_ != org.tron.protos.Protocol.BlockInventory.Type.SYNC.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, type_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.BlockInventory)) { + return super.equals(obj); + } + org.tron.protos.Protocol.BlockInventory other = (org.tron.protos.Protocol.BlockInventory) obj; + + boolean result = true; + result = result && getIdsList() + .equals(other.getIdsList()); + result = result && type_ == other.type_; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getIdsCount() > 0) { + hash = (37 * hash) + IDS_FIELD_NUMBER; + hash = (53 * hash) + getIdsList().hashCode(); + } + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.BlockInventory parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockInventory parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.BlockInventory parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.BlockInventory prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Inventory
+     * 
+ * + * Protobuf type {@code protocol.BlockInventory} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.BlockInventory) + org.tron.protos.Protocol.BlockInventoryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.BlockInventory.class, org.tron.protos.Protocol.BlockInventory.Builder.class); + } + + // Construct using org.tron.protos.Protocol.BlockInventory.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getIdsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (idsBuilder_ == null) { + ids_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + idsBuilder_.clear(); + } + type_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_BlockInventory_descriptor; + } + + public org.tron.protos.Protocol.BlockInventory getDefaultInstanceForType() { + return org.tron.protos.Protocol.BlockInventory.getDefaultInstance(); + } + + public org.tron.protos.Protocol.BlockInventory build() { + org.tron.protos.Protocol.BlockInventory result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.BlockInventory buildPartial() { + org.tron.protos.Protocol.BlockInventory result = new org.tron.protos.Protocol.BlockInventory(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (idsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = java.util.Collections.unmodifiableList(ids_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.ids_ = ids_; + } else { + result.ids_ = idsBuilder_.build(); + } + result.type_ = type_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.BlockInventory) { + return mergeFrom((org.tron.protos.Protocol.BlockInventory)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.BlockInventory other) { + if (other == org.tron.protos.Protocol.BlockInventory.getDefaultInstance()) return this; + if (idsBuilder_ == null) { + if (!other.ids_.isEmpty()) { + if (ids_.isEmpty()) { + ids_ = other.ids_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIdsIsMutable(); + ids_.addAll(other.ids_); + } + onChanged(); + } + } else { + if (!other.ids_.isEmpty()) { + if (idsBuilder_.isEmpty()) { + idsBuilder_.dispose(); + idsBuilder_ = null; + ids_ = other.ids_; + bitField0_ = (bitField0_ & ~0x00000001); + idsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getIdsFieldBuilder() : null; + } else { + idsBuilder_.addAllMessages(other.ids_); + } + } + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.BlockInventory parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.BlockInventory) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List ids_ = + java.util.Collections.emptyList(); + private void ensureIdsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + ids_ = new java.util.ArrayList(ids_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.BlockInventory.BlockId, org.tron.protos.Protocol.BlockInventory.BlockId.Builder, org.tron.protos.Protocol.BlockInventory.BlockIdOrBuilder> idsBuilder_; + + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public java.util.List getIdsList() { + if (idsBuilder_ == null) { + return java.util.Collections.unmodifiableList(ids_); + } else { + return idsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public int getIdsCount() { + if (idsBuilder_ == null) { + return ids_.size(); + } else { + return idsBuilder_.getCount(); + } + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.BlockInventory.BlockId getIds(int index) { + if (idsBuilder_ == null) { + return ids_.get(index); + } else { + return idsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder setIds( + int index, org.tron.protos.Protocol.BlockInventory.BlockId value) { + if (idsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.set(index, value); + onChanged(); + } else { + idsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder setIds( + int index, org.tron.protos.Protocol.BlockInventory.BlockId.Builder builderForValue) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.set(index, builderForValue.build()); + onChanged(); + } else { + idsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder addIds(org.tron.protos.Protocol.BlockInventory.BlockId value) { + if (idsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.add(value); + onChanged(); + } else { + idsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder addIds( + int index, org.tron.protos.Protocol.BlockInventory.BlockId value) { + if (idsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.add(index, value); + onChanged(); + } else { + idsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder addIds( + org.tron.protos.Protocol.BlockInventory.BlockId.Builder builderForValue) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.add(builderForValue.build()); + onChanged(); + } else { + idsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder addIds( + int index, org.tron.protos.Protocol.BlockInventory.BlockId.Builder builderForValue) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.add(index, builderForValue.build()); + onChanged(); + } else { + idsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder addAllIds( + java.lang.Iterable values) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, ids_); + onChanged(); + } else { + idsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder clearIds() { + if (idsBuilder_ == null) { + ids_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + idsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public Builder removeIds(int index) { + if (idsBuilder_ == null) { + ensureIdsIsMutable(); + ids_.remove(index); + onChanged(); + } else { + idsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.BlockInventory.BlockId.Builder getIdsBuilder( + int index) { + return getIdsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.BlockInventory.BlockIdOrBuilder getIdsOrBuilder( + int index) { + if (idsBuilder_ == null) { + return ids_.get(index); } else { + return idsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public java.util.List + getIdsOrBuilderList() { + if (idsBuilder_ != null) { + return idsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(ids_); + } + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.BlockInventory.BlockId.Builder addIdsBuilder() { + return getIdsFieldBuilder().addBuilder( + org.tron.protos.Protocol.BlockInventory.BlockId.getDefaultInstance()); + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public org.tron.protos.Protocol.BlockInventory.BlockId.Builder addIdsBuilder( + int index) { + return getIdsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.BlockInventory.BlockId.getDefaultInstance()); + } + /** + * repeated .protocol.BlockInventory.BlockId ids = 1; + */ + public java.util.List + getIdsBuilderList() { + return getIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.BlockInventory.BlockId, org.tron.protos.Protocol.BlockInventory.BlockId.Builder, org.tron.protos.Protocol.BlockInventory.BlockIdOrBuilder> + getIdsFieldBuilder() { + if (idsBuilder_ == null) { + idsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.BlockInventory.BlockId, org.tron.protos.Protocol.BlockInventory.BlockId.Builder, org.tron.protos.Protocol.BlockInventory.BlockIdOrBuilder>( + ids_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + ids_ = null; + } + return idsBuilder_; + } + + private int type_ = 0; + /** + * .protocol.BlockInventory.Type type = 2; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.BlockInventory.Type type = 2; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.BlockInventory.Type type = 2; + */ + public org.tron.protos.Protocol.BlockInventory.Type getType() { + org.tron.protos.Protocol.BlockInventory.Type result = org.tron.protos.Protocol.BlockInventory.Type.valueOf(type_); + return result == null ? org.tron.protos.Protocol.BlockInventory.Type.UNRECOGNIZED : result; + } + /** + * .protocol.BlockInventory.Type type = 2; + */ + public Builder setType(org.tron.protos.Protocol.BlockInventory.Type value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.BlockInventory.Type type = 2; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.BlockInventory) + } + + // @@protoc_insertion_point(class_scope:protocol.BlockInventory) + private static final org.tron.protos.Protocol.BlockInventory DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.BlockInventory(); + } + + public static org.tron.protos.Protocol.BlockInventory getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockInventory parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockInventory(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.BlockInventory getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface InventoryOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Inventory) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Inventory.InventoryType type = 1; + */ + int getTypeValue(); + /** + * .protocol.Inventory.InventoryType type = 1; + */ + org.tron.protos.Protocol.Inventory.InventoryType getType(); + + /** + * repeated bytes ids = 2; + */ + java.util.List getIdsList(); + /** + * repeated bytes ids = 2; + */ + int getIdsCount(); + /** + * repeated bytes ids = 2; + */ + com.google.protobuf.ByteString getIds(int index); + } + /** + * Protobuf type {@code protocol.Inventory} + */ + public static final class Inventory extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Inventory) + InventoryOrBuilder { + private static final long serialVersionUID = 0L; + // Use Inventory.newBuilder() to construct. + private Inventory(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Inventory() { + type_ = 0; + ids_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Inventory( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + ids_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + ids_.add(input.readBytes()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + ids_ = java.util.Collections.unmodifiableList(ids_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Inventory_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Inventory_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Inventory.class, org.tron.protos.Protocol.Inventory.Builder.class); + } + + /** + * Protobuf enum {@code protocol.Inventory.InventoryType} + */ + public enum InventoryType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * TRX = 0; + */ + TRX(0), + /** + * BLOCK = 1; + */ + BLOCK(1), + UNRECOGNIZED(-1), + ; + + /** + * TRX = 0; + */ + public static final int TRX_VALUE = 0; + /** + * BLOCK = 1; + */ + public static final int BLOCK_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static InventoryType valueOf(int value) { + return forNumber(value); + } + + public static InventoryType forNumber(int value) { + switch (value) { + case 0: return TRX; + case 1: return BLOCK; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + InventoryType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public InventoryType findValueByNumber(int number) { + return InventoryType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.Inventory.getDescriptor().getEnumTypes().get(0); + } + + private static final InventoryType[] VALUES = values(); + + public static InventoryType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private InventoryType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Inventory.InventoryType) + } + + private int bitField0_; + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + * .protocol.Inventory.InventoryType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Inventory.InventoryType type = 1; + */ + public org.tron.protos.Protocol.Inventory.InventoryType getType() { + org.tron.protos.Protocol.Inventory.InventoryType result = org.tron.protos.Protocol.Inventory.InventoryType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Inventory.InventoryType.UNRECOGNIZED : result; + } + + public static final int IDS_FIELD_NUMBER = 2; + private java.util.List ids_; + /** + * repeated bytes ids = 2; + */ + public java.util.List + getIdsList() { + return ids_; + } + /** + * repeated bytes ids = 2; + */ + public int getIdsCount() { + return ids_.size(); + } + /** + * repeated bytes ids = 2; + */ + public com.google.protobuf.ByteString getIds(int index) { + return ids_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != org.tron.protos.Protocol.Inventory.InventoryType.TRX.getNumber()) { + output.writeEnum(1, type_); + } + for (int i = 0; i < ids_.size(); i++) { + output.writeBytes(2, ids_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != org.tron.protos.Protocol.Inventory.InventoryType.TRX.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, type_); + } + { + int dataSize = 0; + for (int i = 0; i < ids_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(ids_.get(i)); + } + size += dataSize; + size += 1 * getIdsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Inventory)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Inventory other = (org.tron.protos.Protocol.Inventory) obj; + + boolean result = true; + result = result && type_ == other.type_; + result = result && getIdsList() + .equals(other.getIdsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + if (getIdsCount() > 0) { + hash = (37 * hash) + IDS_FIELD_NUMBER; + hash = (53 * hash) + getIdsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Inventory parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Inventory parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Inventory parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Inventory parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Inventory parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Inventory parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Inventory parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Inventory parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Inventory parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Inventory parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Inventory parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Inventory parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Inventory prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Inventory} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Inventory) + org.tron.protos.Protocol.InventoryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Inventory_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Inventory_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Inventory.class, org.tron.protos.Protocol.Inventory.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Inventory.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + type_ = 0; + + ids_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Inventory_descriptor; + } + + public org.tron.protos.Protocol.Inventory getDefaultInstanceForType() { + return org.tron.protos.Protocol.Inventory.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Inventory build() { + org.tron.protos.Protocol.Inventory result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Inventory buildPartial() { + org.tron.protos.Protocol.Inventory result = new org.tron.protos.Protocol.Inventory(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.type_ = type_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + ids_ = java.util.Collections.unmodifiableList(ids_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.ids_ = ids_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Inventory) { + return mergeFrom((org.tron.protos.Protocol.Inventory)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Inventory other) { + if (other == org.tron.protos.Protocol.Inventory.getDefaultInstance()) return this; + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (!other.ids_.isEmpty()) { + if (ids_.isEmpty()) { + ids_ = other.ids_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureIdsIsMutable(); + ids_.addAll(other.ids_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Inventory parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Inventory) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int type_ = 0; + /** + * .protocol.Inventory.InventoryType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Inventory.InventoryType type = 1; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.Inventory.InventoryType type = 1; + */ + public org.tron.protos.Protocol.Inventory.InventoryType getType() { + org.tron.protos.Protocol.Inventory.InventoryType result = org.tron.protos.Protocol.Inventory.InventoryType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Inventory.InventoryType.UNRECOGNIZED : result; + } + /** + * .protocol.Inventory.InventoryType type = 1; + */ + public Builder setType(org.tron.protos.Protocol.Inventory.InventoryType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Inventory.InventoryType type = 1; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private java.util.List ids_ = java.util.Collections.emptyList(); + private void ensureIdsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + ids_ = new java.util.ArrayList(ids_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes ids = 2; + */ + public java.util.List + getIdsList() { + return java.util.Collections.unmodifiableList(ids_); + } + /** + * repeated bytes ids = 2; + */ + public int getIdsCount() { + return ids_.size(); + } + /** + * repeated bytes ids = 2; + */ + public com.google.protobuf.ByteString getIds(int index) { + return ids_.get(index); + } + /** + * repeated bytes ids = 2; + */ + public Builder setIds( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes ids = 2; + */ + public Builder addIds(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes ids = 2; + */ + public Builder addAllIds( + java.lang.Iterable values) { + ensureIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, ids_); + onChanged(); + return this; + } + /** + * repeated bytes ids = 2; + */ + public Builder clearIds() { + ids_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Inventory) + } + + // @@protoc_insertion_point(class_scope:protocol.Inventory) + private static final org.tron.protos.Protocol.Inventory DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Inventory(); + } + + public static org.tron.protos.Protocol.Inventory getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Inventory parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Inventory(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Inventory getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ItemsOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.Items) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Items.ItemType type = 1; + */ + int getTypeValue(); + /** + * .protocol.Items.ItemType type = 1; + */ + org.tron.protos.Protocol.Items.ItemType getType(); + + /** + * repeated .protocol.Block blocks = 2; + */ + java.util.List + getBlocksList(); + /** + * repeated .protocol.Block blocks = 2; + */ + org.tron.protos.Protocol.Block getBlocks(int index); + /** + * repeated .protocol.Block blocks = 2; + */ + int getBlocksCount(); + /** + * repeated .protocol.Block blocks = 2; + */ + java.util.List + getBlocksOrBuilderList(); + /** + * repeated .protocol.Block blocks = 2; + */ + org.tron.protos.Protocol.BlockOrBuilder getBlocksOrBuilder( + int index); + + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + java.util.List + getBlockHeadersList(); + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + org.tron.protos.Protocol.BlockHeader getBlockHeaders(int index); + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + int getBlockHeadersCount(); + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + java.util.List + getBlockHeadersOrBuilderList(); + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeadersOrBuilder( + int index); + + /** + * repeated .protocol.Transaction transactions = 4; + */ + java.util.List + getTransactionsList(); + /** + * repeated .protocol.Transaction transactions = 4; + */ + org.tron.protos.Protocol.Transaction getTransactions(int index); + /** + * repeated .protocol.Transaction transactions = 4; + */ + int getTransactionsCount(); + /** + * repeated .protocol.Transaction transactions = 4; + */ + java.util.List + getTransactionsOrBuilderList(); + /** + * repeated .protocol.Transaction transactions = 4; + */ + org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.Items} + */ + public static final class Items extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.Items) + ItemsOrBuilder { + private static final long serialVersionUID = 0L; + // Use Items.newBuilder() to construct. + private Items(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Items() { + type_ = 0; + blocks_ = java.util.Collections.emptyList(); + blockHeaders_ = java.util.Collections.emptyList(); + transactions_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Items( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + blocks_.add( + input.readMessage(org.tron.protos.Protocol.Block.parser(), extensionRegistry)); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + blockHeaders_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + blockHeaders_.add( + input.readMessage(org.tron.protos.Protocol.BlockHeader.parser(), extensionRegistry)); + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + transactions_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + transactions_.add( + input.readMessage(org.tron.protos.Protocol.Transaction.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = java.util.Collections.unmodifiableList(blocks_); + } + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + blockHeaders_ = java.util.Collections.unmodifiableList(blockHeaders_); + } + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Items_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Items_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Items.class, org.tron.protos.Protocol.Items.Builder.class); + } + + /** + * Protobuf enum {@code protocol.Items.ItemType} + */ + public enum ItemType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * ERR = 0; + */ + ERR(0), + /** + * TRX = 1; + */ + TRX(1), + /** + * BLOCK = 2; + */ + BLOCK(2), + /** + * BLOCKHEADER = 3; + */ + BLOCKHEADER(3), + UNRECOGNIZED(-1), + ; + + /** + * ERR = 0; + */ + public static final int ERR_VALUE = 0; + /** + * TRX = 1; + */ + public static final int TRX_VALUE = 1; + /** + * BLOCK = 2; + */ + public static final int BLOCK_VALUE = 2; + /** + * BLOCKHEADER = 3; + */ + public static final int BLOCKHEADER_VALUE = 3; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ItemType valueOf(int value) { + return forNumber(value); + } + + public static ItemType forNumber(int value) { + switch (value) { + case 0: return ERR; + case 1: return TRX; + case 2: return BLOCK; + case 3: return BLOCKHEADER; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + ItemType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ItemType findValueByNumber(int number) { + return ItemType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.Items.getDescriptor().getEnumTypes().get(0); + } + + private static final ItemType[] VALUES = values(); + + public static ItemType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ItemType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.Items.ItemType) + } + + private int bitField0_; + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + * .protocol.Items.ItemType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Items.ItemType type = 1; + */ + public org.tron.protos.Protocol.Items.ItemType getType() { + org.tron.protos.Protocol.Items.ItemType result = org.tron.protos.Protocol.Items.ItemType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Items.ItemType.UNRECOGNIZED : result; + } + + public static final int BLOCKS_FIELD_NUMBER = 2; + private java.util.List blocks_; + /** + * repeated .protocol.Block blocks = 2; + */ + public java.util.List getBlocksList() { + return blocks_; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public java.util.List + getBlocksOrBuilderList() { + return blocks_; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public int getBlocksCount() { + return blocks_.size(); + } + /** + * repeated .protocol.Block blocks = 2; + */ + public org.tron.protos.Protocol.Block getBlocks(int index) { + return blocks_.get(index); + } + /** + * repeated .protocol.Block blocks = 2; + */ + public org.tron.protos.Protocol.BlockOrBuilder getBlocksOrBuilder( + int index) { + return blocks_.get(index); + } + + public static final int BLOCK_HEADERS_FIELD_NUMBER = 3; + private java.util.List blockHeaders_; + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public java.util.List getBlockHeadersList() { + return blockHeaders_; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public java.util.List + getBlockHeadersOrBuilderList() { + return blockHeaders_; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public int getBlockHeadersCount() { + return blockHeaders_.size(); + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public org.tron.protos.Protocol.BlockHeader getBlockHeaders(int index) { + return blockHeaders_.get(index); + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeadersOrBuilder( + int index) { + return blockHeaders_.get(index); + } + + public static final int TRANSACTIONS_FIELD_NUMBER = 4; + private java.util.List transactions_; + /** + * repeated .protocol.Transaction transactions = 4; + */ + public java.util.List getTransactionsList() { + return transactions_; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public java.util.List + getTransactionsOrBuilderList() { + return transactions_; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public int getTransactionsCount() { + return transactions_.size(); + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public org.tron.protos.Protocol.Transaction getTransactions(int index) { + return transactions_.get(index); + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index) { + return transactions_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != org.tron.protos.Protocol.Items.ItemType.ERR.getNumber()) { + output.writeEnum(1, type_); + } + for (int i = 0; i < blocks_.size(); i++) { + output.writeMessage(2, blocks_.get(i)); + } + for (int i = 0; i < blockHeaders_.size(); i++) { + output.writeMessage(3, blockHeaders_.get(i)); + } + for (int i = 0; i < transactions_.size(); i++) { + output.writeMessage(4, transactions_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != org.tron.protos.Protocol.Items.ItemType.ERR.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, type_); + } + for (int i = 0; i < blocks_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, blocks_.get(i)); + } + for (int i = 0; i < blockHeaders_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, blockHeaders_.get(i)); + } + for (int i = 0; i < transactions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, transactions_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.Items)) { + return super.equals(obj); + } + org.tron.protos.Protocol.Items other = (org.tron.protos.Protocol.Items) obj; + + boolean result = true; + result = result && type_ == other.type_; + result = result && getBlocksList() + .equals(other.getBlocksList()); + result = result && getBlockHeadersList() + .equals(other.getBlockHeadersList()); + result = result && getTransactionsList() + .equals(other.getTransactionsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + if (getBlocksCount() > 0) { + hash = (37 * hash) + BLOCKS_FIELD_NUMBER; + hash = (53 * hash) + getBlocksList().hashCode(); + } + if (getBlockHeadersCount() > 0) { + hash = (37 * hash) + BLOCK_HEADERS_FIELD_NUMBER; + hash = (53 * hash) + getBlockHeadersList().hashCode(); + } + if (getTransactionsCount() > 0) { + hash = (37 * hash) + TRANSACTIONS_FIELD_NUMBER; + hash = (53 * hash) + getTransactionsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.Items parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Items parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Items parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Items parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Items parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.Items parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.Items parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Items parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Items parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Items parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.Items parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.Items parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.Items prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.Items} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.Items) + org.tron.protos.Protocol.ItemsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_Items_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_Items_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.Items.class, org.tron.protos.Protocol.Items.Builder.class); + } + + // Construct using org.tron.protos.Protocol.Items.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getBlocksFieldBuilder(); + getBlockHeadersFieldBuilder(); + getTransactionsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + type_ = 0; + + if (blocksBuilder_ == null) { + blocks_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + blocksBuilder_.clear(); + } + if (blockHeadersBuilder_ == null) { + blockHeaders_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + blockHeadersBuilder_.clear(); + } + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + transactionsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_Items_descriptor; + } + + public org.tron.protos.Protocol.Items getDefaultInstanceForType() { + return org.tron.protos.Protocol.Items.getDefaultInstance(); + } + + public org.tron.protos.Protocol.Items build() { + org.tron.protos.Protocol.Items result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.Items buildPartial() { + org.tron.protos.Protocol.Items result = new org.tron.protos.Protocol.Items(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.type_ = type_; + if (blocksBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = java.util.Collections.unmodifiableList(blocks_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.blocks_ = blocks_; + } else { + result.blocks_ = blocksBuilder_.build(); + } + if (blockHeadersBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + blockHeaders_ = java.util.Collections.unmodifiableList(blockHeaders_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.blockHeaders_ = blockHeaders_; + } else { + result.blockHeaders_ = blockHeadersBuilder_.build(); + } + if (transactionsBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + transactions_ = java.util.Collections.unmodifiableList(transactions_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.transactions_ = transactions_; + } else { + result.transactions_ = transactionsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.Items) { + return mergeFrom((org.tron.protos.Protocol.Items)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.Items other) { + if (other == org.tron.protos.Protocol.Items.getDefaultInstance()) return this; + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (blocksBuilder_ == null) { + if (!other.blocks_.isEmpty()) { + if (blocks_.isEmpty()) { + blocks_ = other.blocks_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureBlocksIsMutable(); + blocks_.addAll(other.blocks_); + } + onChanged(); + } + } else { + if (!other.blocks_.isEmpty()) { + if (blocksBuilder_.isEmpty()) { + blocksBuilder_.dispose(); + blocksBuilder_ = null; + blocks_ = other.blocks_; + bitField0_ = (bitField0_ & ~0x00000002); + blocksBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getBlocksFieldBuilder() : null; + } else { + blocksBuilder_.addAllMessages(other.blocks_); + } + } + } + if (blockHeadersBuilder_ == null) { + if (!other.blockHeaders_.isEmpty()) { + if (blockHeaders_.isEmpty()) { + blockHeaders_ = other.blockHeaders_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureBlockHeadersIsMutable(); + blockHeaders_.addAll(other.blockHeaders_); + } + onChanged(); + } + } else { + if (!other.blockHeaders_.isEmpty()) { + if (blockHeadersBuilder_.isEmpty()) { + blockHeadersBuilder_.dispose(); + blockHeadersBuilder_ = null; + blockHeaders_ = other.blockHeaders_; + bitField0_ = (bitField0_ & ~0x00000004); + blockHeadersBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getBlockHeadersFieldBuilder() : null; + } else { + blockHeadersBuilder_.addAllMessages(other.blockHeaders_); + } + } + } + if (transactionsBuilder_ == null) { + if (!other.transactions_.isEmpty()) { + if (transactions_.isEmpty()) { + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureTransactionsIsMutable(); + transactions_.addAll(other.transactions_); + } + onChanged(); + } + } else { + if (!other.transactions_.isEmpty()) { + if (transactionsBuilder_.isEmpty()) { + transactionsBuilder_.dispose(); + transactionsBuilder_ = null; + transactions_ = other.transactions_; + bitField0_ = (bitField0_ & ~0x00000008); + transactionsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTransactionsFieldBuilder() : null; + } else { + transactionsBuilder_.addAllMessages(other.transactions_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.Items parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.Items) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int type_ = 0; + /** + * .protocol.Items.ItemType type = 1; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.Items.ItemType type = 1; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.Items.ItemType type = 1; + */ + public org.tron.protos.Protocol.Items.ItemType getType() { + org.tron.protos.Protocol.Items.ItemType result = org.tron.protos.Protocol.Items.ItemType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.Items.ItemType.UNRECOGNIZED : result; + } + /** + * .protocol.Items.ItemType type = 1; + */ + public Builder setType(org.tron.protos.Protocol.Items.ItemType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.Items.ItemType type = 1; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private java.util.List blocks_ = + java.util.Collections.emptyList(); + private void ensureBlocksIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = new java.util.ArrayList(blocks_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Block, org.tron.protos.Protocol.Block.Builder, org.tron.protos.Protocol.BlockOrBuilder> blocksBuilder_; + + /** + * repeated .protocol.Block blocks = 2; + */ + public java.util.List getBlocksList() { + if (blocksBuilder_ == null) { + return java.util.Collections.unmodifiableList(blocks_); + } else { + return blocksBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Block blocks = 2; + */ + public int getBlocksCount() { + if (blocksBuilder_ == null) { + return blocks_.size(); + } else { + return blocksBuilder_.getCount(); + } + } + /** + * repeated .protocol.Block blocks = 2; + */ + public org.tron.protos.Protocol.Block getBlocks(int index) { + if (blocksBuilder_ == null) { + return blocks_.get(index); + } else { + return blocksBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder setBlocks( + int index, org.tron.protos.Protocol.Block value) { + if (blocksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlocksIsMutable(); + blocks_.set(index, value); + onChanged(); + } else { + blocksBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder setBlocks( + int index, org.tron.protos.Protocol.Block.Builder builderForValue) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.set(index, builderForValue.build()); + onChanged(); + } else { + blocksBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder addBlocks(org.tron.protos.Protocol.Block value) { + if (blocksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlocksIsMutable(); + blocks_.add(value); + onChanged(); + } else { + blocksBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder addBlocks( + int index, org.tron.protos.Protocol.Block value) { + if (blocksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlocksIsMutable(); + blocks_.add(index, value); + onChanged(); + } else { + blocksBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder addBlocks( + org.tron.protos.Protocol.Block.Builder builderForValue) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.add(builderForValue.build()); + onChanged(); + } else { + blocksBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder addBlocks( + int index, org.tron.protos.Protocol.Block.Builder builderForValue) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.add(index, builderForValue.build()); + onChanged(); + } else { + blocksBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder addAllBlocks( + java.lang.Iterable values) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, blocks_); + onChanged(); + } else { + blocksBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder clearBlocks() { + if (blocksBuilder_ == null) { + blocks_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + blocksBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public Builder removeBlocks(int index) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.remove(index); + onChanged(); + } else { + blocksBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Block blocks = 2; + */ + public org.tron.protos.Protocol.Block.Builder getBlocksBuilder( + int index) { + return getBlocksFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Block blocks = 2; + */ + public org.tron.protos.Protocol.BlockOrBuilder getBlocksOrBuilder( + int index) { + if (blocksBuilder_ == null) { + return blocks_.get(index); } else { + return blocksBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Block blocks = 2; + */ + public java.util.List + getBlocksOrBuilderList() { + if (blocksBuilder_ != null) { + return blocksBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(blocks_); + } + } + /** + * repeated .protocol.Block blocks = 2; + */ + public org.tron.protos.Protocol.Block.Builder addBlocksBuilder() { + return getBlocksFieldBuilder().addBuilder( + org.tron.protos.Protocol.Block.getDefaultInstance()); + } + /** + * repeated .protocol.Block blocks = 2; + */ + public org.tron.protos.Protocol.Block.Builder addBlocksBuilder( + int index) { + return getBlocksFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Block.getDefaultInstance()); + } + /** + * repeated .protocol.Block blocks = 2; + */ + public java.util.List + getBlocksBuilderList() { + return getBlocksFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Block, org.tron.protos.Protocol.Block.Builder, org.tron.protos.Protocol.BlockOrBuilder> + getBlocksFieldBuilder() { + if (blocksBuilder_ == null) { + blocksBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Block, org.tron.protos.Protocol.Block.Builder, org.tron.protos.Protocol.BlockOrBuilder>( + blocks_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + blocks_ = null; + } + return blocksBuilder_; + } + + private java.util.List blockHeaders_ = + java.util.Collections.emptyList(); + private void ensureBlockHeadersIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + blockHeaders_ = new java.util.ArrayList(blockHeaders_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder> blockHeadersBuilder_; + + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public java.util.List getBlockHeadersList() { + if (blockHeadersBuilder_ == null) { + return java.util.Collections.unmodifiableList(blockHeaders_); + } else { + return blockHeadersBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public int getBlockHeadersCount() { + if (blockHeadersBuilder_ == null) { + return blockHeaders_.size(); + } else { + return blockHeadersBuilder_.getCount(); + } + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public org.tron.protos.Protocol.BlockHeader getBlockHeaders(int index) { + if (blockHeadersBuilder_ == null) { + return blockHeaders_.get(index); + } else { + return blockHeadersBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder setBlockHeaders( + int index, org.tron.protos.Protocol.BlockHeader value) { + if (blockHeadersBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockHeadersIsMutable(); + blockHeaders_.set(index, value); + onChanged(); + } else { + blockHeadersBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder setBlockHeaders( + int index, org.tron.protos.Protocol.BlockHeader.Builder builderForValue) { + if (blockHeadersBuilder_ == null) { + ensureBlockHeadersIsMutable(); + blockHeaders_.set(index, builderForValue.build()); + onChanged(); + } else { + blockHeadersBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder addBlockHeaders(org.tron.protos.Protocol.BlockHeader value) { + if (blockHeadersBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockHeadersIsMutable(); + blockHeaders_.add(value); + onChanged(); + } else { + blockHeadersBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder addBlockHeaders( + int index, org.tron.protos.Protocol.BlockHeader value) { + if (blockHeadersBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlockHeadersIsMutable(); + blockHeaders_.add(index, value); + onChanged(); + } else { + blockHeadersBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder addBlockHeaders( + org.tron.protos.Protocol.BlockHeader.Builder builderForValue) { + if (blockHeadersBuilder_ == null) { + ensureBlockHeadersIsMutable(); + blockHeaders_.add(builderForValue.build()); + onChanged(); + } else { + blockHeadersBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder addBlockHeaders( + int index, org.tron.protos.Protocol.BlockHeader.Builder builderForValue) { + if (blockHeadersBuilder_ == null) { + ensureBlockHeadersIsMutable(); + blockHeaders_.add(index, builderForValue.build()); + onChanged(); + } else { + blockHeadersBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder addAllBlockHeaders( + java.lang.Iterable values) { + if (blockHeadersBuilder_ == null) { + ensureBlockHeadersIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, blockHeaders_); + onChanged(); + } else { + blockHeadersBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder clearBlockHeaders() { + if (blockHeadersBuilder_ == null) { + blockHeaders_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + blockHeadersBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public Builder removeBlockHeaders(int index) { + if (blockHeadersBuilder_ == null) { + ensureBlockHeadersIsMutable(); + blockHeaders_.remove(index); + onChanged(); + } else { + blockHeadersBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public org.tron.protos.Protocol.BlockHeader.Builder getBlockHeadersBuilder( + int index) { + return getBlockHeadersFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public org.tron.protos.Protocol.BlockHeaderOrBuilder getBlockHeadersOrBuilder( + int index) { + if (blockHeadersBuilder_ == null) { + return blockHeaders_.get(index); } else { + return blockHeadersBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public java.util.List + getBlockHeadersOrBuilderList() { + if (blockHeadersBuilder_ != null) { + return blockHeadersBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(blockHeaders_); + } + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public org.tron.protos.Protocol.BlockHeader.Builder addBlockHeadersBuilder() { + return getBlockHeadersFieldBuilder().addBuilder( + org.tron.protos.Protocol.BlockHeader.getDefaultInstance()); + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public org.tron.protos.Protocol.BlockHeader.Builder addBlockHeadersBuilder( + int index) { + return getBlockHeadersFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.BlockHeader.getDefaultInstance()); + } + /** + * repeated .protocol.BlockHeader block_headers = 3; + */ + public java.util.List + getBlockHeadersBuilderList() { + return getBlockHeadersFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder> + getBlockHeadersFieldBuilder() { + if (blockHeadersBuilder_ == null) { + blockHeadersBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.BlockHeader, org.tron.protos.Protocol.BlockHeader.Builder, org.tron.protos.Protocol.BlockHeaderOrBuilder>( + blockHeaders_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + blockHeaders_ = null; + } + return blockHeadersBuilder_; + } + + private java.util.List transactions_ = + java.util.Collections.emptyList(); + private void ensureTransactionsIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + transactions_ = new java.util.ArrayList(transactions_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> transactionsBuilder_; + + /** + * repeated .protocol.Transaction transactions = 4; + */ + public java.util.List getTransactionsList() { + if (transactionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(transactions_); + } else { + return transactionsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public int getTransactionsCount() { + if (transactionsBuilder_ == null) { + return transactions_.size(); + } else { + return transactionsBuilder_.getCount(); + } + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public org.tron.protos.Protocol.Transaction getTransactions(int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); + } else { + return transactionsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder setTransactions( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.set(index, value); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder setTransactions( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.set(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder addTransactions(org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(value); + onChanged(); + } else { + transactionsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder addTransactions( + int index, org.tron.protos.Protocol.Transaction value) { + if (transactionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransactionsIsMutable(); + transactions_.add(index, value); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder addTransactions( + org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder addTransactions( + int index, org.tron.protos.Protocol.Transaction.Builder builderForValue) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.add(index, builderForValue.build()); + onChanged(); + } else { + transactionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder addAllTransactions( + java.lang.Iterable values) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, transactions_); + onChanged(); + } else { + transactionsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder clearTransactions() { + if (transactionsBuilder_ == null) { + transactions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + transactionsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public Builder removeTransactions(int index) { + if (transactionsBuilder_ == null) { + ensureTransactionsIsMutable(); + transactions_.remove(index); + onChanged(); + } else { + transactionsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public org.tron.protos.Protocol.Transaction.Builder getTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public org.tron.protos.Protocol.TransactionOrBuilder getTransactionsOrBuilder( + int index) { + if (transactionsBuilder_ == null) { + return transactions_.get(index); } else { + return transactionsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public java.util.List + getTransactionsOrBuilderList() { + if (transactionsBuilder_ != null) { + return transactionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transactions_); + } + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionsBuilder() { + return getTransactionsFieldBuilder().addBuilder( + org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public org.tron.protos.Protocol.Transaction.Builder addTransactionsBuilder( + int index) { + return getTransactionsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.Transaction.getDefaultInstance()); + } + /** + * repeated .protocol.Transaction transactions = 4; + */ + public java.util.List + getTransactionsBuilderList() { + return getTransactionsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder> + getTransactionsFieldBuilder() { + if (transactionsBuilder_ == null) { + transactionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.Transaction, org.tron.protos.Protocol.Transaction.Builder, org.tron.protos.Protocol.TransactionOrBuilder>( + transactions_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + transactions_ = null; + } + return transactionsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.Items) + } + + // @@protoc_insertion_point(class_scope:protocol.Items) + private static final org.tron.protos.Protocol.Items DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.Items(); + } + + public static org.tron.protos.Protocol.Items getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Items parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Items(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.Items getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DynamicPropertiesOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.DynamicProperties) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 last_solidity_block_num = 1; + */ + long getLastSolidityBlockNum(); + } + /** + *
+   * DynamicProperties
+   * 
+ * + * Protobuf type {@code protocol.DynamicProperties} + */ + public static final class DynamicProperties extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.DynamicProperties) + DynamicPropertiesOrBuilder { + private static final long serialVersionUID = 0L; + // Use DynamicProperties.newBuilder() to construct. + private DynamicProperties(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DynamicProperties() { + lastSolidityBlockNum_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DynamicProperties( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + lastSolidityBlockNum_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DynamicProperties_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DynamicProperties_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DynamicProperties.class, org.tron.protos.Protocol.DynamicProperties.Builder.class); + } + + public static final int LAST_SOLIDITY_BLOCK_NUM_FIELD_NUMBER = 1; + private long lastSolidityBlockNum_; + /** + * int64 last_solidity_block_num = 1; + */ + public long getLastSolidityBlockNum() { + return lastSolidityBlockNum_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (lastSolidityBlockNum_ != 0L) { + output.writeInt64(1, lastSolidityBlockNum_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (lastSolidityBlockNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, lastSolidityBlockNum_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.DynamicProperties)) { + return super.equals(obj); + } + org.tron.protos.Protocol.DynamicProperties other = (org.tron.protos.Protocol.DynamicProperties) obj; + + boolean result = true; + result = result && (getLastSolidityBlockNum() + == other.getLastSolidityBlockNum()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LAST_SOLIDITY_BLOCK_NUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLastSolidityBlockNum()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DynamicProperties parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DynamicProperties parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DynamicProperties parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.DynamicProperties prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * DynamicProperties
+     * 
+ * + * Protobuf type {@code protocol.DynamicProperties} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.DynamicProperties) + org.tron.protos.Protocol.DynamicPropertiesOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DynamicProperties_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DynamicProperties_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DynamicProperties.class, org.tron.protos.Protocol.DynamicProperties.Builder.class); + } + + // Construct using org.tron.protos.Protocol.DynamicProperties.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + lastSolidityBlockNum_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_DynamicProperties_descriptor; + } + + public org.tron.protos.Protocol.DynamicProperties getDefaultInstanceForType() { + return org.tron.protos.Protocol.DynamicProperties.getDefaultInstance(); + } + + public org.tron.protos.Protocol.DynamicProperties build() { + org.tron.protos.Protocol.DynamicProperties result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.DynamicProperties buildPartial() { + org.tron.protos.Protocol.DynamicProperties result = new org.tron.protos.Protocol.DynamicProperties(this); + result.lastSolidityBlockNum_ = lastSolidityBlockNum_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.DynamicProperties) { + return mergeFrom((org.tron.protos.Protocol.DynamicProperties)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.DynamicProperties other) { + if (other == org.tron.protos.Protocol.DynamicProperties.getDefaultInstance()) return this; + if (other.getLastSolidityBlockNum() != 0L) { + setLastSolidityBlockNum(other.getLastSolidityBlockNum()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.DynamicProperties parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.DynamicProperties) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long lastSolidityBlockNum_ ; + /** + * int64 last_solidity_block_num = 1; + */ + public long getLastSolidityBlockNum() { + return lastSolidityBlockNum_; + } + /** + * int64 last_solidity_block_num = 1; + */ + public Builder setLastSolidityBlockNum(long value) { + + lastSolidityBlockNum_ = value; + onChanged(); + return this; + } + /** + * int64 last_solidity_block_num = 1; + */ + public Builder clearLastSolidityBlockNum() { + + lastSolidityBlockNum_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.DynamicProperties) + } + + // @@protoc_insertion_point(class_scope:protocol.DynamicProperties) + private static final org.tron.protos.Protocol.DynamicProperties DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.DynamicProperties(); + } + + public static org.tron.protos.Protocol.DynamicProperties getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DynamicProperties parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DynamicProperties(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.DynamicProperties getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DisconnectMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.DisconnectMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.ReasonCode reason = 1; + */ + int getReasonValue(); + /** + * .protocol.ReasonCode reason = 1; + */ + org.tron.protos.Protocol.ReasonCode getReason(); + } + /** + * Protobuf type {@code protocol.DisconnectMessage} + */ + public static final class DisconnectMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.DisconnectMessage) + DisconnectMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use DisconnectMessage.newBuilder() to construct. + private DisconnectMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DisconnectMessage() { + reason_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DisconnectMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + + reason_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DisconnectMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DisconnectMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DisconnectMessage.class, org.tron.protos.Protocol.DisconnectMessage.Builder.class); + } + + public static final int REASON_FIELD_NUMBER = 1; + private int reason_; + /** + * .protocol.ReasonCode reason = 1; + */ + public int getReasonValue() { + return reason_; + } + /** + * .protocol.ReasonCode reason = 1; + */ + public org.tron.protos.Protocol.ReasonCode getReason() { + org.tron.protos.Protocol.ReasonCode result = org.tron.protos.Protocol.ReasonCode.valueOf(reason_); + return result == null ? org.tron.protos.Protocol.ReasonCode.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (reason_ != org.tron.protos.Protocol.ReasonCode.REQUESTED.getNumber()) { + output.writeEnum(1, reason_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (reason_ != org.tron.protos.Protocol.ReasonCode.REQUESTED.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, reason_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.DisconnectMessage)) { + return super.equals(obj); + } + org.tron.protos.Protocol.DisconnectMessage other = (org.tron.protos.Protocol.DisconnectMessage) obj; + + boolean result = true; + result = result && reason_ == other.reason_; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REASON_FIELD_NUMBER; + hash = (53 * hash) + reason_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DisconnectMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DisconnectMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DisconnectMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.DisconnectMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.DisconnectMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.DisconnectMessage) + org.tron.protos.Protocol.DisconnectMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DisconnectMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DisconnectMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DisconnectMessage.class, org.tron.protos.Protocol.DisconnectMessage.Builder.class); + } + + // Construct using org.tron.protos.Protocol.DisconnectMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + reason_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_DisconnectMessage_descriptor; + } + + public org.tron.protos.Protocol.DisconnectMessage getDefaultInstanceForType() { + return org.tron.protos.Protocol.DisconnectMessage.getDefaultInstance(); + } + + public org.tron.protos.Protocol.DisconnectMessage build() { + org.tron.protos.Protocol.DisconnectMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.DisconnectMessage buildPartial() { + org.tron.protos.Protocol.DisconnectMessage result = new org.tron.protos.Protocol.DisconnectMessage(this); + result.reason_ = reason_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.DisconnectMessage) { + return mergeFrom((org.tron.protos.Protocol.DisconnectMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.DisconnectMessage other) { + if (other == org.tron.protos.Protocol.DisconnectMessage.getDefaultInstance()) return this; + if (other.reason_ != 0) { + setReasonValue(other.getReasonValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.DisconnectMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.DisconnectMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int reason_ = 0; + /** + * .protocol.ReasonCode reason = 1; + */ + public int getReasonValue() { + return reason_; + } + /** + * .protocol.ReasonCode reason = 1; + */ + public Builder setReasonValue(int value) { + reason_ = value; + onChanged(); + return this; + } + /** + * .protocol.ReasonCode reason = 1; + */ + public org.tron.protos.Protocol.ReasonCode getReason() { + org.tron.protos.Protocol.ReasonCode result = org.tron.protos.Protocol.ReasonCode.valueOf(reason_); + return result == null ? org.tron.protos.Protocol.ReasonCode.UNRECOGNIZED : result; + } + /** + * .protocol.ReasonCode reason = 1; + */ + public Builder setReason(org.tron.protos.Protocol.ReasonCode value) { + if (value == null) { + throw new NullPointerException(); + } + + reason_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.ReasonCode reason = 1; + */ + public Builder clearReason() { + + reason_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.DisconnectMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.DisconnectMessage) + private static final org.tron.protos.Protocol.DisconnectMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.DisconnectMessage(); + } + + public static org.tron.protos.Protocol.DisconnectMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DisconnectMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DisconnectMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.DisconnectMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface HelloMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.HelloMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * .protocol.Endpoint from = 1; + */ + boolean hasFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.Endpoint getFrom(); + /** + * .protocol.Endpoint from = 1; + */ + org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder(); + + /** + * int32 version = 2; + */ + int getVersion(); + + /** + * int64 timestamp = 3; + */ + long getTimestamp(); + + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + boolean hasGenesisBlockId(); + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + org.tron.protos.Protocol.HelloMessage.BlockId getGenesisBlockId(); + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getGenesisBlockIdOrBuilder(); + + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + boolean hasSolidBlockId(); + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + org.tron.protos.Protocol.HelloMessage.BlockId getSolidBlockId(); + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getSolidBlockIdOrBuilder(); + + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + boolean hasHeadBlockId(); + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + org.tron.protos.Protocol.HelloMessage.BlockId getHeadBlockId(); + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getHeadBlockIdOrBuilder(); + } + /** + * Protobuf type {@code protocol.HelloMessage} + */ + public static final class HelloMessage extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.HelloMessage) + HelloMessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use HelloMessage.newBuilder() to construct. + private HelloMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private HelloMessage() { + version_ = 0; + timestamp_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private HelloMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + org.tron.protos.Discover.Endpoint.Builder subBuilder = null; + if (from_ != null) { + subBuilder = from_.toBuilder(); + } + from_ = input.readMessage(org.tron.protos.Discover.Endpoint.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(from_); + from_ = subBuilder.buildPartial(); + } + + break; + } + case 16: { + + version_ = input.readInt32(); + break; + } + case 24: { + + timestamp_ = input.readInt64(); + break; + } + case 34: { + org.tron.protos.Protocol.HelloMessage.BlockId.Builder subBuilder = null; + if (genesisBlockId_ != null) { + subBuilder = genesisBlockId_.toBuilder(); + } + genesisBlockId_ = input.readMessage(org.tron.protos.Protocol.HelloMessage.BlockId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(genesisBlockId_); + genesisBlockId_ = subBuilder.buildPartial(); + } + + break; + } + case 42: { + org.tron.protos.Protocol.HelloMessage.BlockId.Builder subBuilder = null; + if (solidBlockId_ != null) { + subBuilder = solidBlockId_.toBuilder(); + } + solidBlockId_ = input.readMessage(org.tron.protos.Protocol.HelloMessage.BlockId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(solidBlockId_); + solidBlockId_ = subBuilder.buildPartial(); + } + + break; + } + case 50: { + org.tron.protos.Protocol.HelloMessage.BlockId.Builder subBuilder = null; + if (headBlockId_ != null) { + subBuilder = headBlockId_.toBuilder(); + } + headBlockId_ = input.readMessage(org.tron.protos.Protocol.HelloMessage.BlockId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(headBlockId_); + headBlockId_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.HelloMessage.class, org.tron.protos.Protocol.HelloMessage.Builder.class); + } + + public interface BlockIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.HelloMessage.BlockId) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes hash = 1; + */ + com.google.protobuf.ByteString getHash(); + + /** + * int64 number = 2; + */ + long getNumber(); + } + /** + * Protobuf type {@code protocol.HelloMessage.BlockId} + */ + public static final class BlockId extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.HelloMessage.BlockId) + BlockIdOrBuilder { + private static final long serialVersionUID = 0L; + // Use BlockId.newBuilder() to construct. + private BlockId(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BlockId() { + hash_ = com.google.protobuf.ByteString.EMPTY; + number_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BlockId( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + hash_ = input.readBytes(); + break; + } + case 16: { + + number_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_BlockId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_BlockId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.HelloMessage.BlockId.class, org.tron.protos.Protocol.HelloMessage.BlockId.Builder.class); + } + + public static final int HASH_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString hash_; + /** + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + + public static final int NUMBER_FIELD_NUMBER = 2; + private long number_; + /** + * int64 number = 2; + */ + public long getNumber() { + return number_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!hash_.isEmpty()) { + output.writeBytes(1, hash_); + } + if (number_ != 0L) { + output.writeInt64(2, number_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, hash_); + } + if (number_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, number_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.HelloMessage.BlockId)) { + return super.equals(obj); + } + org.tron.protos.Protocol.HelloMessage.BlockId other = (org.tron.protos.Protocol.HelloMessage.BlockId) obj; + + boolean result = true; + result = result && getHash() + .equals(other.getHash()); + result = result && (getNumber() + == other.getNumber()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + HASH_FIELD_NUMBER; + hash = (53 * hash) + getHash().hashCode(); + hash = (37 * hash) + NUMBER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNumber()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.HelloMessage.BlockId parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.HelloMessage.BlockId prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.HelloMessage.BlockId} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.HelloMessage.BlockId) + org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_BlockId_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_BlockId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.HelloMessage.BlockId.class, org.tron.protos.Protocol.HelloMessage.BlockId.Builder.class); + } + + // Construct using org.tron.protos.Protocol.HelloMessage.BlockId.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + hash_ = com.google.protobuf.ByteString.EMPTY; + + number_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_BlockId_descriptor; + } + + public org.tron.protos.Protocol.HelloMessage.BlockId getDefaultInstanceForType() { + return org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance(); + } + + public org.tron.protos.Protocol.HelloMessage.BlockId build() { + org.tron.protos.Protocol.HelloMessage.BlockId result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.HelloMessage.BlockId buildPartial() { + org.tron.protos.Protocol.HelloMessage.BlockId result = new org.tron.protos.Protocol.HelloMessage.BlockId(this); + result.hash_ = hash_; + result.number_ = number_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.HelloMessage.BlockId) { + return mergeFrom((org.tron.protos.Protocol.HelloMessage.BlockId)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.HelloMessage.BlockId other) { + if (other == org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance()) return this; + if (other.getHash() != com.google.protobuf.ByteString.EMPTY) { + setHash(other.getHash()); + } + if (other.getNumber() != 0L) { + setNumber(other.getNumber()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.HelloMessage.BlockId parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.HelloMessage.BlockId) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString hash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + * bytes hash = 1; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + onChanged(); + return this; + } + /** + * bytes hash = 1; + */ + public Builder clearHash() { + + hash_ = getDefaultInstance().getHash(); + onChanged(); + return this; + } + + private long number_ ; + /** + * int64 number = 2; + */ + public long getNumber() { + return number_; + } + /** + * int64 number = 2; + */ + public Builder setNumber(long value) { + + number_ = value; + onChanged(); + return this; + } + /** + * int64 number = 2; + */ + public Builder clearNumber() { + + number_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.HelloMessage.BlockId) + } + + // @@protoc_insertion_point(class_scope:protocol.HelloMessage.BlockId) + private static final org.tron.protos.Protocol.HelloMessage.BlockId DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.HelloMessage.BlockId(); + } + + public static org.tron.protos.Protocol.HelloMessage.BlockId getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BlockId parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BlockId(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.HelloMessage.BlockId getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int FROM_FIELD_NUMBER = 1; + private org.tron.protos.Discover.Endpoint from_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + return getFrom(); + } + + public static final int VERSION_FIELD_NUMBER = 2; + private int version_; + /** + * int32 version = 2; + */ + public int getVersion() { + return version_; + } + + public static final int TIMESTAMP_FIELD_NUMBER = 3; + private long timestamp_; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + + public static final int GENESISBLOCKID_FIELD_NUMBER = 4; + private org.tron.protos.Protocol.HelloMessage.BlockId genesisBlockId_; + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public boolean hasGenesisBlockId() { + return genesisBlockId_ != null; + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId getGenesisBlockId() { + return genesisBlockId_ == null ? org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : genesisBlockId_; + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getGenesisBlockIdOrBuilder() { + return getGenesisBlockId(); + } + + public static final int SOLIDBLOCKID_FIELD_NUMBER = 5; + private org.tron.protos.Protocol.HelloMessage.BlockId solidBlockId_; + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public boolean hasSolidBlockId() { + return solidBlockId_ != null; + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId getSolidBlockId() { + return solidBlockId_ == null ? org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : solidBlockId_; + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getSolidBlockIdOrBuilder() { + return getSolidBlockId(); + } + + public static final int HEADBLOCKID_FIELD_NUMBER = 6; + private org.tron.protos.Protocol.HelloMessage.BlockId headBlockId_; + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public boolean hasHeadBlockId() { + return headBlockId_ != null; + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId getHeadBlockId() { + return headBlockId_ == null ? org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : headBlockId_; + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getHeadBlockIdOrBuilder() { + return getHeadBlockId(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (from_ != null) { + output.writeMessage(1, getFrom()); + } + if (version_ != 0) { + output.writeInt32(2, version_); + } + if (timestamp_ != 0L) { + output.writeInt64(3, timestamp_); + } + if (genesisBlockId_ != null) { + output.writeMessage(4, getGenesisBlockId()); + } + if (solidBlockId_ != null) { + output.writeMessage(5, getSolidBlockId()); + } + if (headBlockId_ != null) { + output.writeMessage(6, getHeadBlockId()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (from_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getFrom()); + } + if (version_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, version_); + } + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, timestamp_); + } + if (genesisBlockId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getGenesisBlockId()); + } + if (solidBlockId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getSolidBlockId()); + } + if (headBlockId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getHeadBlockId()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.HelloMessage)) { + return super.equals(obj); + } + org.tron.protos.Protocol.HelloMessage other = (org.tron.protos.Protocol.HelloMessage) obj; + + boolean result = true; + result = result && (hasFrom() == other.hasFrom()); + if (hasFrom()) { + result = result && getFrom() + .equals(other.getFrom()); + } + result = result && (getVersion() + == other.getVersion()); + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && (hasGenesisBlockId() == other.hasGenesisBlockId()); + if (hasGenesisBlockId()) { + result = result && getGenesisBlockId() + .equals(other.getGenesisBlockId()); + } + result = result && (hasSolidBlockId() == other.hasSolidBlockId()); + if (hasSolidBlockId()) { + result = result && getSolidBlockId() + .equals(other.getSolidBlockId()); + } + result = result && (hasHeadBlockId() == other.hasHeadBlockId()); + if (hasHeadBlockId()) { + result = result && getHeadBlockId() + .equals(other.getHeadBlockId()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasFrom()) { + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFrom().hashCode(); + } + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + if (hasGenesisBlockId()) { + hash = (37 * hash) + GENESISBLOCKID_FIELD_NUMBER; + hash = (53 * hash) + getGenesisBlockId().hashCode(); + } + if (hasSolidBlockId()) { + hash = (37 * hash) + SOLIDBLOCKID_FIELD_NUMBER; + hash = (53 * hash) + getSolidBlockId().hashCode(); + } + if (hasHeadBlockId()) { + hash = (37 * hash) + HEADBLOCKID_FIELD_NUMBER; + hash = (53 * hash) + getHeadBlockId().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.HelloMessage parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.HelloMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.HelloMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.HelloMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.HelloMessage} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.HelloMessage) + org.tron.protos.Protocol.HelloMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.HelloMessage.class, org.tron.protos.Protocol.HelloMessage.Builder.class); + } + + // Construct using org.tron.protos.Protocol.HelloMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (fromBuilder_ == null) { + from_ = null; + } else { + from_ = null; + fromBuilder_ = null; + } + version_ = 0; + + timestamp_ = 0L; + + if (genesisBlockIdBuilder_ == null) { + genesisBlockId_ = null; + } else { + genesisBlockId_ = null; + genesisBlockIdBuilder_ = null; + } + if (solidBlockIdBuilder_ == null) { + solidBlockId_ = null; + } else { + solidBlockId_ = null; + solidBlockIdBuilder_ = null; + } + if (headBlockIdBuilder_ == null) { + headBlockId_ = null; + } else { + headBlockId_ = null; + headBlockIdBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_HelloMessage_descriptor; + } + + public org.tron.protos.Protocol.HelloMessage getDefaultInstanceForType() { + return org.tron.protos.Protocol.HelloMessage.getDefaultInstance(); + } + + public org.tron.protos.Protocol.HelloMessage build() { + org.tron.protos.Protocol.HelloMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.HelloMessage buildPartial() { + org.tron.protos.Protocol.HelloMessage result = new org.tron.protos.Protocol.HelloMessage(this); + if (fromBuilder_ == null) { + result.from_ = from_; + } else { + result.from_ = fromBuilder_.build(); + } + result.version_ = version_; + result.timestamp_ = timestamp_; + if (genesisBlockIdBuilder_ == null) { + result.genesisBlockId_ = genesisBlockId_; + } else { + result.genesisBlockId_ = genesisBlockIdBuilder_.build(); + } + if (solidBlockIdBuilder_ == null) { + result.solidBlockId_ = solidBlockId_; + } else { + result.solidBlockId_ = solidBlockIdBuilder_.build(); + } + if (headBlockIdBuilder_ == null) { + result.headBlockId_ = headBlockId_; + } else { + result.headBlockId_ = headBlockIdBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.HelloMessage) { + return mergeFrom((org.tron.protos.Protocol.HelloMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.HelloMessage other) { + if (other == org.tron.protos.Protocol.HelloMessage.getDefaultInstance()) return this; + if (other.hasFrom()) { + mergeFrom(other.getFrom()); + } + if (other.getVersion() != 0) { + setVersion(other.getVersion()); + } + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + if (other.hasGenesisBlockId()) { + mergeGenesisBlockId(other.getGenesisBlockId()); + } + if (other.hasSolidBlockId()) { + mergeSolidBlockId(other.getSolidBlockId()); + } + if (other.hasHeadBlockId()) { + mergeHeadBlockId(other.getHeadBlockId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.HelloMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.HelloMessage) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.tron.protos.Discover.Endpoint from_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> fromBuilder_; + /** + * .protocol.Endpoint from = 1; + */ + public boolean hasFrom() { + return fromBuilder_ != null || from_ != null; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint getFrom() { + if (fromBuilder_ == null) { + return from_ == null ? org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } else { + return fromBuilder_.getMessage(); + } + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + from_ = value; + onChanged(); + } else { + fromBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder setFrom( + org.tron.protos.Discover.Endpoint.Builder builderForValue) { + if (fromBuilder_ == null) { + from_ = builderForValue.build(); + onChanged(); + } else { + fromBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder mergeFrom(org.tron.protos.Discover.Endpoint value) { + if (fromBuilder_ == null) { + if (from_ != null) { + from_ = + org.tron.protos.Discover.Endpoint.newBuilder(from_).mergeFrom(value).buildPartial(); + } else { + from_ = value; + } + onChanged(); + } else { + fromBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public Builder clearFrom() { + if (fromBuilder_ == null) { + from_ = null; + onChanged(); + } else { + from_ = null; + fromBuilder_ = null; + } + + return this; + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.Endpoint.Builder getFromBuilder() { + + onChanged(); + return getFromFieldBuilder().getBuilder(); + } + /** + * .protocol.Endpoint from = 1; + */ + public org.tron.protos.Discover.EndpointOrBuilder getFromOrBuilder() { + if (fromBuilder_ != null) { + return fromBuilder_.getMessageOrBuilder(); + } else { + return from_ == null ? + org.tron.protos.Discover.Endpoint.getDefaultInstance() : from_; + } + } + /** + * .protocol.Endpoint from = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder> + getFromFieldBuilder() { + if (fromBuilder_ == null) { + fromBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Discover.Endpoint, org.tron.protos.Discover.Endpoint.Builder, org.tron.protos.Discover.EndpointOrBuilder>( + getFrom(), + getParentForChildren(), + isClean()); + from_ = null; + } + return fromBuilder_; + } + + private int version_ ; + /** + * int32 version = 2; + */ + public int getVersion() { + return version_; + } + /** + * int32 version = 2; + */ + public Builder setVersion(int value) { + + version_ = value; + onChanged(); + return this; + } + /** + * int32 version = 2; + */ + public Builder clearVersion() { + + version_ = 0; + onChanged(); + return this; + } + + private long timestamp_ ; + /** + * int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 3; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 3; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + + private org.tron.protos.Protocol.HelloMessage.BlockId genesisBlockId_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder> genesisBlockIdBuilder_; + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public boolean hasGenesisBlockId() { + return genesisBlockIdBuilder_ != null || genesisBlockId_ != null; + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId getGenesisBlockId() { + if (genesisBlockIdBuilder_ == null) { + return genesisBlockId_ == null ? org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : genesisBlockId_; + } else { + return genesisBlockIdBuilder_.getMessage(); + } + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public Builder setGenesisBlockId(org.tron.protos.Protocol.HelloMessage.BlockId value) { + if (genesisBlockIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + genesisBlockId_ = value; + onChanged(); + } else { + genesisBlockIdBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public Builder setGenesisBlockId( + org.tron.protos.Protocol.HelloMessage.BlockId.Builder builderForValue) { + if (genesisBlockIdBuilder_ == null) { + genesisBlockId_ = builderForValue.build(); + onChanged(); + } else { + genesisBlockIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public Builder mergeGenesisBlockId(org.tron.protos.Protocol.HelloMessage.BlockId value) { + if (genesisBlockIdBuilder_ == null) { + if (genesisBlockId_ != null) { + genesisBlockId_ = + org.tron.protos.Protocol.HelloMessage.BlockId.newBuilder(genesisBlockId_).mergeFrom(value).buildPartial(); + } else { + genesisBlockId_ = value; + } + onChanged(); + } else { + genesisBlockIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public Builder clearGenesisBlockId() { + if (genesisBlockIdBuilder_ == null) { + genesisBlockId_ = null; + onChanged(); + } else { + genesisBlockId_ = null; + genesisBlockIdBuilder_ = null; + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId.Builder getGenesisBlockIdBuilder() { + + onChanged(); + return getGenesisBlockIdFieldBuilder().getBuilder(); + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + public org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getGenesisBlockIdOrBuilder() { + if (genesisBlockIdBuilder_ != null) { + return genesisBlockIdBuilder_.getMessageOrBuilder(); + } else { + return genesisBlockId_ == null ? + org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : genesisBlockId_; + } + } + /** + * .protocol.HelloMessage.BlockId genesisBlockId = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder> + getGenesisBlockIdFieldBuilder() { + if (genesisBlockIdBuilder_ == null) { + genesisBlockIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder>( + getGenesisBlockId(), + getParentForChildren(), + isClean()); + genesisBlockId_ = null; + } + return genesisBlockIdBuilder_; + } + + private org.tron.protos.Protocol.HelloMessage.BlockId solidBlockId_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder> solidBlockIdBuilder_; + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public boolean hasSolidBlockId() { + return solidBlockIdBuilder_ != null || solidBlockId_ != null; + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId getSolidBlockId() { + if (solidBlockIdBuilder_ == null) { + return solidBlockId_ == null ? org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : solidBlockId_; + } else { + return solidBlockIdBuilder_.getMessage(); + } + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public Builder setSolidBlockId(org.tron.protos.Protocol.HelloMessage.BlockId value) { + if (solidBlockIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + solidBlockId_ = value; + onChanged(); + } else { + solidBlockIdBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public Builder setSolidBlockId( + org.tron.protos.Protocol.HelloMessage.BlockId.Builder builderForValue) { + if (solidBlockIdBuilder_ == null) { + solidBlockId_ = builderForValue.build(); + onChanged(); + } else { + solidBlockIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public Builder mergeSolidBlockId(org.tron.protos.Protocol.HelloMessage.BlockId value) { + if (solidBlockIdBuilder_ == null) { + if (solidBlockId_ != null) { + solidBlockId_ = + org.tron.protos.Protocol.HelloMessage.BlockId.newBuilder(solidBlockId_).mergeFrom(value).buildPartial(); + } else { + solidBlockId_ = value; + } + onChanged(); + } else { + solidBlockIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public Builder clearSolidBlockId() { + if (solidBlockIdBuilder_ == null) { + solidBlockId_ = null; + onChanged(); + } else { + solidBlockId_ = null; + solidBlockIdBuilder_ = null; + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId.Builder getSolidBlockIdBuilder() { + + onChanged(); + return getSolidBlockIdFieldBuilder().getBuilder(); + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + public org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getSolidBlockIdOrBuilder() { + if (solidBlockIdBuilder_ != null) { + return solidBlockIdBuilder_.getMessageOrBuilder(); + } else { + return solidBlockId_ == null ? + org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : solidBlockId_; + } + } + /** + * .protocol.HelloMessage.BlockId solidBlockId = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder> + getSolidBlockIdFieldBuilder() { + if (solidBlockIdBuilder_ == null) { + solidBlockIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder>( + getSolidBlockId(), + getParentForChildren(), + isClean()); + solidBlockId_ = null; + } + return solidBlockIdBuilder_; + } + + private org.tron.protos.Protocol.HelloMessage.BlockId headBlockId_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder> headBlockIdBuilder_; + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public boolean hasHeadBlockId() { + return headBlockIdBuilder_ != null || headBlockId_ != null; + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId getHeadBlockId() { + if (headBlockIdBuilder_ == null) { + return headBlockId_ == null ? org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : headBlockId_; + } else { + return headBlockIdBuilder_.getMessage(); + } + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public Builder setHeadBlockId(org.tron.protos.Protocol.HelloMessage.BlockId value) { + if (headBlockIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + headBlockId_ = value; + onChanged(); + } else { + headBlockIdBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public Builder setHeadBlockId( + org.tron.protos.Protocol.HelloMessage.BlockId.Builder builderForValue) { + if (headBlockIdBuilder_ == null) { + headBlockId_ = builderForValue.build(); + onChanged(); + } else { + headBlockIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public Builder mergeHeadBlockId(org.tron.protos.Protocol.HelloMessage.BlockId value) { + if (headBlockIdBuilder_ == null) { + if (headBlockId_ != null) { + headBlockId_ = + org.tron.protos.Protocol.HelloMessage.BlockId.newBuilder(headBlockId_).mergeFrom(value).buildPartial(); + } else { + headBlockId_ = value; + } + onChanged(); + } else { + headBlockIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public Builder clearHeadBlockId() { + if (headBlockIdBuilder_ == null) { + headBlockId_ = null; + onChanged(); + } else { + headBlockId_ = null; + headBlockIdBuilder_ = null; + } + + return this; + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public org.tron.protos.Protocol.HelloMessage.BlockId.Builder getHeadBlockIdBuilder() { + + onChanged(); + return getHeadBlockIdFieldBuilder().getBuilder(); + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + public org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder getHeadBlockIdOrBuilder() { + if (headBlockIdBuilder_ != null) { + return headBlockIdBuilder_.getMessageOrBuilder(); + } else { + return headBlockId_ == null ? + org.tron.protos.Protocol.HelloMessage.BlockId.getDefaultInstance() : headBlockId_; + } + } + /** + * .protocol.HelloMessage.BlockId headBlockId = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder> + getHeadBlockIdFieldBuilder() { + if (headBlockIdBuilder_ == null) { + headBlockIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.HelloMessage.BlockId, org.tron.protos.Protocol.HelloMessage.BlockId.Builder, org.tron.protos.Protocol.HelloMessage.BlockIdOrBuilder>( + getHeadBlockId(), + getParentForChildren(), + isClean()); + headBlockId_ = null; + } + return headBlockIdBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.HelloMessage) + } + + // @@protoc_insertion_point(class_scope:protocol.HelloMessage) + private static final org.tron.protos.Protocol.HelloMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.HelloMessage(); + } + + public static org.tron.protos.Protocol.HelloMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HelloMessage(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.HelloMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SmartContractOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.SmartContract) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes origin_address = 1; + */ + com.google.protobuf.ByteString getOriginAddress(); + + /** + * bytes contract_address = 2; + */ + com.google.protobuf.ByteString getContractAddress(); + + /** + * .protocol.SmartContract.ABI abi = 3; + */ + boolean hasAbi(); + /** + * .protocol.SmartContract.ABI abi = 3; + */ + org.tron.protos.Protocol.SmartContract.ABI getAbi(); + /** + * .protocol.SmartContract.ABI abi = 3; + */ + org.tron.protos.Protocol.SmartContract.ABIOrBuilder getAbiOrBuilder(); + + /** + * bytes bytecode = 4; + */ + com.google.protobuf.ByteString getBytecode(); + + /** + * int64 call_value = 5; + */ + long getCallValue(); + + /** + * int64 consume_user_resource_percent = 6; + */ + long getConsumeUserResourcePercent(); + + /** + * string name = 7; + */ + java.lang.String getName(); + /** + * string name = 7; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * int64 origin_energy_limit = 8; + */ + long getOriginEnergyLimit(); + + /** + * bytes code_hash = 9; + */ + com.google.protobuf.ByteString getCodeHash(); + + /** + * bytes trx_hash = 10; + */ + com.google.protobuf.ByteString getTrxHash(); + } + /** + * Protobuf type {@code protocol.SmartContract} + */ + public static final class SmartContract extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.SmartContract) + SmartContractOrBuilder { + private static final long serialVersionUID = 0L; + // Use SmartContract.newBuilder() to construct. + private SmartContract(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SmartContract() { + originAddress_ = com.google.protobuf.ByteString.EMPTY; + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + bytecode_ = com.google.protobuf.ByteString.EMPTY; + callValue_ = 0L; + consumeUserResourcePercent_ = 0L; + name_ = ""; + originEnergyLimit_ = 0L; + codeHash_ = com.google.protobuf.ByteString.EMPTY; + trxHash_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SmartContract( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + originAddress_ = input.readBytes(); + break; + } + case 18: { + + contractAddress_ = input.readBytes(); + break; + } + case 26: { + org.tron.protos.Protocol.SmartContract.ABI.Builder subBuilder = null; + if (abi_ != null) { + subBuilder = abi_.toBuilder(); + } + abi_ = input.readMessage(org.tron.protos.Protocol.SmartContract.ABI.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(abi_); + abi_ = subBuilder.buildPartial(); + } + + break; + } + case 34: { + + bytecode_ = input.readBytes(); + break; + } + case 40: { + + callValue_ = input.readInt64(); + break; + } + case 48: { + + consumeUserResourcePercent_ = input.readInt64(); + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 64: { + + originEnergyLimit_ = input.readInt64(); + break; + } + case 74: { + + codeHash_ = input.readBytes(); + break; + } + case 82: { + + trxHash_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.class, org.tron.protos.Protocol.SmartContract.Builder.class); + } + + public interface ABIOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.SmartContract.ABI) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + java.util.List + getEntrysList(); + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + org.tron.protos.Protocol.SmartContract.ABI.Entry getEntrys(int index); + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + int getEntrysCount(); + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + java.util.List + getEntrysOrBuilderList(); + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + org.tron.protos.Protocol.SmartContract.ABI.EntryOrBuilder getEntrysOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.SmartContract.ABI} + */ + public static final class ABI extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.SmartContract.ABI) + ABIOrBuilder { + private static final long serialVersionUID = 0L; + // Use ABI.newBuilder() to construct. + private ABI(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ABI() { + entrys_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ABI( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + entrys_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + entrys_.add( + input.readMessage(org.tron.protos.Protocol.SmartContract.ABI.Entry.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + entrys_ = java.util.Collections.unmodifiableList(entrys_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.ABI.class, org.tron.protos.Protocol.SmartContract.ABI.Builder.class); + } + + public interface EntryOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.SmartContract.ABI.Entry) + com.google.protobuf.MessageOrBuilder { + + /** + * bool anonymous = 1; + */ + boolean getAnonymous(); + + /** + * bool constant = 2; + */ + boolean getConstant(); + + /** + * string name = 3; + */ + java.lang.String getName(); + /** + * string name = 3; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + java.util.List + getInputsList(); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getInputs(int index); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + int getInputsCount(); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + java.util.List + getInputsOrBuilderList(); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder getInputsOrBuilder( + int index); + + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + java.util.List + getOutputsList(); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getOutputs(int index); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + int getOutputsCount(); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + java.util.List + getOutputsOrBuilderList(); + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder getOutputsOrBuilder( + int index); + + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + int getTypeValue(); + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType getType(); + + /** + * bool payable = 7; + */ + boolean getPayable(); + + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + int getStateMutabilityValue(); + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType getStateMutability(); + } + /** + * Protobuf type {@code protocol.SmartContract.ABI.Entry} + */ + public static final class Entry extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.SmartContract.ABI.Entry) + EntryOrBuilder { + private static final long serialVersionUID = 0L; + // Use Entry.newBuilder() to construct. + private Entry(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Entry() { + anonymous_ = false; + constant_ = false; + name_ = ""; + inputs_ = java.util.Collections.emptyList(); + outputs_ = java.util.Collections.emptyList(); + type_ = 0; + payable_ = false; + stateMutability_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Entry( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + anonymous_ = input.readBool(); + break; + } + case 16: { + + constant_ = input.readBool(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + inputs_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + inputs_.add( + input.readMessage(org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.parser(), extensionRegistry)); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + outputs_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + outputs_.add( + input.readMessage(org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.parser(), extensionRegistry)); + break; + } + case 48: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 56: { + + payable_ = input.readBool(); + break; + } + case 64: { + int rawValue = input.readEnum(); + + stateMutability_ = rawValue; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + inputs_ = java.util.Collections.unmodifiableList(inputs_); + } + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + outputs_ = java.util.Collections.unmodifiableList(outputs_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.ABI.Entry.class, org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder.class); + } + + /** + * Protobuf enum {@code protocol.SmartContract.ABI.Entry.EntryType} + */ + public enum EntryType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * UnknownEntryType = 0; + */ + UnknownEntryType(0), + /** + * Constructor = 1; + */ + Constructor(1), + /** + * Function = 2; + */ + Function(2), + /** + * Event = 3; + */ + Event(3), + /** + * Fallback = 4; + */ + Fallback(4), + UNRECOGNIZED(-1), + ; + + /** + * UnknownEntryType = 0; + */ + public static final int UnknownEntryType_VALUE = 0; + /** + * Constructor = 1; + */ + public static final int Constructor_VALUE = 1; + /** + * Function = 2; + */ + public static final int Function_VALUE = 2; + /** + * Event = 3; + */ + public static final int Event_VALUE = 3; + /** + * Fallback = 4; + */ + public static final int Fallback_VALUE = 4; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static EntryType valueOf(int value) { + return forNumber(value); + } + + public static EntryType forNumber(int value) { + switch (value) { + case 0: return UnknownEntryType; + case 1: return Constructor; + case 2: return Function; + case 3: return Event; + case 4: return Fallback; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + EntryType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public EntryType findValueByNumber(int number) { + return EntryType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.SmartContract.ABI.Entry.getDescriptor().getEnumTypes().get(0); + } + + private static final EntryType[] VALUES = values(); + + public static EntryType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private EntryType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.SmartContract.ABI.Entry.EntryType) + } + + /** + * Protobuf enum {@code protocol.SmartContract.ABI.Entry.StateMutabilityType} + */ + public enum StateMutabilityType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * UnknownMutabilityType = 0; + */ + UnknownMutabilityType(0), + /** + * Pure = 1; + */ + Pure(1), + /** + * View = 2; + */ + View(2), + /** + * Nonpayable = 3; + */ + Nonpayable(3), + /** + * Payable = 4; + */ + Payable(4), + UNRECOGNIZED(-1), + ; + + /** + * UnknownMutabilityType = 0; + */ + public static final int UnknownMutabilityType_VALUE = 0; + /** + * Pure = 1; + */ + public static final int Pure_VALUE = 1; + /** + * View = 2; + */ + public static final int View_VALUE = 2; + /** + * Nonpayable = 3; + */ + public static final int Nonpayable_VALUE = 3; + /** + * Payable = 4; + */ + public static final int Payable_VALUE = 4; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static StateMutabilityType valueOf(int value) { + return forNumber(value); + } + + public static StateMutabilityType forNumber(int value) { + switch (value) { + case 0: return UnknownMutabilityType; + case 1: return Pure; + case 2: return View; + case 3: return Nonpayable; + case 4: return Payable; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + StateMutabilityType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public StateMutabilityType findValueByNumber(int number) { + return StateMutabilityType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.tron.protos.Protocol.SmartContract.ABI.Entry.getDescriptor().getEnumTypes().get(1); + } + + private static final StateMutabilityType[] VALUES = values(); + + public static StateMutabilityType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private StateMutabilityType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:protocol.SmartContract.ABI.Entry.StateMutabilityType) + } + + public interface ParamOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.SmartContract.ABI.Entry.Param) + com.google.protobuf.MessageOrBuilder { + + /** + * bool indexed = 1; + */ + boolean getIndexed(); + + /** + * string name = 2; + */ + java.lang.String getName(); + /** + * string name = 2; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+           * SolidityType type = 3;
+           * 
+ * + * string type = 3; + */ + java.lang.String getType(); + /** + *
+           * SolidityType type = 3;
+           * 
+ * + * string type = 3; + */ + com.google.protobuf.ByteString + getTypeBytes(); + } + /** + * Protobuf type {@code protocol.SmartContract.ABI.Entry.Param} + */ + public static final class Param extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.SmartContract.ABI.Entry.Param) + ParamOrBuilder { + private static final long serialVersionUID = 0L; + // Use Param.newBuilder() to construct. + private Param(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Param() { + indexed_ = false; + name_ = ""; + type_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Param( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + indexed_ = input.readBool(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + type_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_Param_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_Param_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.class, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder.class); + } + + public static final int INDEXED_FIELD_NUMBER = 1; + private boolean indexed_; + /** + * bool indexed = 1; + */ + public boolean getIndexed() { + return indexed_; + } + + public static final int NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object name_; + /** + * string name = 2; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 2; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 3; + private volatile java.lang.Object type_; + /** + *
+           * SolidityType type = 3;
+           * 
+ * + * string type = 3; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } + } + /** + *
+           * SolidityType type = 3;
+           * 
+ * + * string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (indexed_ != false) { + output.writeBool(1, indexed_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); + } + if (!getTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (indexed_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, indexed_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); + } + if (!getTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.SmartContract.ABI.Entry.Param)) { + return super.equals(obj); + } + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param other = (org.tron.protos.Protocol.SmartContract.ABI.Entry.Param) obj; + + boolean result = true; + result = result && (getIndexed() + == other.getIndexed()); + result = result && getName() + .equals(other.getName()); + result = result && getType() + .equals(other.getType()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + INDEXED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIndexed()); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.SmartContract.ABI.Entry.Param prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.SmartContract.ABI.Entry.Param} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.SmartContract.ABI.Entry.Param) + org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_Param_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_Param_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.class, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder.class); + } + + // Construct using org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + indexed_ = false; + + name_ = ""; + + type_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_Param_descriptor; + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getDefaultInstanceForType() { + return org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.getDefaultInstance(); + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param build() { + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param buildPartial() { + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param result = new org.tron.protos.Protocol.SmartContract.ABI.Entry.Param(this); + result.indexed_ = indexed_; + result.name_ = name_; + result.type_ = type_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.SmartContract.ABI.Entry.Param) { + return mergeFrom((org.tron.protos.Protocol.SmartContract.ABI.Entry.Param)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.SmartContract.ABI.Entry.Param other) { + if (other == org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.getDefaultInstance()) return this; + if (other.getIndexed() != false) { + setIndexed(other.getIndexed()); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getType().isEmpty()) { + type_ = other.type_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.SmartContract.ABI.Entry.Param) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean indexed_ ; + /** + * bool indexed = 1; + */ + public boolean getIndexed() { + return indexed_; + } + /** + * bool indexed = 1; + */ + public Builder setIndexed(boolean value) { + + indexed_ = value; + onChanged(); + return this; + } + /** + * bool indexed = 1; + */ + public Builder clearIndexed() { + + indexed_ = false; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 2; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 2; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 2; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 2; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 2; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object type_ = ""; + /** + *
+             * SolidityType type = 3;
+             * 
+ * + * string type = 3; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+             * SolidityType type = 3;
+             * 
+ * + * string type = 3; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+             * SolidityType type = 3;
+             * 
+ * + * string type = 3; + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value; + onChanged(); + return this; + } + /** + *
+             * SolidityType type = 3;
+             * 
+ * + * string type = 3; + */ + public Builder clearType() { + + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + *
+             * SolidityType type = 3;
+             * 
+ * + * string type = 3; + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + type_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.SmartContract.ABI.Entry.Param) + } + + // @@protoc_insertion_point(class_scope:protocol.SmartContract.ABI.Entry.Param) + private static final org.tron.protos.Protocol.SmartContract.ABI.Entry.Param DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.SmartContract.ABI.Entry.Param(); + } + + public static org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Param parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Param(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int ANONYMOUS_FIELD_NUMBER = 1; + private boolean anonymous_; + /** + * bool anonymous = 1; + */ + public boolean getAnonymous() { + return anonymous_; + } + + public static final int CONSTANT_FIELD_NUMBER = 2; + private boolean constant_; + /** + * bool constant = 2; + */ + public boolean getConstant() { + return constant_; + } + + public static final int NAME_FIELD_NUMBER = 3; + private volatile java.lang.Object name_; + /** + * string name = 3; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INPUTS_FIELD_NUMBER = 4; + private java.util.List inputs_; + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public java.util.List getInputsList() { + return inputs_; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public java.util.List + getInputsOrBuilderList() { + return inputs_; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public int getInputsCount() { + return inputs_.size(); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getInputs(int index) { + return inputs_.get(index); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder getInputsOrBuilder( + int index) { + return inputs_.get(index); + } + + public static final int OUTPUTS_FIELD_NUMBER = 5; + private java.util.List outputs_; + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public java.util.List getOutputsList() { + return outputs_; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public java.util.List + getOutputsOrBuilderList() { + return outputs_; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public int getOutputsCount() { + return outputs_.size(); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getOutputs(int index) { + return outputs_.get(index); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder getOutputsOrBuilder( + int index) { + return outputs_.get(index); + } + + public static final int TYPE_FIELD_NUMBER = 6; + private int type_; + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType getType() { + org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType result = org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType.UNRECOGNIZED : result; + } + + public static final int PAYABLE_FIELD_NUMBER = 7; + private boolean payable_; + /** + * bool payable = 7; + */ + public boolean getPayable() { + return payable_; + } + + public static final int STATEMUTABILITY_FIELD_NUMBER = 8; + private int stateMutability_; + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + public int getStateMutabilityValue() { + return stateMutability_; + } + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType getStateMutability() { + org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType result = org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType.valueOf(stateMutability_); + return result == null ? org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (anonymous_ != false) { + output.writeBool(1, anonymous_); + } + if (constant_ != false) { + output.writeBool(2, constant_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_); + } + for (int i = 0; i < inputs_.size(); i++) { + output.writeMessage(4, inputs_.get(i)); + } + for (int i = 0; i < outputs_.size(); i++) { + output.writeMessage(5, outputs_.get(i)); + } + if (type_ != org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType.UnknownEntryType.getNumber()) { + output.writeEnum(6, type_); + } + if (payable_ != false) { + output.writeBool(7, payable_); + } + if (stateMutability_ != org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType.UnknownMutabilityType.getNumber()) { + output.writeEnum(8, stateMutability_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (anonymous_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, anonymous_); + } + if (constant_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, constant_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_); + } + for (int i = 0; i < inputs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, inputs_.get(i)); + } + for (int i = 0; i < outputs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, outputs_.get(i)); + } + if (type_ != org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType.UnknownEntryType.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(6, type_); + } + if (payable_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(7, payable_); + } + if (stateMutability_ != org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType.UnknownMutabilityType.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(8, stateMutability_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.SmartContract.ABI.Entry)) { + return super.equals(obj); + } + org.tron.protos.Protocol.SmartContract.ABI.Entry other = (org.tron.protos.Protocol.SmartContract.ABI.Entry) obj; + + boolean result = true; + result = result && (getAnonymous() + == other.getAnonymous()); + result = result && (getConstant() + == other.getConstant()); + result = result && getName() + .equals(other.getName()); + result = result && getInputsList() + .equals(other.getInputsList()); + result = result && getOutputsList() + .equals(other.getOutputsList()); + result = result && type_ == other.type_; + result = result && (getPayable() + == other.getPayable()); + result = result && stateMutability_ == other.stateMutability_; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ANONYMOUS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getAnonymous()); + hash = (37 * hash) + CONSTANT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getConstant()); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getInputsCount() > 0) { + hash = (37 * hash) + INPUTS_FIELD_NUMBER; + hash = (53 * hash) + getInputsList().hashCode(); + } + if (getOutputsCount() > 0) { + hash = (37 * hash) + OUTPUTS_FIELD_NUMBER; + hash = (53 * hash) + getOutputsList().hashCode(); + } + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + PAYABLE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getPayable()); + hash = (37 * hash) + STATEMUTABILITY_FIELD_NUMBER; + hash = (53 * hash) + stateMutability_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI.Entry parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.SmartContract.ABI.Entry prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.SmartContract.ABI.Entry} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.SmartContract.ABI.Entry) + org.tron.protos.Protocol.SmartContract.ABI.EntryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.ABI.Entry.class, org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder.class); + } + + // Construct using org.tron.protos.Protocol.SmartContract.ABI.Entry.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getInputsFieldBuilder(); + getOutputsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + anonymous_ = false; + + constant_ = false; + + name_ = ""; + + if (inputsBuilder_ == null) { + inputs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + inputsBuilder_.clear(); + } + if (outputsBuilder_ == null) { + outputs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + outputsBuilder_.clear(); + } + type_ = 0; + + payable_ = false; + + stateMutability_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_Entry_descriptor; + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry getDefaultInstanceForType() { + return org.tron.protos.Protocol.SmartContract.ABI.Entry.getDefaultInstance(); + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry build() { + org.tron.protos.Protocol.SmartContract.ABI.Entry result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry buildPartial() { + org.tron.protos.Protocol.SmartContract.ABI.Entry result = new org.tron.protos.Protocol.SmartContract.ABI.Entry(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.anonymous_ = anonymous_; + result.constant_ = constant_; + result.name_ = name_; + if (inputsBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + inputs_ = java.util.Collections.unmodifiableList(inputs_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.inputs_ = inputs_; + } else { + result.inputs_ = inputsBuilder_.build(); + } + if (outputsBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + outputs_ = java.util.Collections.unmodifiableList(outputs_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.outputs_ = outputs_; + } else { + result.outputs_ = outputsBuilder_.build(); + } + result.type_ = type_; + result.payable_ = payable_; + result.stateMutability_ = stateMutability_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.SmartContract.ABI.Entry) { + return mergeFrom((org.tron.protos.Protocol.SmartContract.ABI.Entry)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.SmartContract.ABI.Entry other) { + if (other == org.tron.protos.Protocol.SmartContract.ABI.Entry.getDefaultInstance()) return this; + if (other.getAnonymous() != false) { + setAnonymous(other.getAnonymous()); + } + if (other.getConstant() != false) { + setConstant(other.getConstant()); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (inputsBuilder_ == null) { + if (!other.inputs_.isEmpty()) { + if (inputs_.isEmpty()) { + inputs_ = other.inputs_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureInputsIsMutable(); + inputs_.addAll(other.inputs_); + } + onChanged(); + } + } else { + if (!other.inputs_.isEmpty()) { + if (inputsBuilder_.isEmpty()) { + inputsBuilder_.dispose(); + inputsBuilder_ = null; + inputs_ = other.inputs_; + bitField0_ = (bitField0_ & ~0x00000008); + inputsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getInputsFieldBuilder() : null; + } else { + inputsBuilder_.addAllMessages(other.inputs_); + } + } + } + if (outputsBuilder_ == null) { + if (!other.outputs_.isEmpty()) { + if (outputs_.isEmpty()) { + outputs_ = other.outputs_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureOutputsIsMutable(); + outputs_.addAll(other.outputs_); + } + onChanged(); + } + } else { + if (!other.outputs_.isEmpty()) { + if (outputsBuilder_.isEmpty()) { + outputsBuilder_.dispose(); + outputsBuilder_ = null; + outputs_ = other.outputs_; + bitField0_ = (bitField0_ & ~0x00000010); + outputsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getOutputsFieldBuilder() : null; + } else { + outputsBuilder_.addAllMessages(other.outputs_); + } + } + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.getPayable() != false) { + setPayable(other.getPayable()); + } + if (other.stateMutability_ != 0) { + setStateMutabilityValue(other.getStateMutabilityValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.SmartContract.ABI.Entry parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.SmartContract.ABI.Entry) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private boolean anonymous_ ; + /** + * bool anonymous = 1; + */ + public boolean getAnonymous() { + return anonymous_; + } + /** + * bool anonymous = 1; + */ + public Builder setAnonymous(boolean value) { + + anonymous_ = value; + onChanged(); + return this; + } + /** + * bool anonymous = 1; + */ + public Builder clearAnonymous() { + + anonymous_ = false; + onChanged(); + return this; + } + + private boolean constant_ ; + /** + * bool constant = 2; + */ + public boolean getConstant() { + return constant_; + } + /** + * bool constant = 2; + */ + public Builder setConstant(boolean value) { + + constant_ = value; + onChanged(); + return this; + } + /** + * bool constant = 2; + */ + public Builder clearConstant() { + + constant_ = false; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 3; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 3; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 3; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 3; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.util.List inputs_ = + java.util.Collections.emptyList(); + private void ensureInputsIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + inputs_ = new java.util.ArrayList(inputs_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder, org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder> inputsBuilder_; + + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public java.util.List getInputsList() { + if (inputsBuilder_ == null) { + return java.util.Collections.unmodifiableList(inputs_); + } else { + return inputsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public int getInputsCount() { + if (inputsBuilder_ == null) { + return inputs_.size(); + } else { + return inputsBuilder_.getCount(); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getInputs(int index) { + if (inputsBuilder_ == null) { + return inputs_.get(index); + } else { + return inputsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder setInputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param value) { + if (inputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputsIsMutable(); + inputs_.set(index, value); + onChanged(); + } else { + inputsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder setInputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder builderForValue) { + if (inputsBuilder_ == null) { + ensureInputsIsMutable(); + inputs_.set(index, builderForValue.build()); + onChanged(); + } else { + inputsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder addInputs(org.tron.protos.Protocol.SmartContract.ABI.Entry.Param value) { + if (inputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputsIsMutable(); + inputs_.add(value); + onChanged(); + } else { + inputsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder addInputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param value) { + if (inputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputsIsMutable(); + inputs_.add(index, value); + onChanged(); + } else { + inputsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder addInputs( + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder builderForValue) { + if (inputsBuilder_ == null) { + ensureInputsIsMutable(); + inputs_.add(builderForValue.build()); + onChanged(); + } else { + inputsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder addInputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder builderForValue) { + if (inputsBuilder_ == null) { + ensureInputsIsMutable(); + inputs_.add(index, builderForValue.build()); + onChanged(); + } else { + inputsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder addAllInputs( + java.lang.Iterable values) { + if (inputsBuilder_ == null) { + ensureInputsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, inputs_); + onChanged(); + } else { + inputsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder clearInputs() { + if (inputsBuilder_ == null) { + inputs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + inputsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public Builder removeInputs(int index) { + if (inputsBuilder_ == null) { + ensureInputsIsMutable(); + inputs_.remove(index); + onChanged(); + } else { + inputsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder getInputsBuilder( + int index) { + return getInputsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder getInputsOrBuilder( + int index) { + if (inputsBuilder_ == null) { + return inputs_.get(index); } else { + return inputsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public java.util.List + getInputsOrBuilderList() { + if (inputsBuilder_ != null) { + return inputsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(inputs_); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder addInputsBuilder() { + return getInputsFieldBuilder().addBuilder( + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.getDefaultInstance()); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder addInputsBuilder( + int index) { + return getInputsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.getDefaultInstance()); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param inputs = 4; + */ + public java.util.List + getInputsBuilderList() { + return getInputsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder, org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder> + getInputsFieldBuilder() { + if (inputsBuilder_ == null) { + inputsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder, org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder>( + inputs_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + inputs_ = null; + } + return inputsBuilder_; + } + + private java.util.List outputs_ = + java.util.Collections.emptyList(); + private void ensureOutputsIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + outputs_ = new java.util.ArrayList(outputs_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder, org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder> outputsBuilder_; + + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public java.util.List getOutputsList() { + if (outputsBuilder_ == null) { + return java.util.Collections.unmodifiableList(outputs_); + } else { + return outputsBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public int getOutputsCount() { + if (outputsBuilder_ == null) { + return outputs_.size(); + } else { + return outputsBuilder_.getCount(); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param getOutputs(int index) { + if (outputsBuilder_ == null) { + return outputs_.get(index); + } else { + return outputsBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder setOutputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param value) { + if (outputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.set(index, value); + onChanged(); + } else { + outputsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder setOutputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder builderForValue) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.set(index, builderForValue.build()); + onChanged(); + } else { + outputsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder addOutputs(org.tron.protos.Protocol.SmartContract.ABI.Entry.Param value) { + if (outputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.add(value); + onChanged(); + } else { + outputsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder addOutputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param value) { + if (outputsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputsIsMutable(); + outputs_.add(index, value); + onChanged(); + } else { + outputsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder addOutputs( + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder builderForValue) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.add(builderForValue.build()); + onChanged(); + } else { + outputsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder addOutputs( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder builderForValue) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.add(index, builderForValue.build()); + onChanged(); + } else { + outputsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder addAllOutputs( + java.lang.Iterable values) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, outputs_); + onChanged(); + } else { + outputsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder clearOutputs() { + if (outputsBuilder_ == null) { + outputs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + outputsBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public Builder removeOutputs(int index) { + if (outputsBuilder_ == null) { + ensureOutputsIsMutable(); + outputs_.remove(index); + onChanged(); + } else { + outputsBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder getOutputsBuilder( + int index) { + return getOutputsFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder getOutputsOrBuilder( + int index) { + if (outputsBuilder_ == null) { + return outputs_.get(index); } else { + return outputsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public java.util.List + getOutputsOrBuilderList() { + if (outputsBuilder_ != null) { + return outputsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(outputs_); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder addOutputsBuilder() { + return getOutputsFieldBuilder().addBuilder( + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.getDefaultInstance()); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder addOutputsBuilder( + int index) { + return getOutputsFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.getDefaultInstance()); + } + /** + * repeated .protocol.SmartContract.ABI.Entry.Param outputs = 5; + */ + public java.util.List + getOutputsBuilderList() { + return getOutputsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder, org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder> + getOutputsFieldBuilder() { + if (outputsBuilder_ == null) { + outputsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry.Param, org.tron.protos.Protocol.SmartContract.ABI.Entry.Param.Builder, org.tron.protos.Protocol.SmartContract.ABI.Entry.ParamOrBuilder>( + outputs_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + outputs_ = null; + } + return outputsBuilder_; + } + + private int type_ = 0; + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + public int getTypeValue() { + return type_; + } + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType getType() { + org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType result = org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType.valueOf(type_); + return result == null ? org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType.UNRECOGNIZED : result; + } + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + public Builder setType(org.tron.protos.Protocol.SmartContract.ABI.Entry.EntryType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.SmartContract.ABI.Entry.EntryType type = 6; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private boolean payable_ ; + /** + * bool payable = 7; + */ + public boolean getPayable() { + return payable_; + } + /** + * bool payable = 7; + */ + public Builder setPayable(boolean value) { + + payable_ = value; + onChanged(); + return this; + } + /** + * bool payable = 7; + */ + public Builder clearPayable() { + + payable_ = false; + onChanged(); + return this; + } + + private int stateMutability_ = 0; + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + public int getStateMutabilityValue() { + return stateMutability_; + } + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + public Builder setStateMutabilityValue(int value) { + stateMutability_ = value; + onChanged(); + return this; + } + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType getStateMutability() { + org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType result = org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType.valueOf(stateMutability_); + return result == null ? org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType.UNRECOGNIZED : result; + } + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + public Builder setStateMutability(org.tron.protos.Protocol.SmartContract.ABI.Entry.StateMutabilityType value) { + if (value == null) { + throw new NullPointerException(); + } + + stateMutability_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .protocol.SmartContract.ABI.Entry.StateMutabilityType stateMutability = 8; + */ + public Builder clearStateMutability() { + + stateMutability_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.SmartContract.ABI.Entry) + } + + // @@protoc_insertion_point(class_scope:protocol.SmartContract.ABI.Entry) + private static final org.tron.protos.Protocol.SmartContract.ABI.Entry DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.SmartContract.ABI.Entry(); + } + + public static org.tron.protos.Protocol.SmartContract.ABI.Entry getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Entry parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Entry(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.SmartContract.ABI.Entry getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int ENTRYS_FIELD_NUMBER = 1; + private java.util.List entrys_; + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public java.util.List getEntrysList() { + return entrys_; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public java.util.List + getEntrysOrBuilderList() { + return entrys_; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public int getEntrysCount() { + return entrys_.size(); + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry getEntrys(int index) { + return entrys_.get(index); + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public org.tron.protos.Protocol.SmartContract.ABI.EntryOrBuilder getEntrysOrBuilder( + int index) { + return entrys_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < entrys_.size(); i++) { + output.writeMessage(1, entrys_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < entrys_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, entrys_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.SmartContract.ABI)) { + return super.equals(obj); + } + org.tron.protos.Protocol.SmartContract.ABI other = (org.tron.protos.Protocol.SmartContract.ABI) obj; + + boolean result = true; + result = result && getEntrysList() + .equals(other.getEntrysList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getEntrysCount() > 0) { + hash = (37 * hash) + ENTRYS_FIELD_NUMBER; + hash = (53 * hash) + getEntrysList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract.ABI parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.SmartContract.ABI prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.SmartContract.ABI} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.SmartContract.ABI) + org.tron.protos.Protocol.SmartContract.ABIOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.ABI.class, org.tron.protos.Protocol.SmartContract.ABI.Builder.class); + } + + // Construct using org.tron.protos.Protocol.SmartContract.ABI.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getEntrysFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (entrysBuilder_ == null) { + entrys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + entrysBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_ABI_descriptor; + } + + public org.tron.protos.Protocol.SmartContract.ABI getDefaultInstanceForType() { + return org.tron.protos.Protocol.SmartContract.ABI.getDefaultInstance(); + } + + public org.tron.protos.Protocol.SmartContract.ABI build() { + org.tron.protos.Protocol.SmartContract.ABI result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.SmartContract.ABI buildPartial() { + org.tron.protos.Protocol.SmartContract.ABI result = new org.tron.protos.Protocol.SmartContract.ABI(this); + int from_bitField0_ = bitField0_; + if (entrysBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + entrys_ = java.util.Collections.unmodifiableList(entrys_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.entrys_ = entrys_; + } else { + result.entrys_ = entrysBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.SmartContract.ABI) { + return mergeFrom((org.tron.protos.Protocol.SmartContract.ABI)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.SmartContract.ABI other) { + if (other == org.tron.protos.Protocol.SmartContract.ABI.getDefaultInstance()) return this; + if (entrysBuilder_ == null) { + if (!other.entrys_.isEmpty()) { + if (entrys_.isEmpty()) { + entrys_ = other.entrys_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureEntrysIsMutable(); + entrys_.addAll(other.entrys_); + } + onChanged(); + } + } else { + if (!other.entrys_.isEmpty()) { + if (entrysBuilder_.isEmpty()) { + entrysBuilder_.dispose(); + entrysBuilder_ = null; + entrys_ = other.entrys_; + bitField0_ = (bitField0_ & ~0x00000001); + entrysBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getEntrysFieldBuilder() : null; + } else { + entrysBuilder_.addAllMessages(other.entrys_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.SmartContract.ABI parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.SmartContract.ABI) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List entrys_ = + java.util.Collections.emptyList(); + private void ensureEntrysIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + entrys_ = new java.util.ArrayList(entrys_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry, org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder, org.tron.protos.Protocol.SmartContract.ABI.EntryOrBuilder> entrysBuilder_; + + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public java.util.List getEntrysList() { + if (entrysBuilder_ == null) { + return java.util.Collections.unmodifiableList(entrys_); + } else { + return entrysBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public int getEntrysCount() { + if (entrysBuilder_ == null) { + return entrys_.size(); + } else { + return entrysBuilder_.getCount(); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry getEntrys(int index) { + if (entrysBuilder_ == null) { + return entrys_.get(index); + } else { + return entrysBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder setEntrys( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry value) { + if (entrysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEntrysIsMutable(); + entrys_.set(index, value); + onChanged(); + } else { + entrysBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder setEntrys( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder builderForValue) { + if (entrysBuilder_ == null) { + ensureEntrysIsMutable(); + entrys_.set(index, builderForValue.build()); + onChanged(); + } else { + entrysBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder addEntrys(org.tron.protos.Protocol.SmartContract.ABI.Entry value) { + if (entrysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEntrysIsMutable(); + entrys_.add(value); + onChanged(); + } else { + entrysBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder addEntrys( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry value) { + if (entrysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEntrysIsMutable(); + entrys_.add(index, value); + onChanged(); + } else { + entrysBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder addEntrys( + org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder builderForValue) { + if (entrysBuilder_ == null) { + ensureEntrysIsMutable(); + entrys_.add(builderForValue.build()); + onChanged(); + } else { + entrysBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder addEntrys( + int index, org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder builderForValue) { + if (entrysBuilder_ == null) { + ensureEntrysIsMutable(); + entrys_.add(index, builderForValue.build()); + onChanged(); + } else { + entrysBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder addAllEntrys( + java.lang.Iterable values) { + if (entrysBuilder_ == null) { + ensureEntrysIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, entrys_); + onChanged(); + } else { + entrysBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder clearEntrys() { + if (entrysBuilder_ == null) { + entrys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + entrysBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public Builder removeEntrys(int index) { + if (entrysBuilder_ == null) { + ensureEntrysIsMutable(); + entrys_.remove(index); + onChanged(); + } else { + entrysBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder getEntrysBuilder( + int index) { + return getEntrysFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public org.tron.protos.Protocol.SmartContract.ABI.EntryOrBuilder getEntrysOrBuilder( + int index) { + if (entrysBuilder_ == null) { + return entrys_.get(index); } else { + return entrysBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public java.util.List + getEntrysOrBuilderList() { + if (entrysBuilder_ != null) { + return entrysBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(entrys_); + } + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder addEntrysBuilder() { + return getEntrysFieldBuilder().addBuilder( + org.tron.protos.Protocol.SmartContract.ABI.Entry.getDefaultInstance()); + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder addEntrysBuilder( + int index) { + return getEntrysFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.SmartContract.ABI.Entry.getDefaultInstance()); + } + /** + * repeated .protocol.SmartContract.ABI.Entry entrys = 1; + */ + public java.util.List + getEntrysBuilderList() { + return getEntrysFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry, org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder, org.tron.protos.Protocol.SmartContract.ABI.EntryOrBuilder> + getEntrysFieldBuilder() { + if (entrysBuilder_ == null) { + entrysBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI.Entry, org.tron.protos.Protocol.SmartContract.ABI.Entry.Builder, org.tron.protos.Protocol.SmartContract.ABI.EntryOrBuilder>( + entrys_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + entrys_ = null; + } + return entrysBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.SmartContract.ABI) + } + + // @@protoc_insertion_point(class_scope:protocol.SmartContract.ABI) + private static final org.tron.protos.Protocol.SmartContract.ABI DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.SmartContract.ABI(); + } + + public static org.tron.protos.Protocol.SmartContract.ABI getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ABI parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ABI(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.SmartContract.ABI getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int ORIGIN_ADDRESS_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString originAddress_; + /** + * bytes origin_address = 1; + */ + public com.google.protobuf.ByteString getOriginAddress() { + return originAddress_; + } + + public static final int CONTRACT_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString contractAddress_; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + + public static final int ABI_FIELD_NUMBER = 3; + private org.tron.protos.Protocol.SmartContract.ABI abi_; + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public boolean hasAbi() { + return abi_ != null; + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public org.tron.protos.Protocol.SmartContract.ABI getAbi() { + return abi_ == null ? org.tron.protos.Protocol.SmartContract.ABI.getDefaultInstance() : abi_; + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public org.tron.protos.Protocol.SmartContract.ABIOrBuilder getAbiOrBuilder() { + return getAbi(); + } + + public static final int BYTECODE_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString bytecode_; + /** + * bytes bytecode = 4; + */ + public com.google.protobuf.ByteString getBytecode() { + return bytecode_; + } + + public static final int CALL_VALUE_FIELD_NUMBER = 5; + private long callValue_; + /** + * int64 call_value = 5; + */ + public long getCallValue() { + return callValue_; + } + + public static final int CONSUME_USER_RESOURCE_PERCENT_FIELD_NUMBER = 6; + private long consumeUserResourcePercent_; + /** + * int64 consume_user_resource_percent = 6; + */ + public long getConsumeUserResourcePercent() { + return consumeUserResourcePercent_; + } + + public static final int NAME_FIELD_NUMBER = 7; + private volatile java.lang.Object name_; + /** + * string name = 7; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 7; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ORIGIN_ENERGY_LIMIT_FIELD_NUMBER = 8; + private long originEnergyLimit_; + /** + * int64 origin_energy_limit = 8; + */ + public long getOriginEnergyLimit() { + return originEnergyLimit_; + } + + public static final int CODE_HASH_FIELD_NUMBER = 9; + private com.google.protobuf.ByteString codeHash_; + /** + * bytes code_hash = 9; + */ + public com.google.protobuf.ByteString getCodeHash() { + return codeHash_; + } + + public static final int TRX_HASH_FIELD_NUMBER = 10; + private com.google.protobuf.ByteString trxHash_; + /** + * bytes trx_hash = 10; + */ + public com.google.protobuf.ByteString getTrxHash() { + return trxHash_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!originAddress_.isEmpty()) { + output.writeBytes(1, originAddress_); + } + if (!contractAddress_.isEmpty()) { + output.writeBytes(2, contractAddress_); + } + if (abi_ != null) { + output.writeMessage(3, getAbi()); + } + if (!bytecode_.isEmpty()) { + output.writeBytes(4, bytecode_); + } + if (callValue_ != 0L) { + output.writeInt64(5, callValue_); + } + if (consumeUserResourcePercent_ != 0L) { + output.writeInt64(6, consumeUserResourcePercent_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, name_); + } + if (originEnergyLimit_ != 0L) { + output.writeInt64(8, originEnergyLimit_); + } + if (!codeHash_.isEmpty()) { + output.writeBytes(9, codeHash_); + } + if (!trxHash_.isEmpty()) { + output.writeBytes(10, trxHash_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!originAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, originAddress_); + } + if (!contractAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, contractAddress_); + } + if (abi_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getAbi()); + } + if (!bytecode_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, bytecode_); + } + if (callValue_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, callValue_); + } + if (consumeUserResourcePercent_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, consumeUserResourcePercent_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, name_); + } + if (originEnergyLimit_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, originEnergyLimit_); + } + if (!codeHash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(9, codeHash_); + } + if (!trxHash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(10, trxHash_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.SmartContract)) { + return super.equals(obj); + } + org.tron.protos.Protocol.SmartContract other = (org.tron.protos.Protocol.SmartContract) obj; + + boolean result = true; + result = result && getOriginAddress() + .equals(other.getOriginAddress()); + result = result && getContractAddress() + .equals(other.getContractAddress()); + result = result && (hasAbi() == other.hasAbi()); + if (hasAbi()) { + result = result && getAbi() + .equals(other.getAbi()); + } + result = result && getBytecode() + .equals(other.getBytecode()); + result = result && (getCallValue() + == other.getCallValue()); + result = result && (getConsumeUserResourcePercent() + == other.getConsumeUserResourcePercent()); + result = result && getName() + .equals(other.getName()); + result = result && (getOriginEnergyLimit() + == other.getOriginEnergyLimit()); + result = result && getCodeHash() + .equals(other.getCodeHash()); + result = result && getTrxHash() + .equals(other.getTrxHash()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ORIGIN_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getOriginAddress().hashCode(); + hash = (37 * hash) + CONTRACT_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getContractAddress().hashCode(); + if (hasAbi()) { + hash = (37 * hash) + ABI_FIELD_NUMBER; + hash = (53 * hash) + getAbi().hashCode(); + } + hash = (37 * hash) + BYTECODE_FIELD_NUMBER; + hash = (53 * hash) + getBytecode().hashCode(); + hash = (37 * hash) + CALL_VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCallValue()); + hash = (37 * hash) + CONSUME_USER_RESOURCE_PERCENT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getConsumeUserResourcePercent()); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + ORIGIN_ENERGY_LIMIT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getOriginEnergyLimit()); + hash = (37 * hash) + CODE_HASH_FIELD_NUMBER; + hash = (53 * hash) + getCodeHash().hashCode(); + hash = (37 * hash) + TRX_HASH_FIELD_NUMBER; + hash = (53 * hash) + getTrxHash().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.SmartContract parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.SmartContract parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.SmartContract parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.SmartContract parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.SmartContract prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.SmartContract} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.SmartContract) + org.tron.protos.Protocol.SmartContractOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.SmartContract.class, org.tron.protos.Protocol.SmartContract.Builder.class); + } + + // Construct using org.tron.protos.Protocol.SmartContract.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + originAddress_ = com.google.protobuf.ByteString.EMPTY; + + contractAddress_ = com.google.protobuf.ByteString.EMPTY; + + if (abiBuilder_ == null) { + abi_ = null; + } else { + abi_ = null; + abiBuilder_ = null; + } + bytecode_ = com.google.protobuf.ByteString.EMPTY; + + callValue_ = 0L; + + consumeUserResourcePercent_ = 0L; + + name_ = ""; + + originEnergyLimit_ = 0L; + + codeHash_ = com.google.protobuf.ByteString.EMPTY; + + trxHash_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_SmartContract_descriptor; + } + + public org.tron.protos.Protocol.SmartContract getDefaultInstanceForType() { + return org.tron.protos.Protocol.SmartContract.getDefaultInstance(); + } + + public org.tron.protos.Protocol.SmartContract build() { + org.tron.protos.Protocol.SmartContract result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.SmartContract buildPartial() { + org.tron.protos.Protocol.SmartContract result = new org.tron.protos.Protocol.SmartContract(this); + result.originAddress_ = originAddress_; + result.contractAddress_ = contractAddress_; + if (abiBuilder_ == null) { + result.abi_ = abi_; + } else { + result.abi_ = abiBuilder_.build(); + } + result.bytecode_ = bytecode_; + result.callValue_ = callValue_; + result.consumeUserResourcePercent_ = consumeUserResourcePercent_; + result.name_ = name_; + result.originEnergyLimit_ = originEnergyLimit_; + result.codeHash_ = codeHash_; + result.trxHash_ = trxHash_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.SmartContract) { + return mergeFrom((org.tron.protos.Protocol.SmartContract)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.SmartContract other) { + if (other == org.tron.protos.Protocol.SmartContract.getDefaultInstance()) return this; + if (other.getOriginAddress() != com.google.protobuf.ByteString.EMPTY) { + setOriginAddress(other.getOriginAddress()); + } + if (other.getContractAddress() != com.google.protobuf.ByteString.EMPTY) { + setContractAddress(other.getContractAddress()); + } + if (other.hasAbi()) { + mergeAbi(other.getAbi()); + } + if (other.getBytecode() != com.google.protobuf.ByteString.EMPTY) { + setBytecode(other.getBytecode()); + } + if (other.getCallValue() != 0L) { + setCallValue(other.getCallValue()); + } + if (other.getConsumeUserResourcePercent() != 0L) { + setConsumeUserResourcePercent(other.getConsumeUserResourcePercent()); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.getOriginEnergyLimit() != 0L) { + setOriginEnergyLimit(other.getOriginEnergyLimit()); + } + if (other.getCodeHash() != com.google.protobuf.ByteString.EMPTY) { + setCodeHash(other.getCodeHash()); + } + if (other.getTrxHash() != com.google.protobuf.ByteString.EMPTY) { + setTrxHash(other.getTrxHash()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.SmartContract parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.SmartContract) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString originAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes origin_address = 1; + */ + public com.google.protobuf.ByteString getOriginAddress() { + return originAddress_; + } + /** + * bytes origin_address = 1; + */ + public Builder setOriginAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + originAddress_ = value; + onChanged(); + return this; + } + /** + * bytes origin_address = 1; + */ + public Builder clearOriginAddress() { + + originAddress_ = getDefaultInstance().getOriginAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString contractAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes contract_address = 2; + */ + public com.google.protobuf.ByteString getContractAddress() { + return contractAddress_; + } + /** + * bytes contract_address = 2; + */ + public Builder setContractAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + contractAddress_ = value; + onChanged(); + return this; + } + /** + * bytes contract_address = 2; + */ + public Builder clearContractAddress() { + + contractAddress_ = getDefaultInstance().getContractAddress(); + onChanged(); + return this; + } + + private org.tron.protos.Protocol.SmartContract.ABI abi_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI, org.tron.protos.Protocol.SmartContract.ABI.Builder, org.tron.protos.Protocol.SmartContract.ABIOrBuilder> abiBuilder_; + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public boolean hasAbi() { + return abiBuilder_ != null || abi_ != null; + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public org.tron.protos.Protocol.SmartContract.ABI getAbi() { + if (abiBuilder_ == null) { + return abi_ == null ? org.tron.protos.Protocol.SmartContract.ABI.getDefaultInstance() : abi_; + } else { + return abiBuilder_.getMessage(); + } + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public Builder setAbi(org.tron.protos.Protocol.SmartContract.ABI value) { + if (abiBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + abi_ = value; + onChanged(); + } else { + abiBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public Builder setAbi( + org.tron.protos.Protocol.SmartContract.ABI.Builder builderForValue) { + if (abiBuilder_ == null) { + abi_ = builderForValue.build(); + onChanged(); + } else { + abiBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public Builder mergeAbi(org.tron.protos.Protocol.SmartContract.ABI value) { + if (abiBuilder_ == null) { + if (abi_ != null) { + abi_ = + org.tron.protos.Protocol.SmartContract.ABI.newBuilder(abi_).mergeFrom(value).buildPartial(); + } else { + abi_ = value; + } + onChanged(); + } else { + abiBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public Builder clearAbi() { + if (abiBuilder_ == null) { + abi_ = null; + onChanged(); + } else { + abi_ = null; + abiBuilder_ = null; + } + + return this; + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public org.tron.protos.Protocol.SmartContract.ABI.Builder getAbiBuilder() { + + onChanged(); + return getAbiFieldBuilder().getBuilder(); + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + public org.tron.protos.Protocol.SmartContract.ABIOrBuilder getAbiOrBuilder() { + if (abiBuilder_ != null) { + return abiBuilder_.getMessageOrBuilder(); + } else { + return abi_ == null ? + org.tron.protos.Protocol.SmartContract.ABI.getDefaultInstance() : abi_; + } + } + /** + * .protocol.SmartContract.ABI abi = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI, org.tron.protos.Protocol.SmartContract.ABI.Builder, org.tron.protos.Protocol.SmartContract.ABIOrBuilder> + getAbiFieldBuilder() { + if (abiBuilder_ == null) { + abiBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.SmartContract.ABI, org.tron.protos.Protocol.SmartContract.ABI.Builder, org.tron.protos.Protocol.SmartContract.ABIOrBuilder>( + getAbi(), + getParentForChildren(), + isClean()); + abi_ = null; + } + return abiBuilder_; + } + + private com.google.protobuf.ByteString bytecode_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes bytecode = 4; + */ + public com.google.protobuf.ByteString getBytecode() { + return bytecode_; + } + /** + * bytes bytecode = 4; + */ + public Builder setBytecode(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + bytecode_ = value; + onChanged(); + return this; + } + /** + * bytes bytecode = 4; + */ + public Builder clearBytecode() { + + bytecode_ = getDefaultInstance().getBytecode(); + onChanged(); + return this; + } + + private long callValue_ ; + /** + * int64 call_value = 5; + */ + public long getCallValue() { + return callValue_; + } + /** + * int64 call_value = 5; + */ + public Builder setCallValue(long value) { + + callValue_ = value; + onChanged(); + return this; + } + /** + * int64 call_value = 5; + */ + public Builder clearCallValue() { + + callValue_ = 0L; + onChanged(); + return this; + } + + private long consumeUserResourcePercent_ ; + /** + * int64 consume_user_resource_percent = 6; + */ + public long getConsumeUserResourcePercent() { + return consumeUserResourcePercent_; + } + /** + * int64 consume_user_resource_percent = 6; + */ + public Builder setConsumeUserResourcePercent(long value) { + + consumeUserResourcePercent_ = value; + onChanged(); + return this; + } + /** + * int64 consume_user_resource_percent = 6; + */ + public Builder clearConsumeUserResourcePercent() { + + consumeUserResourcePercent_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 7; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 7; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 7; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 7; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 7; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private long originEnergyLimit_ ; + /** + * int64 origin_energy_limit = 8; + */ + public long getOriginEnergyLimit() { + return originEnergyLimit_; + } + /** + * int64 origin_energy_limit = 8; + */ + public Builder setOriginEnergyLimit(long value) { + + originEnergyLimit_ = value; + onChanged(); + return this; + } + /** + * int64 origin_energy_limit = 8; + */ + public Builder clearOriginEnergyLimit() { + + originEnergyLimit_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString codeHash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes code_hash = 9; + */ + public com.google.protobuf.ByteString getCodeHash() { + return codeHash_; + } + /** + * bytes code_hash = 9; + */ + public Builder setCodeHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + codeHash_ = value; + onChanged(); + return this; + } + /** + * bytes code_hash = 9; + */ + public Builder clearCodeHash() { + + codeHash_ = getDefaultInstance().getCodeHash(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString trxHash_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes trx_hash = 10; + */ + public com.google.protobuf.ByteString getTrxHash() { + return trxHash_; + } + /** + * bytes trx_hash = 10; + */ + public Builder setTrxHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + trxHash_ = value; + onChanged(); + return this; + } + /** + * bytes trx_hash = 10; + */ + public Builder clearTrxHash() { + + trxHash_ = getDefaultInstance().getTrxHash(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.SmartContract) + } + + // @@protoc_insertion_point(class_scope:protocol.SmartContract) + private static final org.tron.protos.Protocol.SmartContract DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.SmartContract(); + } + + public static org.tron.protos.Protocol.SmartContract getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public SmartContract parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SmartContract(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.SmartContract getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface InternalTransactionOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.InternalTransaction) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * internalTransaction identity, the root InternalTransaction hash
+     * should equals to root transaction id.
+     * 
+ * + * bytes hash = 1; + */ + com.google.protobuf.ByteString getHash(); + + /** + *
+     * the one send trx (TBD: or token) via function
+     * 
+ * + * bytes caller_address = 2; + */ + com.google.protobuf.ByteString getCallerAddress(); + + /** + *
+     * the one recieve trx (TBD: or token) via function
+     * 
+ * + * bytes transferTo_address = 3; + */ + com.google.protobuf.ByteString getTransferToAddress(); + + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + java.util.List + getCallValueInfoList(); + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + org.tron.protos.Protocol.InternalTransaction.CallValueInfo getCallValueInfo(int index); + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + int getCallValueInfoCount(); + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + java.util.List + getCallValueInfoOrBuilderList(); + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + org.tron.protos.Protocol.InternalTransaction.CallValueInfoOrBuilder getCallValueInfoOrBuilder( + int index); + + /** + * bytes note = 5; + */ + com.google.protobuf.ByteString getNote(); + + /** + * bool rejected = 6; + */ + boolean getRejected(); + } + /** + * Protobuf type {@code protocol.InternalTransaction} + */ + public static final class InternalTransaction extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.InternalTransaction) + InternalTransactionOrBuilder { + private static final long serialVersionUID = 0L; + // Use InternalTransaction.newBuilder() to construct. + private InternalTransaction(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private InternalTransaction() { + hash_ = com.google.protobuf.ByteString.EMPTY; + callerAddress_ = com.google.protobuf.ByteString.EMPTY; + transferToAddress_ = com.google.protobuf.ByteString.EMPTY; + callValueInfo_ = java.util.Collections.emptyList(); + note_ = com.google.protobuf.ByteString.EMPTY; + rejected_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private InternalTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + hash_ = input.readBytes(); + break; + } + case 18: { + + callerAddress_ = input.readBytes(); + break; + } + case 26: { + + transferToAddress_ = input.readBytes(); + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + callValueInfo_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + callValueInfo_.add( + input.readMessage(org.tron.protos.Protocol.InternalTransaction.CallValueInfo.parser(), extensionRegistry)); + break; + } + case 42: { + + note_ = input.readBytes(); + break; + } + case 48: { + + rejected_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + callValueInfo_ = java.util.Collections.unmodifiableList(callValueInfo_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.InternalTransaction.class, org.tron.protos.Protocol.InternalTransaction.Builder.class); + } + + public interface CallValueInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.InternalTransaction.CallValueInfo) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * trx (TBD: or token) value
+       * 
+ * + * int64 callValue = 1; + */ + long getCallValue(); + + /** + *
+       * TBD: tokenName, trx should be empty
+       * 
+ * + * string tokenId = 2; + */ + java.lang.String getTokenId(); + /** + *
+       * TBD: tokenName, trx should be empty
+       * 
+ * + * string tokenId = 2; + */ + com.google.protobuf.ByteString + getTokenIdBytes(); + } + /** + * Protobuf type {@code protocol.InternalTransaction.CallValueInfo} + */ + public static final class CallValueInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.InternalTransaction.CallValueInfo) + CallValueInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use CallValueInfo.newBuilder() to construct. + private CallValueInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private CallValueInfo() { + callValue_ = 0L; + tokenId_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CallValueInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + callValue_ = input.readInt64(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + tokenId_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_CallValueInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_CallValueInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.InternalTransaction.CallValueInfo.class, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder.class); + } + + public static final int CALLVALUE_FIELD_NUMBER = 1; + private long callValue_; + /** + *
+       * trx (TBD: or token) value
+       * 
+ * + * int64 callValue = 1; + */ + public long getCallValue() { + return callValue_; + } + + public static final int TOKENID_FIELD_NUMBER = 2; + private volatile java.lang.Object tokenId_; + /** + *
+       * TBD: tokenName, trx should be empty
+       * 
+ * + * string tokenId = 2; + */ + public java.lang.String getTokenId() { + java.lang.Object ref = tokenId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tokenId_ = s; + return s; + } + } + /** + *
+       * TBD: tokenName, trx should be empty
+       * 
+ * + * string tokenId = 2; + */ + public com.google.protobuf.ByteString + getTokenIdBytes() { + java.lang.Object ref = tokenId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tokenId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (callValue_ != 0L) { + output.writeInt64(1, callValue_); + } + if (!getTokenIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, tokenId_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (callValue_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, callValue_); + } + if (!getTokenIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, tokenId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.InternalTransaction.CallValueInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.InternalTransaction.CallValueInfo other = (org.tron.protos.Protocol.InternalTransaction.CallValueInfo) obj; + + boolean result = true; + result = result && (getCallValue() + == other.getCallValue()); + result = result && getTokenId() + .equals(other.getTokenId()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CALLVALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getCallValue()); + hash = (37 * hash) + TOKENID_FIELD_NUMBER; + hash = (53 * hash) + getTokenId().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.InternalTransaction.CallValueInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.InternalTransaction.CallValueInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.InternalTransaction.CallValueInfo) + org.tron.protos.Protocol.InternalTransaction.CallValueInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_CallValueInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_CallValueInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.InternalTransaction.CallValueInfo.class, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.InternalTransaction.CallValueInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + callValue_ = 0L; + + tokenId_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_CallValueInfo_descriptor; + } + + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.InternalTransaction.CallValueInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo build() { + org.tron.protos.Protocol.InternalTransaction.CallValueInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo buildPartial() { + org.tron.protos.Protocol.InternalTransaction.CallValueInfo result = new org.tron.protos.Protocol.InternalTransaction.CallValueInfo(this); + result.callValue_ = callValue_; + result.tokenId_ = tokenId_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.InternalTransaction.CallValueInfo) { + return mergeFrom((org.tron.protos.Protocol.InternalTransaction.CallValueInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.InternalTransaction.CallValueInfo other) { + if (other == org.tron.protos.Protocol.InternalTransaction.CallValueInfo.getDefaultInstance()) return this; + if (other.getCallValue() != 0L) { + setCallValue(other.getCallValue()); + } + if (!other.getTokenId().isEmpty()) { + tokenId_ = other.tokenId_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.InternalTransaction.CallValueInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.InternalTransaction.CallValueInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long callValue_ ; + /** + *
+         * trx (TBD: or token) value
+         * 
+ * + * int64 callValue = 1; + */ + public long getCallValue() { + return callValue_; + } + /** + *
+         * trx (TBD: or token) value
+         * 
+ * + * int64 callValue = 1; + */ + public Builder setCallValue(long value) { + + callValue_ = value; + onChanged(); + return this; + } + /** + *
+         * trx (TBD: or token) value
+         * 
+ * + * int64 callValue = 1; + */ + public Builder clearCallValue() { + + callValue_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object tokenId_ = ""; + /** + *
+         * TBD: tokenName, trx should be empty
+         * 
+ * + * string tokenId = 2; + */ + public java.lang.String getTokenId() { + java.lang.Object ref = tokenId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tokenId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+         * TBD: tokenName, trx should be empty
+         * 
+ * + * string tokenId = 2; + */ + public com.google.protobuf.ByteString + getTokenIdBytes() { + java.lang.Object ref = tokenId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tokenId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+         * TBD: tokenName, trx should be empty
+         * 
+ * + * string tokenId = 2; + */ + public Builder setTokenId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + tokenId_ = value; + onChanged(); + return this; + } + /** + *
+         * TBD: tokenName, trx should be empty
+         * 
+ * + * string tokenId = 2; + */ + public Builder clearTokenId() { + + tokenId_ = getDefaultInstance().getTokenId(); + onChanged(); + return this; + } + /** + *
+         * TBD: tokenName, trx should be empty
+         * 
+ * + * string tokenId = 2; + */ + public Builder setTokenIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tokenId_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.InternalTransaction.CallValueInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.InternalTransaction.CallValueInfo) + private static final org.tron.protos.Protocol.InternalTransaction.CallValueInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.InternalTransaction.CallValueInfo(); + } + + public static org.tron.protos.Protocol.InternalTransaction.CallValueInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CallValueInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CallValueInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int HASH_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString hash_; + /** + *
+     * internalTransaction identity, the root InternalTransaction hash
+     * should equals to root transaction id.
+     * 
+ * + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + + public static final int CALLER_ADDRESS_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString callerAddress_; + /** + *
+     * the one send trx (TBD: or token) via function
+     * 
+ * + * bytes caller_address = 2; + */ + public com.google.protobuf.ByteString getCallerAddress() { + return callerAddress_; + } + + public static final int TRANSFERTO_ADDRESS_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString transferToAddress_; + /** + *
+     * the one recieve trx (TBD: or token) via function
+     * 
+ * + * bytes transferTo_address = 3; + */ + public com.google.protobuf.ByteString getTransferToAddress() { + return transferToAddress_; + } + + public static final int CALLVALUEINFO_FIELD_NUMBER = 4; + private java.util.List callValueInfo_; + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public java.util.List getCallValueInfoList() { + return callValueInfo_; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public java.util.List + getCallValueInfoOrBuilderList() { + return callValueInfo_; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public int getCallValueInfoCount() { + return callValueInfo_.size(); + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo getCallValueInfo(int index) { + return callValueInfo_.get(index); + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public org.tron.protos.Protocol.InternalTransaction.CallValueInfoOrBuilder getCallValueInfoOrBuilder( + int index) { + return callValueInfo_.get(index); + } + + public static final int NOTE_FIELD_NUMBER = 5; + private com.google.protobuf.ByteString note_; + /** + * bytes note = 5; + */ + public com.google.protobuf.ByteString getNote() { + return note_; + } + + public static final int REJECTED_FIELD_NUMBER = 6; + private boolean rejected_; + /** + * bool rejected = 6; + */ + public boolean getRejected() { + return rejected_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!hash_.isEmpty()) { + output.writeBytes(1, hash_); + } + if (!callerAddress_.isEmpty()) { + output.writeBytes(2, callerAddress_); + } + if (!transferToAddress_.isEmpty()) { + output.writeBytes(3, transferToAddress_); + } + for (int i = 0; i < callValueInfo_.size(); i++) { + output.writeMessage(4, callValueInfo_.get(i)); + } + if (!note_.isEmpty()) { + output.writeBytes(5, note_); + } + if (rejected_ != false) { + output.writeBool(6, rejected_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!hash_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, hash_); + } + if (!callerAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, callerAddress_); + } + if (!transferToAddress_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, transferToAddress_); + } + for (int i = 0; i < callValueInfo_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, callValueInfo_.get(i)); + } + if (!note_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(5, note_); + } + if (rejected_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(6, rejected_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.InternalTransaction)) { + return super.equals(obj); + } + org.tron.protos.Protocol.InternalTransaction other = (org.tron.protos.Protocol.InternalTransaction) obj; + + boolean result = true; + result = result && getHash() + .equals(other.getHash()); + result = result && getCallerAddress() + .equals(other.getCallerAddress()); + result = result && getTransferToAddress() + .equals(other.getTransferToAddress()); + result = result && getCallValueInfoList() + .equals(other.getCallValueInfoList()); + result = result && getNote() + .equals(other.getNote()); + result = result && (getRejected() + == other.getRejected()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + HASH_FIELD_NUMBER; + hash = (53 * hash) + getHash().hashCode(); + hash = (37 * hash) + CALLER_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getCallerAddress().hashCode(); + hash = (37 * hash) + TRANSFERTO_ADDRESS_FIELD_NUMBER; + hash = (53 * hash) + getTransferToAddress().hashCode(); + if (getCallValueInfoCount() > 0) { + hash = (37 * hash) + CALLVALUEINFO_FIELD_NUMBER; + hash = (53 * hash) + getCallValueInfoList().hashCode(); + } + hash = (37 * hash) + NOTE_FIELD_NUMBER; + hash = (53 * hash) + getNote().hashCode(); + hash = (37 * hash) + REJECTED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getRejected()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.InternalTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.InternalTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.InternalTransaction prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.InternalTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.InternalTransaction) + org.tron.protos.Protocol.InternalTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.InternalTransaction.class, org.tron.protos.Protocol.InternalTransaction.Builder.class); + } + + // Construct using org.tron.protos.Protocol.InternalTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getCallValueInfoFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + hash_ = com.google.protobuf.ByteString.EMPTY; + + callerAddress_ = com.google.protobuf.ByteString.EMPTY; + + transferToAddress_ = com.google.protobuf.ByteString.EMPTY; + + if (callValueInfoBuilder_ == null) { + callValueInfo_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + callValueInfoBuilder_.clear(); + } + note_ = com.google.protobuf.ByteString.EMPTY; + + rejected_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_InternalTransaction_descriptor; + } + + public org.tron.protos.Protocol.InternalTransaction getDefaultInstanceForType() { + return org.tron.protos.Protocol.InternalTransaction.getDefaultInstance(); + } + + public org.tron.protos.Protocol.InternalTransaction build() { + org.tron.protos.Protocol.InternalTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.InternalTransaction buildPartial() { + org.tron.protos.Protocol.InternalTransaction result = new org.tron.protos.Protocol.InternalTransaction(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.hash_ = hash_; + result.callerAddress_ = callerAddress_; + result.transferToAddress_ = transferToAddress_; + if (callValueInfoBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + callValueInfo_ = java.util.Collections.unmodifiableList(callValueInfo_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.callValueInfo_ = callValueInfo_; + } else { + result.callValueInfo_ = callValueInfoBuilder_.build(); + } + result.note_ = note_; + result.rejected_ = rejected_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.InternalTransaction) { + return mergeFrom((org.tron.protos.Protocol.InternalTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.InternalTransaction other) { + if (other == org.tron.protos.Protocol.InternalTransaction.getDefaultInstance()) return this; + if (other.getHash() != com.google.protobuf.ByteString.EMPTY) { + setHash(other.getHash()); + } + if (other.getCallerAddress() != com.google.protobuf.ByteString.EMPTY) { + setCallerAddress(other.getCallerAddress()); + } + if (other.getTransferToAddress() != com.google.protobuf.ByteString.EMPTY) { + setTransferToAddress(other.getTransferToAddress()); + } + if (callValueInfoBuilder_ == null) { + if (!other.callValueInfo_.isEmpty()) { + if (callValueInfo_.isEmpty()) { + callValueInfo_ = other.callValueInfo_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureCallValueInfoIsMutable(); + callValueInfo_.addAll(other.callValueInfo_); + } + onChanged(); + } + } else { + if (!other.callValueInfo_.isEmpty()) { + if (callValueInfoBuilder_.isEmpty()) { + callValueInfoBuilder_.dispose(); + callValueInfoBuilder_ = null; + callValueInfo_ = other.callValueInfo_; + bitField0_ = (bitField0_ & ~0x00000008); + callValueInfoBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getCallValueInfoFieldBuilder() : null; + } else { + callValueInfoBuilder_.addAllMessages(other.callValueInfo_); + } + } + } + if (other.getNote() != com.google.protobuf.ByteString.EMPTY) { + setNote(other.getNote()); + } + if (other.getRejected() != false) { + setRejected(other.getRejected()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.InternalTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.InternalTransaction) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString hash_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * internalTransaction identity, the root InternalTransaction hash
+       * should equals to root transaction id.
+       * 
+ * + * bytes hash = 1; + */ + public com.google.protobuf.ByteString getHash() { + return hash_; + } + /** + *
+       * internalTransaction identity, the root InternalTransaction hash
+       * should equals to root transaction id.
+       * 
+ * + * bytes hash = 1; + */ + public Builder setHash(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + hash_ = value; + onChanged(); + return this; + } + /** + *
+       * internalTransaction identity, the root InternalTransaction hash
+       * should equals to root transaction id.
+       * 
+ * + * bytes hash = 1; + */ + public Builder clearHash() { + + hash_ = getDefaultInstance().getHash(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString callerAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * the one send trx (TBD: or token) via function
+       * 
+ * + * bytes caller_address = 2; + */ + public com.google.protobuf.ByteString getCallerAddress() { + return callerAddress_; + } + /** + *
+       * the one send trx (TBD: or token) via function
+       * 
+ * + * bytes caller_address = 2; + */ + public Builder setCallerAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + callerAddress_ = value; + onChanged(); + return this; + } + /** + *
+       * the one send trx (TBD: or token) via function
+       * 
+ * + * bytes caller_address = 2; + */ + public Builder clearCallerAddress() { + + callerAddress_ = getDefaultInstance().getCallerAddress(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString transferToAddress_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * the one recieve trx (TBD: or token) via function
+       * 
+ * + * bytes transferTo_address = 3; + */ + public com.google.protobuf.ByteString getTransferToAddress() { + return transferToAddress_; + } + /** + *
+       * the one recieve trx (TBD: or token) via function
+       * 
+ * + * bytes transferTo_address = 3; + */ + public Builder setTransferToAddress(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + transferToAddress_ = value; + onChanged(); + return this; + } + /** + *
+       * the one recieve trx (TBD: or token) via function
+       * 
+ * + * bytes transferTo_address = 3; + */ + public Builder clearTransferToAddress() { + + transferToAddress_ = getDefaultInstance().getTransferToAddress(); + onChanged(); + return this; + } + + private java.util.List callValueInfo_ = + java.util.Collections.emptyList(); + private void ensureCallValueInfoIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + callValueInfo_ = new java.util.ArrayList(callValueInfo_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.InternalTransaction.CallValueInfo, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder, org.tron.protos.Protocol.InternalTransaction.CallValueInfoOrBuilder> callValueInfoBuilder_; + + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public java.util.List getCallValueInfoList() { + if (callValueInfoBuilder_ == null) { + return java.util.Collections.unmodifiableList(callValueInfo_); + } else { + return callValueInfoBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public int getCallValueInfoCount() { + if (callValueInfoBuilder_ == null) { + return callValueInfo_.size(); + } else { + return callValueInfoBuilder_.getCount(); + } + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo getCallValueInfo(int index) { + if (callValueInfoBuilder_ == null) { + return callValueInfo_.get(index); + } else { + return callValueInfoBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder setCallValueInfo( + int index, org.tron.protos.Protocol.InternalTransaction.CallValueInfo value) { + if (callValueInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureCallValueInfoIsMutable(); + callValueInfo_.set(index, value); + onChanged(); + } else { + callValueInfoBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder setCallValueInfo( + int index, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder builderForValue) { + if (callValueInfoBuilder_ == null) { + ensureCallValueInfoIsMutable(); + callValueInfo_.set(index, builderForValue.build()); + onChanged(); + } else { + callValueInfoBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder addCallValueInfo(org.tron.protos.Protocol.InternalTransaction.CallValueInfo value) { + if (callValueInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureCallValueInfoIsMutable(); + callValueInfo_.add(value); + onChanged(); + } else { + callValueInfoBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder addCallValueInfo( + int index, org.tron.protos.Protocol.InternalTransaction.CallValueInfo value) { + if (callValueInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureCallValueInfoIsMutable(); + callValueInfo_.add(index, value); + onChanged(); + } else { + callValueInfoBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder addCallValueInfo( + org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder builderForValue) { + if (callValueInfoBuilder_ == null) { + ensureCallValueInfoIsMutable(); + callValueInfo_.add(builderForValue.build()); + onChanged(); + } else { + callValueInfoBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder addCallValueInfo( + int index, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder builderForValue) { + if (callValueInfoBuilder_ == null) { + ensureCallValueInfoIsMutable(); + callValueInfo_.add(index, builderForValue.build()); + onChanged(); + } else { + callValueInfoBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder addAllCallValueInfo( + java.lang.Iterable values) { + if (callValueInfoBuilder_ == null) { + ensureCallValueInfoIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, callValueInfo_); + onChanged(); + } else { + callValueInfoBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder clearCallValueInfo() { + if (callValueInfoBuilder_ == null) { + callValueInfo_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + callValueInfoBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public Builder removeCallValueInfo(int index) { + if (callValueInfoBuilder_ == null) { + ensureCallValueInfoIsMutable(); + callValueInfo_.remove(index); + onChanged(); + } else { + callValueInfoBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder getCallValueInfoBuilder( + int index) { + return getCallValueInfoFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public org.tron.protos.Protocol.InternalTransaction.CallValueInfoOrBuilder getCallValueInfoOrBuilder( + int index) { + if (callValueInfoBuilder_ == null) { + return callValueInfo_.get(index); } else { + return callValueInfoBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public java.util.List + getCallValueInfoOrBuilderList() { + if (callValueInfoBuilder_ != null) { + return callValueInfoBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(callValueInfo_); + } + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder addCallValueInfoBuilder() { + return getCallValueInfoFieldBuilder().addBuilder( + org.tron.protos.Protocol.InternalTransaction.CallValueInfo.getDefaultInstance()); + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder addCallValueInfoBuilder( + int index) { + return getCallValueInfoFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.getDefaultInstance()); + } + /** + * repeated .protocol.InternalTransaction.CallValueInfo callValueInfo = 4; + */ + public java.util.List + getCallValueInfoBuilderList() { + return getCallValueInfoFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.InternalTransaction.CallValueInfo, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder, org.tron.protos.Protocol.InternalTransaction.CallValueInfoOrBuilder> + getCallValueInfoFieldBuilder() { + if (callValueInfoBuilder_ == null) { + callValueInfoBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.InternalTransaction.CallValueInfo, org.tron.protos.Protocol.InternalTransaction.CallValueInfo.Builder, org.tron.protos.Protocol.InternalTransaction.CallValueInfoOrBuilder>( + callValueInfo_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + callValueInfo_ = null; + } + return callValueInfoBuilder_; + } + + private com.google.protobuf.ByteString note_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes note = 5; + */ + public com.google.protobuf.ByteString getNote() { + return note_; + } + /** + * bytes note = 5; + */ + public Builder setNote(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + note_ = value; + onChanged(); + return this; + } + /** + * bytes note = 5; + */ + public Builder clearNote() { + + note_ = getDefaultInstance().getNote(); + onChanged(); + return this; + } + + private boolean rejected_ ; + /** + * bool rejected = 6; + */ + public boolean getRejected() { + return rejected_; + } + /** + * bool rejected = 6; + */ + public Builder setRejected(boolean value) { + + rejected_ = value; + onChanged(); + return this; + } + /** + * bool rejected = 6; + */ + public Builder clearRejected() { + + rejected_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.InternalTransaction) + } + + // @@protoc_insertion_point(class_scope:protocol.InternalTransaction) + private static final org.tron.protos.Protocol.InternalTransaction DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.InternalTransaction(); + } + + public static org.tron.protos.Protocol.InternalTransaction getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public InternalTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new InternalTransaction(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.InternalTransaction getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DelegatedResourceAccountIndexOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.DelegatedResourceAccountIndex) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes account = 1; + */ + com.google.protobuf.ByteString getAccount(); + + /** + * repeated bytes fromAccounts = 2; + */ + java.util.List getFromAccountsList(); + /** + * repeated bytes fromAccounts = 2; + */ + int getFromAccountsCount(); + /** + * repeated bytes fromAccounts = 2; + */ + com.google.protobuf.ByteString getFromAccounts(int index); + + /** + * repeated bytes toAccounts = 3; + */ + java.util.List getToAccountsList(); + /** + * repeated bytes toAccounts = 3; + */ + int getToAccountsCount(); + /** + * repeated bytes toAccounts = 3; + */ + com.google.protobuf.ByteString getToAccounts(int index); + } + /** + * Protobuf type {@code protocol.DelegatedResourceAccountIndex} + */ + public static final class DelegatedResourceAccountIndex extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.DelegatedResourceAccountIndex) + DelegatedResourceAccountIndexOrBuilder { + private static final long serialVersionUID = 0L; + // Use DelegatedResourceAccountIndex.newBuilder() to construct. + private DelegatedResourceAccountIndex(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DelegatedResourceAccountIndex() { + account_ = com.google.protobuf.ByteString.EMPTY; + fromAccounts_ = java.util.Collections.emptyList(); + toAccounts_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DelegatedResourceAccountIndex( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + account_ = input.readBytes(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + fromAccounts_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + fromAccounts_.add(input.readBytes()); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + toAccounts_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + toAccounts_.add(input.readBytes()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + fromAccounts_ = java.util.Collections.unmodifiableList(fromAccounts_); + } + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + toAccounts_ = java.util.Collections.unmodifiableList(toAccounts_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResourceAccountIndex_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResourceAccountIndex_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DelegatedResourceAccountIndex.class, org.tron.protos.Protocol.DelegatedResourceAccountIndex.Builder.class); + } + + private int bitField0_; + public static final int ACCOUNT_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString account_; + /** + * bytes account = 1; + */ + public com.google.protobuf.ByteString getAccount() { + return account_; + } + + public static final int FROMACCOUNTS_FIELD_NUMBER = 2; + private java.util.List fromAccounts_; + /** + * repeated bytes fromAccounts = 2; + */ + public java.util.List + getFromAccountsList() { + return fromAccounts_; + } + /** + * repeated bytes fromAccounts = 2; + */ + public int getFromAccountsCount() { + return fromAccounts_.size(); + } + /** + * repeated bytes fromAccounts = 2; + */ + public com.google.protobuf.ByteString getFromAccounts(int index) { + return fromAccounts_.get(index); + } + + public static final int TOACCOUNTS_FIELD_NUMBER = 3; + private java.util.List toAccounts_; + /** + * repeated bytes toAccounts = 3; + */ + public java.util.List + getToAccountsList() { + return toAccounts_; + } + /** + * repeated bytes toAccounts = 3; + */ + public int getToAccountsCount() { + return toAccounts_.size(); + } + /** + * repeated bytes toAccounts = 3; + */ + public com.google.protobuf.ByteString getToAccounts(int index) { + return toAccounts_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!account_.isEmpty()) { + output.writeBytes(1, account_); + } + for (int i = 0; i < fromAccounts_.size(); i++) { + output.writeBytes(2, fromAccounts_.get(i)); + } + for (int i = 0; i < toAccounts_.size(); i++) { + output.writeBytes(3, toAccounts_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!account_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, account_); + } + { + int dataSize = 0; + for (int i = 0; i < fromAccounts_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(fromAccounts_.get(i)); + } + size += dataSize; + size += 1 * getFromAccountsList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < toAccounts_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(toAccounts_.get(i)); + } + size += dataSize; + size += 1 * getToAccountsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.DelegatedResourceAccountIndex)) { + return super.equals(obj); + } + org.tron.protos.Protocol.DelegatedResourceAccountIndex other = (org.tron.protos.Protocol.DelegatedResourceAccountIndex) obj; + + boolean result = true; + result = result && getAccount() + .equals(other.getAccount()); + result = result && getFromAccountsList() + .equals(other.getFromAccountsList()); + result = result && getToAccountsList() + .equals(other.getToAccountsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ACCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getAccount().hashCode(); + if (getFromAccountsCount() > 0) { + hash = (37 * hash) + FROMACCOUNTS_FIELD_NUMBER; + hash = (53 * hash) + getFromAccountsList().hashCode(); + } + if (getToAccountsCount() > 0) { + hash = (37 * hash) + TOACCOUNTS_FIELD_NUMBER; + hash = (53 * hash) + getToAccountsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.DelegatedResourceAccountIndex prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.DelegatedResourceAccountIndex} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.DelegatedResourceAccountIndex) + org.tron.protos.Protocol.DelegatedResourceAccountIndexOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResourceAccountIndex_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResourceAccountIndex_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.DelegatedResourceAccountIndex.class, org.tron.protos.Protocol.DelegatedResourceAccountIndex.Builder.class); + } + + // Construct using org.tron.protos.Protocol.DelegatedResourceAccountIndex.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + account_ = com.google.protobuf.ByteString.EMPTY; + + fromAccounts_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + toAccounts_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_DelegatedResourceAccountIndex_descriptor; + } + + public org.tron.protos.Protocol.DelegatedResourceAccountIndex getDefaultInstanceForType() { + return org.tron.protos.Protocol.DelegatedResourceAccountIndex.getDefaultInstance(); + } + + public org.tron.protos.Protocol.DelegatedResourceAccountIndex build() { + org.tron.protos.Protocol.DelegatedResourceAccountIndex result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.DelegatedResourceAccountIndex buildPartial() { + org.tron.protos.Protocol.DelegatedResourceAccountIndex result = new org.tron.protos.Protocol.DelegatedResourceAccountIndex(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.account_ = account_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + fromAccounts_ = java.util.Collections.unmodifiableList(fromAccounts_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.fromAccounts_ = fromAccounts_; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + toAccounts_ = java.util.Collections.unmodifiableList(toAccounts_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.toAccounts_ = toAccounts_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.DelegatedResourceAccountIndex) { + return mergeFrom((org.tron.protos.Protocol.DelegatedResourceAccountIndex)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.DelegatedResourceAccountIndex other) { + if (other == org.tron.protos.Protocol.DelegatedResourceAccountIndex.getDefaultInstance()) return this; + if (other.getAccount() != com.google.protobuf.ByteString.EMPTY) { + setAccount(other.getAccount()); + } + if (!other.fromAccounts_.isEmpty()) { + if (fromAccounts_.isEmpty()) { + fromAccounts_ = other.fromAccounts_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureFromAccountsIsMutable(); + fromAccounts_.addAll(other.fromAccounts_); + } + onChanged(); + } + if (!other.toAccounts_.isEmpty()) { + if (toAccounts_.isEmpty()) { + toAccounts_ = other.toAccounts_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureToAccountsIsMutable(); + toAccounts_.addAll(other.toAccounts_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.DelegatedResourceAccountIndex parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.DelegatedResourceAccountIndex) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString account_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes account = 1; + */ + public com.google.protobuf.ByteString getAccount() { + return account_; + } + /** + * bytes account = 1; + */ + public Builder setAccount(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + account_ = value; + onChanged(); + return this; + } + /** + * bytes account = 1; + */ + public Builder clearAccount() { + + account_ = getDefaultInstance().getAccount(); + onChanged(); + return this; + } + + private java.util.List fromAccounts_ = java.util.Collections.emptyList(); + private void ensureFromAccountsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + fromAccounts_ = new java.util.ArrayList(fromAccounts_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes fromAccounts = 2; + */ + public java.util.List + getFromAccountsList() { + return java.util.Collections.unmodifiableList(fromAccounts_); + } + /** + * repeated bytes fromAccounts = 2; + */ + public int getFromAccountsCount() { + return fromAccounts_.size(); + } + /** + * repeated bytes fromAccounts = 2; + */ + public com.google.protobuf.ByteString getFromAccounts(int index) { + return fromAccounts_.get(index); + } + /** + * repeated bytes fromAccounts = 2; + */ + public Builder setFromAccounts( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureFromAccountsIsMutable(); + fromAccounts_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes fromAccounts = 2; + */ + public Builder addFromAccounts(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureFromAccountsIsMutable(); + fromAccounts_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes fromAccounts = 2; + */ + public Builder addAllFromAccounts( + java.lang.Iterable values) { + ensureFromAccountsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, fromAccounts_); + onChanged(); + return this; + } + /** + * repeated bytes fromAccounts = 2; + */ + public Builder clearFromAccounts() { + fromAccounts_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private java.util.List toAccounts_ = java.util.Collections.emptyList(); + private void ensureToAccountsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + toAccounts_ = new java.util.ArrayList(toAccounts_); + bitField0_ |= 0x00000004; + } + } + /** + * repeated bytes toAccounts = 3; + */ + public java.util.List + getToAccountsList() { + return java.util.Collections.unmodifiableList(toAccounts_); + } + /** + * repeated bytes toAccounts = 3; + */ + public int getToAccountsCount() { + return toAccounts_.size(); + } + /** + * repeated bytes toAccounts = 3; + */ + public com.google.protobuf.ByteString getToAccounts(int index) { + return toAccounts_.get(index); + } + /** + * repeated bytes toAccounts = 3; + */ + public Builder setToAccounts( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureToAccountsIsMutable(); + toAccounts_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes toAccounts = 3; + */ + public Builder addToAccounts(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureToAccountsIsMutable(); + toAccounts_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes toAccounts = 3; + */ + public Builder addAllToAccounts( + java.lang.Iterable values) { + ensureToAccountsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, toAccounts_); + onChanged(); + return this; + } + /** + * repeated bytes toAccounts = 3; + */ + public Builder clearToAccounts() { + toAccounts_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.DelegatedResourceAccountIndex) + } + + // @@protoc_insertion_point(class_scope:protocol.DelegatedResourceAccountIndex) + private static final org.tron.protos.Protocol.DelegatedResourceAccountIndex DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.DelegatedResourceAccountIndex(); + } + + public static org.tron.protos.Protocol.DelegatedResourceAccountIndex getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DelegatedResourceAccountIndex parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DelegatedResourceAccountIndex(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.DelegatedResourceAccountIndex getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface NodeInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NodeInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 beginSyncNum = 1; + */ + long getBeginSyncNum(); + + /** + * string block = 2; + */ + java.lang.String getBlock(); + /** + * string block = 2; + */ + com.google.protobuf.ByteString + getBlockBytes(); + + /** + * string solidityBlock = 3; + */ + java.lang.String getSolidityBlock(); + /** + * string solidityBlock = 3; + */ + com.google.protobuf.ByteString + getSolidityBlockBytes(); + + /** + *
+     *connect information
+     * 
+ * + * int32 currentConnectCount = 4; + */ + int getCurrentConnectCount(); + + /** + * int32 activeConnectCount = 5; + */ + int getActiveConnectCount(); + + /** + * int32 passiveConnectCount = 6; + */ + int getPassiveConnectCount(); + + /** + * int64 totalFlow = 7; + */ + long getTotalFlow(); + + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + java.util.List + getPeerInfoListList(); + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + org.tron.protos.Protocol.NodeInfo.PeerInfo getPeerInfoList(int index); + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + int getPeerInfoListCount(); + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + java.util.List + getPeerInfoListOrBuilderList(); + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + org.tron.protos.Protocol.NodeInfo.PeerInfoOrBuilder getPeerInfoListOrBuilder( + int index); + + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + boolean hasConfigNodeInfo(); + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo getConfigNodeInfo(); + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfoOrBuilder getConfigNodeInfoOrBuilder(); + + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + boolean hasMachineInfo(); + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + org.tron.protos.Protocol.NodeInfo.MachineInfo getMachineInfo(); + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + org.tron.protos.Protocol.NodeInfo.MachineInfoOrBuilder getMachineInfoOrBuilder(); + + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + int getCheatWitnessInfoMapCount(); + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + boolean containsCheatWitnessInfoMap( + java.lang.String key); + /** + * Use {@link #getCheatWitnessInfoMapMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getCheatWitnessInfoMap(); + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + java.util.Map + getCheatWitnessInfoMapMap(); + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + java.lang.String getCheatWitnessInfoMapOrDefault( + java.lang.String key, + java.lang.String defaultValue); + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + java.lang.String getCheatWitnessInfoMapOrThrow( + java.lang.String key); + } + /** + * Protobuf type {@code protocol.NodeInfo} + */ + public static final class NodeInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NodeInfo) + NodeInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use NodeInfo.newBuilder() to construct. + private NodeInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NodeInfo() { + beginSyncNum_ = 0L; + block_ = ""; + solidityBlock_ = ""; + currentConnectCount_ = 0; + activeConnectCount_ = 0; + passiveConnectCount_ = 0; + totalFlow_ = 0L; + peerInfoList_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NodeInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + beginSyncNum_ = input.readInt64(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + block_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + solidityBlock_ = s; + break; + } + case 32: { + + currentConnectCount_ = input.readInt32(); + break; + } + case 40: { + + activeConnectCount_ = input.readInt32(); + break; + } + case 48: { + + passiveConnectCount_ = input.readInt32(); + break; + } + case 56: { + + totalFlow_ = input.readInt64(); + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + peerInfoList_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000080; + } + peerInfoList_.add( + input.readMessage(org.tron.protos.Protocol.NodeInfo.PeerInfo.parser(), extensionRegistry)); + break; + } + case 74: { + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder subBuilder = null; + if (configNodeInfo_ != null) { + subBuilder = configNodeInfo_.toBuilder(); + } + configNodeInfo_ = input.readMessage(org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(configNodeInfo_); + configNodeInfo_ = subBuilder.buildPartial(); + } + + break; + } + case 82: { + org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder subBuilder = null; + if (machineInfo_ != null) { + subBuilder = machineInfo_.toBuilder(); + } + machineInfo_ = input.readMessage(org.tron.protos.Protocol.NodeInfo.MachineInfo.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(machineInfo_); + machineInfo_ = subBuilder.buildPartial(); + } + + break; + } + case 90: { + if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + cheatWitnessInfoMap_ = com.google.protobuf.MapField.newMapField( + CheatWitnessInfoMapDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000400; + } + com.google.protobuf.MapEntry + cheatWitnessInfoMap__ = input.readMessage( + CheatWitnessInfoMapDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + cheatWitnessInfoMap_.getMutableMap().put( + cheatWitnessInfoMap__.getKey(), cheatWitnessInfoMap__.getValue()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + peerInfoList_ = java.util.Collections.unmodifiableList(peerInfoList_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 11: + return internalGetCheatWitnessInfoMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.class, org.tron.protos.Protocol.NodeInfo.Builder.class); + } + + public interface PeerInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NodeInfo.PeerInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * string lastSyncBlock = 1; + */ + java.lang.String getLastSyncBlock(); + /** + * string lastSyncBlock = 1; + */ + com.google.protobuf.ByteString + getLastSyncBlockBytes(); + + /** + * int64 remainNum = 2; + */ + long getRemainNum(); + + /** + * int64 lastBlockUpdateTime = 3; + */ + long getLastBlockUpdateTime(); + + /** + * bool syncFlag = 4; + */ + boolean getSyncFlag(); + + /** + * int64 headBlockTimeWeBothHave = 5; + */ + long getHeadBlockTimeWeBothHave(); + + /** + * bool needSyncFromPeer = 6; + */ + boolean getNeedSyncFromPeer(); + + /** + * bool needSyncFromUs = 7; + */ + boolean getNeedSyncFromUs(); + + /** + * string host = 8; + */ + java.lang.String getHost(); + /** + * string host = 8; + */ + com.google.protobuf.ByteString + getHostBytes(); + + /** + * int32 port = 9; + */ + int getPort(); + + /** + * string nodeId = 10; + */ + java.lang.String getNodeId(); + /** + * string nodeId = 10; + */ + com.google.protobuf.ByteString + getNodeIdBytes(); + + /** + * int64 connectTime = 11; + */ + long getConnectTime(); + + /** + * double avgLatency = 12; + */ + double getAvgLatency(); + + /** + * int32 syncToFetchSize = 13; + */ + int getSyncToFetchSize(); + + /** + * int64 syncToFetchSizePeekNum = 14; + */ + long getSyncToFetchSizePeekNum(); + + /** + * int32 syncBlockRequestedSize = 15; + */ + int getSyncBlockRequestedSize(); + + /** + * int64 unFetchSynNum = 16; + */ + long getUnFetchSynNum(); + + /** + * int32 blockInPorcSize = 17; + */ + int getBlockInPorcSize(); + + /** + * string headBlockWeBothHave = 18; + */ + java.lang.String getHeadBlockWeBothHave(); + /** + * string headBlockWeBothHave = 18; + */ + com.google.protobuf.ByteString + getHeadBlockWeBothHaveBytes(); + + /** + * bool isActive = 19; + */ + boolean getIsActive(); + + /** + * int32 score = 20; + */ + int getScore(); + + /** + * int32 nodeCount = 21; + */ + int getNodeCount(); + + /** + * int64 inFlow = 22; + */ + long getInFlow(); + + /** + * int32 disconnectTimes = 23; + */ + int getDisconnectTimes(); + + /** + * string localDisconnectReason = 24; + */ + java.lang.String getLocalDisconnectReason(); + /** + * string localDisconnectReason = 24; + */ + com.google.protobuf.ByteString + getLocalDisconnectReasonBytes(); + + /** + * string remoteDisconnectReason = 25; + */ + java.lang.String getRemoteDisconnectReason(); + /** + * string remoteDisconnectReason = 25; + */ + com.google.protobuf.ByteString + getRemoteDisconnectReasonBytes(); + } + /** + * Protobuf type {@code protocol.NodeInfo.PeerInfo} + */ + public static final class PeerInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NodeInfo.PeerInfo) + PeerInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use PeerInfo.newBuilder() to construct. + private PeerInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PeerInfo() { + lastSyncBlock_ = ""; + remainNum_ = 0L; + lastBlockUpdateTime_ = 0L; + syncFlag_ = false; + headBlockTimeWeBothHave_ = 0L; + needSyncFromPeer_ = false; + needSyncFromUs_ = false; + host_ = ""; + port_ = 0; + nodeId_ = ""; + connectTime_ = 0L; + avgLatency_ = 0D; + syncToFetchSize_ = 0; + syncToFetchSizePeekNum_ = 0L; + syncBlockRequestedSize_ = 0; + unFetchSynNum_ = 0L; + blockInPorcSize_ = 0; + headBlockWeBothHave_ = ""; + isActive_ = false; + score_ = 0; + nodeCount_ = 0; + inFlow_ = 0L; + disconnectTimes_ = 0; + localDisconnectReason_ = ""; + remoteDisconnectReason_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PeerInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + lastSyncBlock_ = s; + break; + } + case 16: { + + remainNum_ = input.readInt64(); + break; + } + case 24: { + + lastBlockUpdateTime_ = input.readInt64(); + break; + } + case 32: { + + syncFlag_ = input.readBool(); + break; + } + case 40: { + + headBlockTimeWeBothHave_ = input.readInt64(); + break; + } + case 48: { + + needSyncFromPeer_ = input.readBool(); + break; + } + case 56: { + + needSyncFromUs_ = input.readBool(); + break; + } + case 66: { + java.lang.String s = input.readStringRequireUtf8(); + + host_ = s; + break; + } + case 72: { + + port_ = input.readInt32(); + break; + } + case 82: { + java.lang.String s = input.readStringRequireUtf8(); + + nodeId_ = s; + break; + } + case 88: { + + connectTime_ = input.readInt64(); + break; + } + case 97: { + + avgLatency_ = input.readDouble(); + break; + } + case 104: { + + syncToFetchSize_ = input.readInt32(); + break; + } + case 112: { + + syncToFetchSizePeekNum_ = input.readInt64(); + break; + } + case 120: { + + syncBlockRequestedSize_ = input.readInt32(); + break; + } + case 128: { + + unFetchSynNum_ = input.readInt64(); + break; + } + case 136: { + + blockInPorcSize_ = input.readInt32(); + break; + } + case 146: { + java.lang.String s = input.readStringRequireUtf8(); + + headBlockWeBothHave_ = s; + break; + } + case 152: { + + isActive_ = input.readBool(); + break; + } + case 160: { + + score_ = input.readInt32(); + break; + } + case 168: { + + nodeCount_ = input.readInt32(); + break; + } + case 176: { + + inFlow_ = input.readInt64(); + break; + } + case 184: { + + disconnectTimes_ = input.readInt32(); + break; + } + case 194: { + java.lang.String s = input.readStringRequireUtf8(); + + localDisconnectReason_ = s; + break; + } + case 202: { + java.lang.String s = input.readStringRequireUtf8(); + + remoteDisconnectReason_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_PeerInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_PeerInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.PeerInfo.class, org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder.class); + } + + public static final int LASTSYNCBLOCK_FIELD_NUMBER = 1; + private volatile java.lang.Object lastSyncBlock_; + /** + * string lastSyncBlock = 1; + */ + public java.lang.String getLastSyncBlock() { + java.lang.Object ref = lastSyncBlock_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + lastSyncBlock_ = s; + return s; + } + } + /** + * string lastSyncBlock = 1; + */ + public com.google.protobuf.ByteString + getLastSyncBlockBytes() { + java.lang.Object ref = lastSyncBlock_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + lastSyncBlock_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REMAINNUM_FIELD_NUMBER = 2; + private long remainNum_; + /** + * int64 remainNum = 2; + */ + public long getRemainNum() { + return remainNum_; + } + + public static final int LASTBLOCKUPDATETIME_FIELD_NUMBER = 3; + private long lastBlockUpdateTime_; + /** + * int64 lastBlockUpdateTime = 3; + */ + public long getLastBlockUpdateTime() { + return lastBlockUpdateTime_; + } + + public static final int SYNCFLAG_FIELD_NUMBER = 4; + private boolean syncFlag_; + /** + * bool syncFlag = 4; + */ + public boolean getSyncFlag() { + return syncFlag_; + } + + public static final int HEADBLOCKTIMEWEBOTHHAVE_FIELD_NUMBER = 5; + private long headBlockTimeWeBothHave_; + /** + * int64 headBlockTimeWeBothHave = 5; + */ + public long getHeadBlockTimeWeBothHave() { + return headBlockTimeWeBothHave_; + } + + public static final int NEEDSYNCFROMPEER_FIELD_NUMBER = 6; + private boolean needSyncFromPeer_; + /** + * bool needSyncFromPeer = 6; + */ + public boolean getNeedSyncFromPeer() { + return needSyncFromPeer_; + } + + public static final int NEEDSYNCFROMUS_FIELD_NUMBER = 7; + private boolean needSyncFromUs_; + /** + * bool needSyncFromUs = 7; + */ + public boolean getNeedSyncFromUs() { + return needSyncFromUs_; + } + + public static final int HOST_FIELD_NUMBER = 8; + private volatile java.lang.Object host_; + /** + * string host = 8; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + host_ = s; + return s; + } + } + /** + * string host = 8; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PORT_FIELD_NUMBER = 9; + private int port_; + /** + * int32 port = 9; + */ + public int getPort() { + return port_; + } + + public static final int NODEID_FIELD_NUMBER = 10; + private volatile java.lang.Object nodeId_; + /** + * string nodeId = 10; + */ + public java.lang.String getNodeId() { + java.lang.Object ref = nodeId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nodeId_ = s; + return s; + } + } + /** + * string nodeId = 10; + */ + public com.google.protobuf.ByteString + getNodeIdBytes() { + java.lang.Object ref = nodeId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nodeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONNECTTIME_FIELD_NUMBER = 11; + private long connectTime_; + /** + * int64 connectTime = 11; + */ + public long getConnectTime() { + return connectTime_; + } + + public static final int AVGLATENCY_FIELD_NUMBER = 12; + private double avgLatency_; + /** + * double avgLatency = 12; + */ + public double getAvgLatency() { + return avgLatency_; + } + + public static final int SYNCTOFETCHSIZE_FIELD_NUMBER = 13; + private int syncToFetchSize_; + /** + * int32 syncToFetchSize = 13; + */ + public int getSyncToFetchSize() { + return syncToFetchSize_; + } + + public static final int SYNCTOFETCHSIZEPEEKNUM_FIELD_NUMBER = 14; + private long syncToFetchSizePeekNum_; + /** + * int64 syncToFetchSizePeekNum = 14; + */ + public long getSyncToFetchSizePeekNum() { + return syncToFetchSizePeekNum_; + } + + public static final int SYNCBLOCKREQUESTEDSIZE_FIELD_NUMBER = 15; + private int syncBlockRequestedSize_; + /** + * int32 syncBlockRequestedSize = 15; + */ + public int getSyncBlockRequestedSize() { + return syncBlockRequestedSize_; + } + + public static final int UNFETCHSYNNUM_FIELD_NUMBER = 16; + private long unFetchSynNum_; + /** + * int64 unFetchSynNum = 16; + */ + public long getUnFetchSynNum() { + return unFetchSynNum_; + } + + public static final int BLOCKINPORCSIZE_FIELD_NUMBER = 17; + private int blockInPorcSize_; + /** + * int32 blockInPorcSize = 17; + */ + public int getBlockInPorcSize() { + return blockInPorcSize_; + } + + public static final int HEADBLOCKWEBOTHHAVE_FIELD_NUMBER = 18; + private volatile java.lang.Object headBlockWeBothHave_; + /** + * string headBlockWeBothHave = 18; + */ + public java.lang.String getHeadBlockWeBothHave() { + java.lang.Object ref = headBlockWeBothHave_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + headBlockWeBothHave_ = s; + return s; + } + } + /** + * string headBlockWeBothHave = 18; + */ + public com.google.protobuf.ByteString + getHeadBlockWeBothHaveBytes() { + java.lang.Object ref = headBlockWeBothHave_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + headBlockWeBothHave_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ISACTIVE_FIELD_NUMBER = 19; + private boolean isActive_; + /** + * bool isActive = 19; + */ + public boolean getIsActive() { + return isActive_; + } + + public static final int SCORE_FIELD_NUMBER = 20; + private int score_; + /** + * int32 score = 20; + */ + public int getScore() { + return score_; + } + + public static final int NODECOUNT_FIELD_NUMBER = 21; + private int nodeCount_; + /** + * int32 nodeCount = 21; + */ + public int getNodeCount() { + return nodeCount_; + } + + public static final int INFLOW_FIELD_NUMBER = 22; + private long inFlow_; + /** + * int64 inFlow = 22; + */ + public long getInFlow() { + return inFlow_; + } + + public static final int DISCONNECTTIMES_FIELD_NUMBER = 23; + private int disconnectTimes_; + /** + * int32 disconnectTimes = 23; + */ + public int getDisconnectTimes() { + return disconnectTimes_; + } + + public static final int LOCALDISCONNECTREASON_FIELD_NUMBER = 24; + private volatile java.lang.Object localDisconnectReason_; + /** + * string localDisconnectReason = 24; + */ + public java.lang.String getLocalDisconnectReason() { + java.lang.Object ref = localDisconnectReason_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + localDisconnectReason_ = s; + return s; + } + } + /** + * string localDisconnectReason = 24; + */ + public com.google.protobuf.ByteString + getLocalDisconnectReasonBytes() { + java.lang.Object ref = localDisconnectReason_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + localDisconnectReason_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REMOTEDISCONNECTREASON_FIELD_NUMBER = 25; + private volatile java.lang.Object remoteDisconnectReason_; + /** + * string remoteDisconnectReason = 25; + */ + public java.lang.String getRemoteDisconnectReason() { + java.lang.Object ref = remoteDisconnectReason_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + remoteDisconnectReason_ = s; + return s; + } + } + /** + * string remoteDisconnectReason = 25; + */ + public com.google.protobuf.ByteString + getRemoteDisconnectReasonBytes() { + java.lang.Object ref = remoteDisconnectReason_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + remoteDisconnectReason_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getLastSyncBlockBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, lastSyncBlock_); + } + if (remainNum_ != 0L) { + output.writeInt64(2, remainNum_); + } + if (lastBlockUpdateTime_ != 0L) { + output.writeInt64(3, lastBlockUpdateTime_); + } + if (syncFlag_ != false) { + output.writeBool(4, syncFlag_); + } + if (headBlockTimeWeBothHave_ != 0L) { + output.writeInt64(5, headBlockTimeWeBothHave_); + } + if (needSyncFromPeer_ != false) { + output.writeBool(6, needSyncFromPeer_); + } + if (needSyncFromUs_ != false) { + output.writeBool(7, needSyncFromUs_); + } + if (!getHostBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, host_); + } + if (port_ != 0) { + output.writeInt32(9, port_); + } + if (!getNodeIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, nodeId_); + } + if (connectTime_ != 0L) { + output.writeInt64(11, connectTime_); + } + if (avgLatency_ != 0D) { + output.writeDouble(12, avgLatency_); + } + if (syncToFetchSize_ != 0) { + output.writeInt32(13, syncToFetchSize_); + } + if (syncToFetchSizePeekNum_ != 0L) { + output.writeInt64(14, syncToFetchSizePeekNum_); + } + if (syncBlockRequestedSize_ != 0) { + output.writeInt32(15, syncBlockRequestedSize_); + } + if (unFetchSynNum_ != 0L) { + output.writeInt64(16, unFetchSynNum_); + } + if (blockInPorcSize_ != 0) { + output.writeInt32(17, blockInPorcSize_); + } + if (!getHeadBlockWeBothHaveBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 18, headBlockWeBothHave_); + } + if (isActive_ != false) { + output.writeBool(19, isActive_); + } + if (score_ != 0) { + output.writeInt32(20, score_); + } + if (nodeCount_ != 0) { + output.writeInt32(21, nodeCount_); + } + if (inFlow_ != 0L) { + output.writeInt64(22, inFlow_); + } + if (disconnectTimes_ != 0) { + output.writeInt32(23, disconnectTimes_); + } + if (!getLocalDisconnectReasonBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 24, localDisconnectReason_); + } + if (!getRemoteDisconnectReasonBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 25, remoteDisconnectReason_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getLastSyncBlockBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, lastSyncBlock_); + } + if (remainNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, remainNum_); + } + if (lastBlockUpdateTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, lastBlockUpdateTime_); + } + if (syncFlag_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(4, syncFlag_); + } + if (headBlockTimeWeBothHave_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, headBlockTimeWeBothHave_); + } + if (needSyncFromPeer_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(6, needSyncFromPeer_); + } + if (needSyncFromUs_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(7, needSyncFromUs_); + } + if (!getHostBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, host_); + } + if (port_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(9, port_); + } + if (!getNodeIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, nodeId_); + } + if (connectTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(11, connectTime_); + } + if (avgLatency_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(12, avgLatency_); + } + if (syncToFetchSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(13, syncToFetchSize_); + } + if (syncToFetchSizePeekNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(14, syncToFetchSizePeekNum_); + } + if (syncBlockRequestedSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(15, syncBlockRequestedSize_); + } + if (unFetchSynNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(16, unFetchSynNum_); + } + if (blockInPorcSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(17, blockInPorcSize_); + } + if (!getHeadBlockWeBothHaveBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(18, headBlockWeBothHave_); + } + if (isActive_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(19, isActive_); + } + if (score_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(20, score_); + } + if (nodeCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(21, nodeCount_); + } + if (inFlow_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(22, inFlow_); + } + if (disconnectTimes_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(23, disconnectTimes_); + } + if (!getLocalDisconnectReasonBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(24, localDisconnectReason_); + } + if (!getRemoteDisconnectReasonBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(25, remoteDisconnectReason_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.NodeInfo.PeerInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.NodeInfo.PeerInfo other = (org.tron.protos.Protocol.NodeInfo.PeerInfo) obj; + + boolean result = true; + result = result && getLastSyncBlock() + .equals(other.getLastSyncBlock()); + result = result && (getRemainNum() + == other.getRemainNum()); + result = result && (getLastBlockUpdateTime() + == other.getLastBlockUpdateTime()); + result = result && (getSyncFlag() + == other.getSyncFlag()); + result = result && (getHeadBlockTimeWeBothHave() + == other.getHeadBlockTimeWeBothHave()); + result = result && (getNeedSyncFromPeer() + == other.getNeedSyncFromPeer()); + result = result && (getNeedSyncFromUs() + == other.getNeedSyncFromUs()); + result = result && getHost() + .equals(other.getHost()); + result = result && (getPort() + == other.getPort()); + result = result && getNodeId() + .equals(other.getNodeId()); + result = result && (getConnectTime() + == other.getConnectTime()); + result = result && ( + java.lang.Double.doubleToLongBits(getAvgLatency()) + == java.lang.Double.doubleToLongBits( + other.getAvgLatency())); + result = result && (getSyncToFetchSize() + == other.getSyncToFetchSize()); + result = result && (getSyncToFetchSizePeekNum() + == other.getSyncToFetchSizePeekNum()); + result = result && (getSyncBlockRequestedSize() + == other.getSyncBlockRequestedSize()); + result = result && (getUnFetchSynNum() + == other.getUnFetchSynNum()); + result = result && (getBlockInPorcSize() + == other.getBlockInPorcSize()); + result = result && getHeadBlockWeBothHave() + .equals(other.getHeadBlockWeBothHave()); + result = result && (getIsActive() + == other.getIsActive()); + result = result && (getScore() + == other.getScore()); + result = result && (getNodeCount() + == other.getNodeCount()); + result = result && (getInFlow() + == other.getInFlow()); + result = result && (getDisconnectTimes() + == other.getDisconnectTimes()); + result = result && getLocalDisconnectReason() + .equals(other.getLocalDisconnectReason()); + result = result && getRemoteDisconnectReason() + .equals(other.getRemoteDisconnectReason()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LASTSYNCBLOCK_FIELD_NUMBER; + hash = (53 * hash) + getLastSyncBlock().hashCode(); + hash = (37 * hash) + REMAINNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getRemainNum()); + hash = (37 * hash) + LASTBLOCKUPDATETIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLastBlockUpdateTime()); + hash = (37 * hash) + SYNCFLAG_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getSyncFlag()); + hash = (37 * hash) + HEADBLOCKTIMEWEBOTHHAVE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getHeadBlockTimeWeBothHave()); + hash = (37 * hash) + NEEDSYNCFROMPEER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getNeedSyncFromPeer()); + hash = (37 * hash) + NEEDSYNCFROMUS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getNeedSyncFromUs()); + hash = (37 * hash) + HOST_FIELD_NUMBER; + hash = (53 * hash) + getHost().hashCode(); + hash = (37 * hash) + PORT_FIELD_NUMBER; + hash = (53 * hash) + getPort(); + hash = (37 * hash) + NODEID_FIELD_NUMBER; + hash = (53 * hash) + getNodeId().hashCode(); + hash = (37 * hash) + CONNECTTIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getConnectTime()); + hash = (37 * hash) + AVGLATENCY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getAvgLatency())); + hash = (37 * hash) + SYNCTOFETCHSIZE_FIELD_NUMBER; + hash = (53 * hash) + getSyncToFetchSize(); + hash = (37 * hash) + SYNCTOFETCHSIZEPEEKNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSyncToFetchSizePeekNum()); + hash = (37 * hash) + SYNCBLOCKREQUESTEDSIZE_FIELD_NUMBER; + hash = (53 * hash) + getSyncBlockRequestedSize(); + hash = (37 * hash) + UNFETCHSYNNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getUnFetchSynNum()); + hash = (37 * hash) + BLOCKINPORCSIZE_FIELD_NUMBER; + hash = (53 * hash) + getBlockInPorcSize(); + hash = (37 * hash) + HEADBLOCKWEBOTHHAVE_FIELD_NUMBER; + hash = (53 * hash) + getHeadBlockWeBothHave().hashCode(); + hash = (37 * hash) + ISACTIVE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIsActive()); + hash = (37 * hash) + SCORE_FIELD_NUMBER; + hash = (53 * hash) + getScore(); + hash = (37 * hash) + NODECOUNT_FIELD_NUMBER; + hash = (53 * hash) + getNodeCount(); + hash = (37 * hash) + INFLOW_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getInFlow()); + hash = (37 * hash) + DISCONNECTTIMES_FIELD_NUMBER; + hash = (53 * hash) + getDisconnectTimes(); + hash = (37 * hash) + LOCALDISCONNECTREASON_FIELD_NUMBER; + hash = (53 * hash) + getLocalDisconnectReason().hashCode(); + hash = (37 * hash) + REMOTEDISCONNECTREASON_FIELD_NUMBER; + hash = (53 * hash) + getRemoteDisconnectReason().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.PeerInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.NodeInfo.PeerInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.NodeInfo.PeerInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NodeInfo.PeerInfo) + org.tron.protos.Protocol.NodeInfo.PeerInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_PeerInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_PeerInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.PeerInfo.class, org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.NodeInfo.PeerInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + lastSyncBlock_ = ""; + + remainNum_ = 0L; + + lastBlockUpdateTime_ = 0L; + + syncFlag_ = false; + + headBlockTimeWeBothHave_ = 0L; + + needSyncFromPeer_ = false; + + needSyncFromUs_ = false; + + host_ = ""; + + port_ = 0; + + nodeId_ = ""; + + connectTime_ = 0L; + + avgLatency_ = 0D; + + syncToFetchSize_ = 0; + + syncToFetchSizePeekNum_ = 0L; + + syncBlockRequestedSize_ = 0; + + unFetchSynNum_ = 0L; + + blockInPorcSize_ = 0; + + headBlockWeBothHave_ = ""; + + isActive_ = false; + + score_ = 0; + + nodeCount_ = 0; + + inFlow_ = 0L; + + disconnectTimes_ = 0; + + localDisconnectReason_ = ""; + + remoteDisconnectReason_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_PeerInfo_descriptor; + } + + public org.tron.protos.Protocol.NodeInfo.PeerInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.NodeInfo.PeerInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.NodeInfo.PeerInfo build() { + org.tron.protos.Protocol.NodeInfo.PeerInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.NodeInfo.PeerInfo buildPartial() { + org.tron.protos.Protocol.NodeInfo.PeerInfo result = new org.tron.protos.Protocol.NodeInfo.PeerInfo(this); + result.lastSyncBlock_ = lastSyncBlock_; + result.remainNum_ = remainNum_; + result.lastBlockUpdateTime_ = lastBlockUpdateTime_; + result.syncFlag_ = syncFlag_; + result.headBlockTimeWeBothHave_ = headBlockTimeWeBothHave_; + result.needSyncFromPeer_ = needSyncFromPeer_; + result.needSyncFromUs_ = needSyncFromUs_; + result.host_ = host_; + result.port_ = port_; + result.nodeId_ = nodeId_; + result.connectTime_ = connectTime_; + result.avgLatency_ = avgLatency_; + result.syncToFetchSize_ = syncToFetchSize_; + result.syncToFetchSizePeekNum_ = syncToFetchSizePeekNum_; + result.syncBlockRequestedSize_ = syncBlockRequestedSize_; + result.unFetchSynNum_ = unFetchSynNum_; + result.blockInPorcSize_ = blockInPorcSize_; + result.headBlockWeBothHave_ = headBlockWeBothHave_; + result.isActive_ = isActive_; + result.score_ = score_; + result.nodeCount_ = nodeCount_; + result.inFlow_ = inFlow_; + result.disconnectTimes_ = disconnectTimes_; + result.localDisconnectReason_ = localDisconnectReason_; + result.remoteDisconnectReason_ = remoteDisconnectReason_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.NodeInfo.PeerInfo) { + return mergeFrom((org.tron.protos.Protocol.NodeInfo.PeerInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.NodeInfo.PeerInfo other) { + if (other == org.tron.protos.Protocol.NodeInfo.PeerInfo.getDefaultInstance()) return this; + if (!other.getLastSyncBlock().isEmpty()) { + lastSyncBlock_ = other.lastSyncBlock_; + onChanged(); + } + if (other.getRemainNum() != 0L) { + setRemainNum(other.getRemainNum()); + } + if (other.getLastBlockUpdateTime() != 0L) { + setLastBlockUpdateTime(other.getLastBlockUpdateTime()); + } + if (other.getSyncFlag() != false) { + setSyncFlag(other.getSyncFlag()); + } + if (other.getHeadBlockTimeWeBothHave() != 0L) { + setHeadBlockTimeWeBothHave(other.getHeadBlockTimeWeBothHave()); + } + if (other.getNeedSyncFromPeer() != false) { + setNeedSyncFromPeer(other.getNeedSyncFromPeer()); + } + if (other.getNeedSyncFromUs() != false) { + setNeedSyncFromUs(other.getNeedSyncFromUs()); + } + if (!other.getHost().isEmpty()) { + host_ = other.host_; + onChanged(); + } + if (other.getPort() != 0) { + setPort(other.getPort()); + } + if (!other.getNodeId().isEmpty()) { + nodeId_ = other.nodeId_; + onChanged(); + } + if (other.getConnectTime() != 0L) { + setConnectTime(other.getConnectTime()); + } + if (other.getAvgLatency() != 0D) { + setAvgLatency(other.getAvgLatency()); + } + if (other.getSyncToFetchSize() != 0) { + setSyncToFetchSize(other.getSyncToFetchSize()); + } + if (other.getSyncToFetchSizePeekNum() != 0L) { + setSyncToFetchSizePeekNum(other.getSyncToFetchSizePeekNum()); + } + if (other.getSyncBlockRequestedSize() != 0) { + setSyncBlockRequestedSize(other.getSyncBlockRequestedSize()); + } + if (other.getUnFetchSynNum() != 0L) { + setUnFetchSynNum(other.getUnFetchSynNum()); + } + if (other.getBlockInPorcSize() != 0) { + setBlockInPorcSize(other.getBlockInPorcSize()); + } + if (!other.getHeadBlockWeBothHave().isEmpty()) { + headBlockWeBothHave_ = other.headBlockWeBothHave_; + onChanged(); + } + if (other.getIsActive() != false) { + setIsActive(other.getIsActive()); + } + if (other.getScore() != 0) { + setScore(other.getScore()); + } + if (other.getNodeCount() != 0) { + setNodeCount(other.getNodeCount()); + } + if (other.getInFlow() != 0L) { + setInFlow(other.getInFlow()); + } + if (other.getDisconnectTimes() != 0) { + setDisconnectTimes(other.getDisconnectTimes()); + } + if (!other.getLocalDisconnectReason().isEmpty()) { + localDisconnectReason_ = other.localDisconnectReason_; + onChanged(); + } + if (!other.getRemoteDisconnectReason().isEmpty()) { + remoteDisconnectReason_ = other.remoteDisconnectReason_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.NodeInfo.PeerInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.NodeInfo.PeerInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object lastSyncBlock_ = ""; + /** + * string lastSyncBlock = 1; + */ + public java.lang.String getLastSyncBlock() { + java.lang.Object ref = lastSyncBlock_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + lastSyncBlock_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string lastSyncBlock = 1; + */ + public com.google.protobuf.ByteString + getLastSyncBlockBytes() { + java.lang.Object ref = lastSyncBlock_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + lastSyncBlock_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string lastSyncBlock = 1; + */ + public Builder setLastSyncBlock( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + lastSyncBlock_ = value; + onChanged(); + return this; + } + /** + * string lastSyncBlock = 1; + */ + public Builder clearLastSyncBlock() { + + lastSyncBlock_ = getDefaultInstance().getLastSyncBlock(); + onChanged(); + return this; + } + /** + * string lastSyncBlock = 1; + */ + public Builder setLastSyncBlockBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + lastSyncBlock_ = value; + onChanged(); + return this; + } + + private long remainNum_ ; + /** + * int64 remainNum = 2; + */ + public long getRemainNum() { + return remainNum_; + } + /** + * int64 remainNum = 2; + */ + public Builder setRemainNum(long value) { + + remainNum_ = value; + onChanged(); + return this; + } + /** + * int64 remainNum = 2; + */ + public Builder clearRemainNum() { + + remainNum_ = 0L; + onChanged(); + return this; + } + + private long lastBlockUpdateTime_ ; + /** + * int64 lastBlockUpdateTime = 3; + */ + public long getLastBlockUpdateTime() { + return lastBlockUpdateTime_; + } + /** + * int64 lastBlockUpdateTime = 3; + */ + public Builder setLastBlockUpdateTime(long value) { + + lastBlockUpdateTime_ = value; + onChanged(); + return this; + } + /** + * int64 lastBlockUpdateTime = 3; + */ + public Builder clearLastBlockUpdateTime() { + + lastBlockUpdateTime_ = 0L; + onChanged(); + return this; + } + + private boolean syncFlag_ ; + /** + * bool syncFlag = 4; + */ + public boolean getSyncFlag() { + return syncFlag_; + } + /** + * bool syncFlag = 4; + */ + public Builder setSyncFlag(boolean value) { + + syncFlag_ = value; + onChanged(); + return this; + } + /** + * bool syncFlag = 4; + */ + public Builder clearSyncFlag() { + + syncFlag_ = false; + onChanged(); + return this; + } + + private long headBlockTimeWeBothHave_ ; + /** + * int64 headBlockTimeWeBothHave = 5; + */ + public long getHeadBlockTimeWeBothHave() { + return headBlockTimeWeBothHave_; + } + /** + * int64 headBlockTimeWeBothHave = 5; + */ + public Builder setHeadBlockTimeWeBothHave(long value) { + + headBlockTimeWeBothHave_ = value; + onChanged(); + return this; + } + /** + * int64 headBlockTimeWeBothHave = 5; + */ + public Builder clearHeadBlockTimeWeBothHave() { + + headBlockTimeWeBothHave_ = 0L; + onChanged(); + return this; + } + + private boolean needSyncFromPeer_ ; + /** + * bool needSyncFromPeer = 6; + */ + public boolean getNeedSyncFromPeer() { + return needSyncFromPeer_; + } + /** + * bool needSyncFromPeer = 6; + */ + public Builder setNeedSyncFromPeer(boolean value) { + + needSyncFromPeer_ = value; + onChanged(); + return this; + } + /** + * bool needSyncFromPeer = 6; + */ + public Builder clearNeedSyncFromPeer() { + + needSyncFromPeer_ = false; + onChanged(); + return this; + } + + private boolean needSyncFromUs_ ; + /** + * bool needSyncFromUs = 7; + */ + public boolean getNeedSyncFromUs() { + return needSyncFromUs_; + } + /** + * bool needSyncFromUs = 7; + */ + public Builder setNeedSyncFromUs(boolean value) { + + needSyncFromUs_ = value; + onChanged(); + return this; + } + /** + * bool needSyncFromUs = 7; + */ + public Builder clearNeedSyncFromUs() { + + needSyncFromUs_ = false; + onChanged(); + return this; + } + + private java.lang.Object host_ = ""; + /** + * string host = 8; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + host_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string host = 8; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string host = 8; + */ + public Builder setHost( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + host_ = value; + onChanged(); + return this; + } + /** + * string host = 8; + */ + public Builder clearHost() { + + host_ = getDefaultInstance().getHost(); + onChanged(); + return this; + } + /** + * string host = 8; + */ + public Builder setHostBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + host_ = value; + onChanged(); + return this; + } + + private int port_ ; + /** + * int32 port = 9; + */ + public int getPort() { + return port_; + } + /** + * int32 port = 9; + */ + public Builder setPort(int value) { + + port_ = value; + onChanged(); + return this; + } + /** + * int32 port = 9; + */ + public Builder clearPort() { + + port_ = 0; + onChanged(); + return this; + } + + private java.lang.Object nodeId_ = ""; + /** + * string nodeId = 10; + */ + public java.lang.String getNodeId() { + java.lang.Object ref = nodeId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nodeId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string nodeId = 10; + */ + public com.google.protobuf.ByteString + getNodeIdBytes() { + java.lang.Object ref = nodeId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nodeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string nodeId = 10; + */ + public Builder setNodeId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + nodeId_ = value; + onChanged(); + return this; + } + /** + * string nodeId = 10; + */ + public Builder clearNodeId() { + + nodeId_ = getDefaultInstance().getNodeId(); + onChanged(); + return this; + } + /** + * string nodeId = 10; + */ + public Builder setNodeIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nodeId_ = value; + onChanged(); + return this; + } + + private long connectTime_ ; + /** + * int64 connectTime = 11; + */ + public long getConnectTime() { + return connectTime_; + } + /** + * int64 connectTime = 11; + */ + public Builder setConnectTime(long value) { + + connectTime_ = value; + onChanged(); + return this; + } + /** + * int64 connectTime = 11; + */ + public Builder clearConnectTime() { + + connectTime_ = 0L; + onChanged(); + return this; + } + + private double avgLatency_ ; + /** + * double avgLatency = 12; + */ + public double getAvgLatency() { + return avgLatency_; + } + /** + * double avgLatency = 12; + */ + public Builder setAvgLatency(double value) { + + avgLatency_ = value; + onChanged(); + return this; + } + /** + * double avgLatency = 12; + */ + public Builder clearAvgLatency() { + + avgLatency_ = 0D; + onChanged(); + return this; + } + + private int syncToFetchSize_ ; + /** + * int32 syncToFetchSize = 13; + */ + public int getSyncToFetchSize() { + return syncToFetchSize_; + } + /** + * int32 syncToFetchSize = 13; + */ + public Builder setSyncToFetchSize(int value) { + + syncToFetchSize_ = value; + onChanged(); + return this; + } + /** + * int32 syncToFetchSize = 13; + */ + public Builder clearSyncToFetchSize() { + + syncToFetchSize_ = 0; + onChanged(); + return this; + } + + private long syncToFetchSizePeekNum_ ; + /** + * int64 syncToFetchSizePeekNum = 14; + */ + public long getSyncToFetchSizePeekNum() { + return syncToFetchSizePeekNum_; + } + /** + * int64 syncToFetchSizePeekNum = 14; + */ + public Builder setSyncToFetchSizePeekNum(long value) { + + syncToFetchSizePeekNum_ = value; + onChanged(); + return this; + } + /** + * int64 syncToFetchSizePeekNum = 14; + */ + public Builder clearSyncToFetchSizePeekNum() { + + syncToFetchSizePeekNum_ = 0L; + onChanged(); + return this; + } + + private int syncBlockRequestedSize_ ; + /** + * int32 syncBlockRequestedSize = 15; + */ + public int getSyncBlockRequestedSize() { + return syncBlockRequestedSize_; + } + /** + * int32 syncBlockRequestedSize = 15; + */ + public Builder setSyncBlockRequestedSize(int value) { + + syncBlockRequestedSize_ = value; + onChanged(); + return this; + } + /** + * int32 syncBlockRequestedSize = 15; + */ + public Builder clearSyncBlockRequestedSize() { + + syncBlockRequestedSize_ = 0; + onChanged(); + return this; + } + + private long unFetchSynNum_ ; + /** + * int64 unFetchSynNum = 16; + */ + public long getUnFetchSynNum() { + return unFetchSynNum_; + } + /** + * int64 unFetchSynNum = 16; + */ + public Builder setUnFetchSynNum(long value) { + + unFetchSynNum_ = value; + onChanged(); + return this; + } + /** + * int64 unFetchSynNum = 16; + */ + public Builder clearUnFetchSynNum() { + + unFetchSynNum_ = 0L; + onChanged(); + return this; + } + + private int blockInPorcSize_ ; + /** + * int32 blockInPorcSize = 17; + */ + public int getBlockInPorcSize() { + return blockInPorcSize_; + } + /** + * int32 blockInPorcSize = 17; + */ + public Builder setBlockInPorcSize(int value) { + + blockInPorcSize_ = value; + onChanged(); + return this; + } + /** + * int32 blockInPorcSize = 17; + */ + public Builder clearBlockInPorcSize() { + + blockInPorcSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object headBlockWeBothHave_ = ""; + /** + * string headBlockWeBothHave = 18; + */ + public java.lang.String getHeadBlockWeBothHave() { + java.lang.Object ref = headBlockWeBothHave_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + headBlockWeBothHave_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string headBlockWeBothHave = 18; + */ + public com.google.protobuf.ByteString + getHeadBlockWeBothHaveBytes() { + java.lang.Object ref = headBlockWeBothHave_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + headBlockWeBothHave_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string headBlockWeBothHave = 18; + */ + public Builder setHeadBlockWeBothHave( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + headBlockWeBothHave_ = value; + onChanged(); + return this; + } + /** + * string headBlockWeBothHave = 18; + */ + public Builder clearHeadBlockWeBothHave() { + + headBlockWeBothHave_ = getDefaultInstance().getHeadBlockWeBothHave(); + onChanged(); + return this; + } + /** + * string headBlockWeBothHave = 18; + */ + public Builder setHeadBlockWeBothHaveBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + headBlockWeBothHave_ = value; + onChanged(); + return this; + } + + private boolean isActive_ ; + /** + * bool isActive = 19; + */ + public boolean getIsActive() { + return isActive_; + } + /** + * bool isActive = 19; + */ + public Builder setIsActive(boolean value) { + + isActive_ = value; + onChanged(); + return this; + } + /** + * bool isActive = 19; + */ + public Builder clearIsActive() { + + isActive_ = false; + onChanged(); + return this; + } + + private int score_ ; + /** + * int32 score = 20; + */ + public int getScore() { + return score_; + } + /** + * int32 score = 20; + */ + public Builder setScore(int value) { + + score_ = value; + onChanged(); + return this; + } + /** + * int32 score = 20; + */ + public Builder clearScore() { + + score_ = 0; + onChanged(); + return this; + } + + private int nodeCount_ ; + /** + * int32 nodeCount = 21; + */ + public int getNodeCount() { + return nodeCount_; + } + /** + * int32 nodeCount = 21; + */ + public Builder setNodeCount(int value) { + + nodeCount_ = value; + onChanged(); + return this; + } + /** + * int32 nodeCount = 21; + */ + public Builder clearNodeCount() { + + nodeCount_ = 0; + onChanged(); + return this; + } + + private long inFlow_ ; + /** + * int64 inFlow = 22; + */ + public long getInFlow() { + return inFlow_; + } + /** + * int64 inFlow = 22; + */ + public Builder setInFlow(long value) { + + inFlow_ = value; + onChanged(); + return this; + } + /** + * int64 inFlow = 22; + */ + public Builder clearInFlow() { + + inFlow_ = 0L; + onChanged(); + return this; + } + + private int disconnectTimes_ ; + /** + * int32 disconnectTimes = 23; + */ + public int getDisconnectTimes() { + return disconnectTimes_; + } + /** + * int32 disconnectTimes = 23; + */ + public Builder setDisconnectTimes(int value) { + + disconnectTimes_ = value; + onChanged(); + return this; + } + /** + * int32 disconnectTimes = 23; + */ + public Builder clearDisconnectTimes() { + + disconnectTimes_ = 0; + onChanged(); + return this; + } + + private java.lang.Object localDisconnectReason_ = ""; + /** + * string localDisconnectReason = 24; + */ + public java.lang.String getLocalDisconnectReason() { + java.lang.Object ref = localDisconnectReason_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + localDisconnectReason_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string localDisconnectReason = 24; + */ + public com.google.protobuf.ByteString + getLocalDisconnectReasonBytes() { + java.lang.Object ref = localDisconnectReason_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + localDisconnectReason_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string localDisconnectReason = 24; + */ + public Builder setLocalDisconnectReason( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + localDisconnectReason_ = value; + onChanged(); + return this; + } + /** + * string localDisconnectReason = 24; + */ + public Builder clearLocalDisconnectReason() { + + localDisconnectReason_ = getDefaultInstance().getLocalDisconnectReason(); + onChanged(); + return this; + } + /** + * string localDisconnectReason = 24; + */ + public Builder setLocalDisconnectReasonBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + localDisconnectReason_ = value; + onChanged(); + return this; + } + + private java.lang.Object remoteDisconnectReason_ = ""; + /** + * string remoteDisconnectReason = 25; + */ + public java.lang.String getRemoteDisconnectReason() { + java.lang.Object ref = remoteDisconnectReason_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + remoteDisconnectReason_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string remoteDisconnectReason = 25; + */ + public com.google.protobuf.ByteString + getRemoteDisconnectReasonBytes() { + java.lang.Object ref = remoteDisconnectReason_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + remoteDisconnectReason_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string remoteDisconnectReason = 25; + */ + public Builder setRemoteDisconnectReason( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + remoteDisconnectReason_ = value; + onChanged(); + return this; + } + /** + * string remoteDisconnectReason = 25; + */ + public Builder clearRemoteDisconnectReason() { + + remoteDisconnectReason_ = getDefaultInstance().getRemoteDisconnectReason(); + onChanged(); + return this; + } + /** + * string remoteDisconnectReason = 25; + */ + public Builder setRemoteDisconnectReasonBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + remoteDisconnectReason_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NodeInfo.PeerInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.NodeInfo.PeerInfo) + private static final org.tron.protos.Protocol.NodeInfo.PeerInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.NodeInfo.PeerInfo(); + } + + public static org.tron.protos.Protocol.NodeInfo.PeerInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PeerInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PeerInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.NodeInfo.PeerInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ConfigNodeInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NodeInfo.ConfigNodeInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * string codeVersion = 1; + */ + java.lang.String getCodeVersion(); + /** + * string codeVersion = 1; + */ + com.google.protobuf.ByteString + getCodeVersionBytes(); + + /** + * string p2pVersion = 2; + */ + java.lang.String getP2PVersion(); + /** + * string p2pVersion = 2; + */ + com.google.protobuf.ByteString + getP2PVersionBytes(); + + /** + * int32 listenPort = 3; + */ + int getListenPort(); + + /** + * bool discoverEnable = 4; + */ + boolean getDiscoverEnable(); + + /** + * int32 activeNodeSize = 5; + */ + int getActiveNodeSize(); + + /** + * int32 passiveNodeSize = 6; + */ + int getPassiveNodeSize(); + + /** + * int32 sendNodeSize = 7; + */ + int getSendNodeSize(); + + /** + * int32 maxConnectCount = 8; + */ + int getMaxConnectCount(); + + /** + * int32 sameIpMaxConnectCount = 9; + */ + int getSameIpMaxConnectCount(); + + /** + * int32 backupListenPort = 10; + */ + int getBackupListenPort(); + + /** + * int32 backupMemberSize = 11; + */ + int getBackupMemberSize(); + + /** + * int32 backupPriority = 12; + */ + int getBackupPriority(); + + /** + * int32 dbVersion = 13; + */ + int getDbVersion(); + + /** + * int32 minParticipationRate = 14; + */ + int getMinParticipationRate(); + + /** + * bool supportConstant = 15; + */ + boolean getSupportConstant(); + + /** + * double minTimeRatio = 16; + */ + double getMinTimeRatio(); + + /** + * double maxTimeRatio = 17; + */ + double getMaxTimeRatio(); + + /** + * int64 allowCreationOfContracts = 18; + */ + long getAllowCreationOfContracts(); + + /** + * int64 allowAdaptiveEnergy = 19; + */ + long getAllowAdaptiveEnergy(); + } + /** + * Protobuf type {@code protocol.NodeInfo.ConfigNodeInfo} + */ + public static final class ConfigNodeInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NodeInfo.ConfigNodeInfo) + ConfigNodeInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use ConfigNodeInfo.newBuilder() to construct. + private ConfigNodeInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ConfigNodeInfo() { + codeVersion_ = ""; + p2PVersion_ = ""; + listenPort_ = 0; + discoverEnable_ = false; + activeNodeSize_ = 0; + passiveNodeSize_ = 0; + sendNodeSize_ = 0; + maxConnectCount_ = 0; + sameIpMaxConnectCount_ = 0; + backupListenPort_ = 0; + backupMemberSize_ = 0; + backupPriority_ = 0; + dbVersion_ = 0; + minParticipationRate_ = 0; + supportConstant_ = false; + minTimeRatio_ = 0D; + maxTimeRatio_ = 0D; + allowCreationOfContracts_ = 0L; + allowAdaptiveEnergy_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ConfigNodeInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + codeVersion_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + p2PVersion_ = s; + break; + } + case 24: { + + listenPort_ = input.readInt32(); + break; + } + case 32: { + + discoverEnable_ = input.readBool(); + break; + } + case 40: { + + activeNodeSize_ = input.readInt32(); + break; + } + case 48: { + + passiveNodeSize_ = input.readInt32(); + break; + } + case 56: { + + sendNodeSize_ = input.readInt32(); + break; + } + case 64: { + + maxConnectCount_ = input.readInt32(); + break; + } + case 72: { + + sameIpMaxConnectCount_ = input.readInt32(); + break; + } + case 80: { + + backupListenPort_ = input.readInt32(); + break; + } + case 88: { + + backupMemberSize_ = input.readInt32(); + break; + } + case 96: { + + backupPriority_ = input.readInt32(); + break; + } + case 104: { + + dbVersion_ = input.readInt32(); + break; + } + case 112: { + + minParticipationRate_ = input.readInt32(); + break; + } + case 120: { + + supportConstant_ = input.readBool(); + break; + } + case 129: { + + minTimeRatio_ = input.readDouble(); + break; + } + case 137: { + + maxTimeRatio_ = input.readDouble(); + break; + } + case 144: { + + allowCreationOfContracts_ = input.readInt64(); + break; + } + case 152: { + + allowAdaptiveEnergy_ = input.readInt64(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_ConfigNodeInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_ConfigNodeInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.class, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder.class); + } + + public static final int CODEVERSION_FIELD_NUMBER = 1; + private volatile java.lang.Object codeVersion_; + /** + * string codeVersion = 1; + */ + public java.lang.String getCodeVersion() { + java.lang.Object ref = codeVersion_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + codeVersion_ = s; + return s; + } + } + /** + * string codeVersion = 1; + */ + public com.google.protobuf.ByteString + getCodeVersionBytes() { + java.lang.Object ref = codeVersion_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + codeVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int P2PVERSION_FIELD_NUMBER = 2; + private volatile java.lang.Object p2PVersion_; + /** + * string p2pVersion = 2; + */ + public java.lang.String getP2PVersion() { + java.lang.Object ref = p2PVersion_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + p2PVersion_ = s; + return s; + } + } + /** + * string p2pVersion = 2; + */ + public com.google.protobuf.ByteString + getP2PVersionBytes() { + java.lang.Object ref = p2PVersion_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + p2PVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LISTENPORT_FIELD_NUMBER = 3; + private int listenPort_; + /** + * int32 listenPort = 3; + */ + public int getListenPort() { + return listenPort_; + } + + public static final int DISCOVERENABLE_FIELD_NUMBER = 4; + private boolean discoverEnable_; + /** + * bool discoverEnable = 4; + */ + public boolean getDiscoverEnable() { + return discoverEnable_; + } + + public static final int ACTIVENODESIZE_FIELD_NUMBER = 5; + private int activeNodeSize_; + /** + * int32 activeNodeSize = 5; + */ + public int getActiveNodeSize() { + return activeNodeSize_; + } + + public static final int PASSIVENODESIZE_FIELD_NUMBER = 6; + private int passiveNodeSize_; + /** + * int32 passiveNodeSize = 6; + */ + public int getPassiveNodeSize() { + return passiveNodeSize_; + } + + public static final int SENDNODESIZE_FIELD_NUMBER = 7; + private int sendNodeSize_; + /** + * int32 sendNodeSize = 7; + */ + public int getSendNodeSize() { + return sendNodeSize_; + } + + public static final int MAXCONNECTCOUNT_FIELD_NUMBER = 8; + private int maxConnectCount_; + /** + * int32 maxConnectCount = 8; + */ + public int getMaxConnectCount() { + return maxConnectCount_; + } + + public static final int SAMEIPMAXCONNECTCOUNT_FIELD_NUMBER = 9; + private int sameIpMaxConnectCount_; + /** + * int32 sameIpMaxConnectCount = 9; + */ + public int getSameIpMaxConnectCount() { + return sameIpMaxConnectCount_; + } + + public static final int BACKUPLISTENPORT_FIELD_NUMBER = 10; + private int backupListenPort_; + /** + * int32 backupListenPort = 10; + */ + public int getBackupListenPort() { + return backupListenPort_; + } + + public static final int BACKUPMEMBERSIZE_FIELD_NUMBER = 11; + private int backupMemberSize_; + /** + * int32 backupMemberSize = 11; + */ + public int getBackupMemberSize() { + return backupMemberSize_; + } + + public static final int BACKUPPRIORITY_FIELD_NUMBER = 12; + private int backupPriority_; + /** + * int32 backupPriority = 12; + */ + public int getBackupPriority() { + return backupPriority_; + } + + public static final int DBVERSION_FIELD_NUMBER = 13; + private int dbVersion_; + /** + * int32 dbVersion = 13; + */ + public int getDbVersion() { + return dbVersion_; + } + + public static final int MINPARTICIPATIONRATE_FIELD_NUMBER = 14; + private int minParticipationRate_; + /** + * int32 minParticipationRate = 14; + */ + public int getMinParticipationRate() { + return minParticipationRate_; + } + + public static final int SUPPORTCONSTANT_FIELD_NUMBER = 15; + private boolean supportConstant_; + /** + * bool supportConstant = 15; + */ + public boolean getSupportConstant() { + return supportConstant_; + } + + public static final int MINTIMERATIO_FIELD_NUMBER = 16; + private double minTimeRatio_; + /** + * double minTimeRatio = 16; + */ + public double getMinTimeRatio() { + return minTimeRatio_; + } + + public static final int MAXTIMERATIO_FIELD_NUMBER = 17; + private double maxTimeRatio_; + /** + * double maxTimeRatio = 17; + */ + public double getMaxTimeRatio() { + return maxTimeRatio_; + } + + public static final int ALLOWCREATIONOFCONTRACTS_FIELD_NUMBER = 18; + private long allowCreationOfContracts_; + /** + * int64 allowCreationOfContracts = 18; + */ + public long getAllowCreationOfContracts() { + return allowCreationOfContracts_; + } + + public static final int ALLOWADAPTIVEENERGY_FIELD_NUMBER = 19; + private long allowAdaptiveEnergy_; + /** + * int64 allowAdaptiveEnergy = 19; + */ + public long getAllowAdaptiveEnergy() { + return allowAdaptiveEnergy_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getCodeVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, codeVersion_); + } + if (!getP2PVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, p2PVersion_); + } + if (listenPort_ != 0) { + output.writeInt32(3, listenPort_); + } + if (discoverEnable_ != false) { + output.writeBool(4, discoverEnable_); + } + if (activeNodeSize_ != 0) { + output.writeInt32(5, activeNodeSize_); + } + if (passiveNodeSize_ != 0) { + output.writeInt32(6, passiveNodeSize_); + } + if (sendNodeSize_ != 0) { + output.writeInt32(7, sendNodeSize_); + } + if (maxConnectCount_ != 0) { + output.writeInt32(8, maxConnectCount_); + } + if (sameIpMaxConnectCount_ != 0) { + output.writeInt32(9, sameIpMaxConnectCount_); + } + if (backupListenPort_ != 0) { + output.writeInt32(10, backupListenPort_); + } + if (backupMemberSize_ != 0) { + output.writeInt32(11, backupMemberSize_); + } + if (backupPriority_ != 0) { + output.writeInt32(12, backupPriority_); + } + if (dbVersion_ != 0) { + output.writeInt32(13, dbVersion_); + } + if (minParticipationRate_ != 0) { + output.writeInt32(14, minParticipationRate_); + } + if (supportConstant_ != false) { + output.writeBool(15, supportConstant_); + } + if (minTimeRatio_ != 0D) { + output.writeDouble(16, minTimeRatio_); + } + if (maxTimeRatio_ != 0D) { + output.writeDouble(17, maxTimeRatio_); + } + if (allowCreationOfContracts_ != 0L) { + output.writeInt64(18, allowCreationOfContracts_); + } + if (allowAdaptiveEnergy_ != 0L) { + output.writeInt64(19, allowAdaptiveEnergy_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getCodeVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, codeVersion_); + } + if (!getP2PVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, p2PVersion_); + } + if (listenPort_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, listenPort_); + } + if (discoverEnable_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(4, discoverEnable_); + } + if (activeNodeSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, activeNodeSize_); + } + if (passiveNodeSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(6, passiveNodeSize_); + } + if (sendNodeSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(7, sendNodeSize_); + } + if (maxConnectCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(8, maxConnectCount_); + } + if (sameIpMaxConnectCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(9, sameIpMaxConnectCount_); + } + if (backupListenPort_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(10, backupListenPort_); + } + if (backupMemberSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(11, backupMemberSize_); + } + if (backupPriority_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(12, backupPriority_); + } + if (dbVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(13, dbVersion_); + } + if (minParticipationRate_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(14, minParticipationRate_); + } + if (supportConstant_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(15, supportConstant_); + } + if (minTimeRatio_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(16, minTimeRatio_); + } + if (maxTimeRatio_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(17, maxTimeRatio_); + } + if (allowCreationOfContracts_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(18, allowCreationOfContracts_); + } + if (allowAdaptiveEnergy_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(19, allowAdaptiveEnergy_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo other = (org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo) obj; + + boolean result = true; + result = result && getCodeVersion() + .equals(other.getCodeVersion()); + result = result && getP2PVersion() + .equals(other.getP2PVersion()); + result = result && (getListenPort() + == other.getListenPort()); + result = result && (getDiscoverEnable() + == other.getDiscoverEnable()); + result = result && (getActiveNodeSize() + == other.getActiveNodeSize()); + result = result && (getPassiveNodeSize() + == other.getPassiveNodeSize()); + result = result && (getSendNodeSize() + == other.getSendNodeSize()); + result = result && (getMaxConnectCount() + == other.getMaxConnectCount()); + result = result && (getSameIpMaxConnectCount() + == other.getSameIpMaxConnectCount()); + result = result && (getBackupListenPort() + == other.getBackupListenPort()); + result = result && (getBackupMemberSize() + == other.getBackupMemberSize()); + result = result && (getBackupPriority() + == other.getBackupPriority()); + result = result && (getDbVersion() + == other.getDbVersion()); + result = result && (getMinParticipationRate() + == other.getMinParticipationRate()); + result = result && (getSupportConstant() + == other.getSupportConstant()); + result = result && ( + java.lang.Double.doubleToLongBits(getMinTimeRatio()) + == java.lang.Double.doubleToLongBits( + other.getMinTimeRatio())); + result = result && ( + java.lang.Double.doubleToLongBits(getMaxTimeRatio()) + == java.lang.Double.doubleToLongBits( + other.getMaxTimeRatio())); + result = result && (getAllowCreationOfContracts() + == other.getAllowCreationOfContracts()); + result = result && (getAllowAdaptiveEnergy() + == other.getAllowAdaptiveEnergy()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CODEVERSION_FIELD_NUMBER; + hash = (53 * hash) + getCodeVersion().hashCode(); + hash = (37 * hash) + P2PVERSION_FIELD_NUMBER; + hash = (53 * hash) + getP2PVersion().hashCode(); + hash = (37 * hash) + LISTENPORT_FIELD_NUMBER; + hash = (53 * hash) + getListenPort(); + hash = (37 * hash) + DISCOVERENABLE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getDiscoverEnable()); + hash = (37 * hash) + ACTIVENODESIZE_FIELD_NUMBER; + hash = (53 * hash) + getActiveNodeSize(); + hash = (37 * hash) + PASSIVENODESIZE_FIELD_NUMBER; + hash = (53 * hash) + getPassiveNodeSize(); + hash = (37 * hash) + SENDNODESIZE_FIELD_NUMBER; + hash = (53 * hash) + getSendNodeSize(); + hash = (37 * hash) + MAXCONNECTCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getMaxConnectCount(); + hash = (37 * hash) + SAMEIPMAXCONNECTCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getSameIpMaxConnectCount(); + hash = (37 * hash) + BACKUPLISTENPORT_FIELD_NUMBER; + hash = (53 * hash) + getBackupListenPort(); + hash = (37 * hash) + BACKUPMEMBERSIZE_FIELD_NUMBER; + hash = (53 * hash) + getBackupMemberSize(); + hash = (37 * hash) + BACKUPPRIORITY_FIELD_NUMBER; + hash = (53 * hash) + getBackupPriority(); + hash = (37 * hash) + DBVERSION_FIELD_NUMBER; + hash = (53 * hash) + getDbVersion(); + hash = (37 * hash) + MINPARTICIPATIONRATE_FIELD_NUMBER; + hash = (53 * hash) + getMinParticipationRate(); + hash = (37 * hash) + SUPPORTCONSTANT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getSupportConstant()); + hash = (37 * hash) + MINTIMERATIO_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getMinTimeRatio())); + hash = (37 * hash) + MAXTIMERATIO_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getMaxTimeRatio())); + hash = (37 * hash) + ALLOWCREATIONOFCONTRACTS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAllowCreationOfContracts()); + hash = (37 * hash) + ALLOWADAPTIVEENERGY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAllowAdaptiveEnergy()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.NodeInfo.ConfigNodeInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NodeInfo.ConfigNodeInfo) + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_ConfigNodeInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_ConfigNodeInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.class, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + codeVersion_ = ""; + + p2PVersion_ = ""; + + listenPort_ = 0; + + discoverEnable_ = false; + + activeNodeSize_ = 0; + + passiveNodeSize_ = 0; + + sendNodeSize_ = 0; + + maxConnectCount_ = 0; + + sameIpMaxConnectCount_ = 0; + + backupListenPort_ = 0; + + backupMemberSize_ = 0; + + backupPriority_ = 0; + + dbVersion_ = 0; + + minParticipationRate_ = 0; + + supportConstant_ = false; + + minTimeRatio_ = 0D; + + maxTimeRatio_ = 0D; + + allowCreationOfContracts_ = 0L; + + allowAdaptiveEnergy_ = 0L; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_ConfigNodeInfo_descriptor; + } + + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo build() { + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo buildPartial() { + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo result = new org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo(this); + result.codeVersion_ = codeVersion_; + result.p2PVersion_ = p2PVersion_; + result.listenPort_ = listenPort_; + result.discoverEnable_ = discoverEnable_; + result.activeNodeSize_ = activeNodeSize_; + result.passiveNodeSize_ = passiveNodeSize_; + result.sendNodeSize_ = sendNodeSize_; + result.maxConnectCount_ = maxConnectCount_; + result.sameIpMaxConnectCount_ = sameIpMaxConnectCount_; + result.backupListenPort_ = backupListenPort_; + result.backupMemberSize_ = backupMemberSize_; + result.backupPriority_ = backupPriority_; + result.dbVersion_ = dbVersion_; + result.minParticipationRate_ = minParticipationRate_; + result.supportConstant_ = supportConstant_; + result.minTimeRatio_ = minTimeRatio_; + result.maxTimeRatio_ = maxTimeRatio_; + result.allowCreationOfContracts_ = allowCreationOfContracts_; + result.allowAdaptiveEnergy_ = allowAdaptiveEnergy_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo) { + return mergeFrom((org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo other) { + if (other == org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.getDefaultInstance()) return this; + if (!other.getCodeVersion().isEmpty()) { + codeVersion_ = other.codeVersion_; + onChanged(); + } + if (!other.getP2PVersion().isEmpty()) { + p2PVersion_ = other.p2PVersion_; + onChanged(); + } + if (other.getListenPort() != 0) { + setListenPort(other.getListenPort()); + } + if (other.getDiscoverEnable() != false) { + setDiscoverEnable(other.getDiscoverEnable()); + } + if (other.getActiveNodeSize() != 0) { + setActiveNodeSize(other.getActiveNodeSize()); + } + if (other.getPassiveNodeSize() != 0) { + setPassiveNodeSize(other.getPassiveNodeSize()); + } + if (other.getSendNodeSize() != 0) { + setSendNodeSize(other.getSendNodeSize()); + } + if (other.getMaxConnectCount() != 0) { + setMaxConnectCount(other.getMaxConnectCount()); + } + if (other.getSameIpMaxConnectCount() != 0) { + setSameIpMaxConnectCount(other.getSameIpMaxConnectCount()); + } + if (other.getBackupListenPort() != 0) { + setBackupListenPort(other.getBackupListenPort()); + } + if (other.getBackupMemberSize() != 0) { + setBackupMemberSize(other.getBackupMemberSize()); + } + if (other.getBackupPriority() != 0) { + setBackupPriority(other.getBackupPriority()); + } + if (other.getDbVersion() != 0) { + setDbVersion(other.getDbVersion()); + } + if (other.getMinParticipationRate() != 0) { + setMinParticipationRate(other.getMinParticipationRate()); + } + if (other.getSupportConstant() != false) { + setSupportConstant(other.getSupportConstant()); + } + if (other.getMinTimeRatio() != 0D) { + setMinTimeRatio(other.getMinTimeRatio()); + } + if (other.getMaxTimeRatio() != 0D) { + setMaxTimeRatio(other.getMaxTimeRatio()); + } + if (other.getAllowCreationOfContracts() != 0L) { + setAllowCreationOfContracts(other.getAllowCreationOfContracts()); + } + if (other.getAllowAdaptiveEnergy() != 0L) { + setAllowAdaptiveEnergy(other.getAllowAdaptiveEnergy()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object codeVersion_ = ""; + /** + * string codeVersion = 1; + */ + public java.lang.String getCodeVersion() { + java.lang.Object ref = codeVersion_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + codeVersion_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string codeVersion = 1; + */ + public com.google.protobuf.ByteString + getCodeVersionBytes() { + java.lang.Object ref = codeVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + codeVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string codeVersion = 1; + */ + public Builder setCodeVersion( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + codeVersion_ = value; + onChanged(); + return this; + } + /** + * string codeVersion = 1; + */ + public Builder clearCodeVersion() { + + codeVersion_ = getDefaultInstance().getCodeVersion(); + onChanged(); + return this; + } + /** + * string codeVersion = 1; + */ + public Builder setCodeVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + codeVersion_ = value; + onChanged(); + return this; + } + + private java.lang.Object p2PVersion_ = ""; + /** + * string p2pVersion = 2; + */ + public java.lang.String getP2PVersion() { + java.lang.Object ref = p2PVersion_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + p2PVersion_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string p2pVersion = 2; + */ + public com.google.protobuf.ByteString + getP2PVersionBytes() { + java.lang.Object ref = p2PVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + p2PVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string p2pVersion = 2; + */ + public Builder setP2PVersion( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + p2PVersion_ = value; + onChanged(); + return this; + } + /** + * string p2pVersion = 2; + */ + public Builder clearP2PVersion() { + + p2PVersion_ = getDefaultInstance().getP2PVersion(); + onChanged(); + return this; + } + /** + * string p2pVersion = 2; + */ + public Builder setP2PVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + p2PVersion_ = value; + onChanged(); + return this; + } + + private int listenPort_ ; + /** + * int32 listenPort = 3; + */ + public int getListenPort() { + return listenPort_; + } + /** + * int32 listenPort = 3; + */ + public Builder setListenPort(int value) { + + listenPort_ = value; + onChanged(); + return this; + } + /** + * int32 listenPort = 3; + */ + public Builder clearListenPort() { + + listenPort_ = 0; + onChanged(); + return this; + } + + private boolean discoverEnable_ ; + /** + * bool discoverEnable = 4; + */ + public boolean getDiscoverEnable() { + return discoverEnable_; + } + /** + * bool discoverEnable = 4; + */ + public Builder setDiscoverEnable(boolean value) { + + discoverEnable_ = value; + onChanged(); + return this; + } + /** + * bool discoverEnable = 4; + */ + public Builder clearDiscoverEnable() { + + discoverEnable_ = false; + onChanged(); + return this; + } + + private int activeNodeSize_ ; + /** + * int32 activeNodeSize = 5; + */ + public int getActiveNodeSize() { + return activeNodeSize_; + } + /** + * int32 activeNodeSize = 5; + */ + public Builder setActiveNodeSize(int value) { + + activeNodeSize_ = value; + onChanged(); + return this; + } + /** + * int32 activeNodeSize = 5; + */ + public Builder clearActiveNodeSize() { + + activeNodeSize_ = 0; + onChanged(); + return this; + } + + private int passiveNodeSize_ ; + /** + * int32 passiveNodeSize = 6; + */ + public int getPassiveNodeSize() { + return passiveNodeSize_; + } + /** + * int32 passiveNodeSize = 6; + */ + public Builder setPassiveNodeSize(int value) { + + passiveNodeSize_ = value; + onChanged(); + return this; + } + /** + * int32 passiveNodeSize = 6; + */ + public Builder clearPassiveNodeSize() { + + passiveNodeSize_ = 0; + onChanged(); + return this; + } + + private int sendNodeSize_ ; + /** + * int32 sendNodeSize = 7; + */ + public int getSendNodeSize() { + return sendNodeSize_; + } + /** + * int32 sendNodeSize = 7; + */ + public Builder setSendNodeSize(int value) { + + sendNodeSize_ = value; + onChanged(); + return this; + } + /** + * int32 sendNodeSize = 7; + */ + public Builder clearSendNodeSize() { + + sendNodeSize_ = 0; + onChanged(); + return this; + } + + private int maxConnectCount_ ; + /** + * int32 maxConnectCount = 8; + */ + public int getMaxConnectCount() { + return maxConnectCount_; + } + /** + * int32 maxConnectCount = 8; + */ + public Builder setMaxConnectCount(int value) { + + maxConnectCount_ = value; + onChanged(); + return this; + } + /** + * int32 maxConnectCount = 8; + */ + public Builder clearMaxConnectCount() { + + maxConnectCount_ = 0; + onChanged(); + return this; + } + + private int sameIpMaxConnectCount_ ; + /** + * int32 sameIpMaxConnectCount = 9; + */ + public int getSameIpMaxConnectCount() { + return sameIpMaxConnectCount_; + } + /** + * int32 sameIpMaxConnectCount = 9; + */ + public Builder setSameIpMaxConnectCount(int value) { + + sameIpMaxConnectCount_ = value; + onChanged(); + return this; + } + /** + * int32 sameIpMaxConnectCount = 9; + */ + public Builder clearSameIpMaxConnectCount() { + + sameIpMaxConnectCount_ = 0; + onChanged(); + return this; + } + + private int backupListenPort_ ; + /** + * int32 backupListenPort = 10; + */ + public int getBackupListenPort() { + return backupListenPort_; + } + /** + * int32 backupListenPort = 10; + */ + public Builder setBackupListenPort(int value) { + + backupListenPort_ = value; + onChanged(); + return this; + } + /** + * int32 backupListenPort = 10; + */ + public Builder clearBackupListenPort() { + + backupListenPort_ = 0; + onChanged(); + return this; + } + + private int backupMemberSize_ ; + /** + * int32 backupMemberSize = 11; + */ + public int getBackupMemberSize() { + return backupMemberSize_; + } + /** + * int32 backupMemberSize = 11; + */ + public Builder setBackupMemberSize(int value) { + + backupMemberSize_ = value; + onChanged(); + return this; + } + /** + * int32 backupMemberSize = 11; + */ + public Builder clearBackupMemberSize() { + + backupMemberSize_ = 0; + onChanged(); + return this; + } + + private int backupPriority_ ; + /** + * int32 backupPriority = 12; + */ + public int getBackupPriority() { + return backupPriority_; + } + /** + * int32 backupPriority = 12; + */ + public Builder setBackupPriority(int value) { + + backupPriority_ = value; + onChanged(); + return this; + } + /** + * int32 backupPriority = 12; + */ + public Builder clearBackupPriority() { + + backupPriority_ = 0; + onChanged(); + return this; + } + + private int dbVersion_ ; + /** + * int32 dbVersion = 13; + */ + public int getDbVersion() { + return dbVersion_; + } + /** + * int32 dbVersion = 13; + */ + public Builder setDbVersion(int value) { + + dbVersion_ = value; + onChanged(); + return this; + } + /** + * int32 dbVersion = 13; + */ + public Builder clearDbVersion() { + + dbVersion_ = 0; + onChanged(); + return this; + } + + private int minParticipationRate_ ; + /** + * int32 minParticipationRate = 14; + */ + public int getMinParticipationRate() { + return minParticipationRate_; + } + /** + * int32 minParticipationRate = 14; + */ + public Builder setMinParticipationRate(int value) { + + minParticipationRate_ = value; + onChanged(); + return this; + } + /** + * int32 minParticipationRate = 14; + */ + public Builder clearMinParticipationRate() { + + minParticipationRate_ = 0; + onChanged(); + return this; + } + + private boolean supportConstant_ ; + /** + * bool supportConstant = 15; + */ + public boolean getSupportConstant() { + return supportConstant_; + } + /** + * bool supportConstant = 15; + */ + public Builder setSupportConstant(boolean value) { + + supportConstant_ = value; + onChanged(); + return this; + } + /** + * bool supportConstant = 15; + */ + public Builder clearSupportConstant() { + + supportConstant_ = false; + onChanged(); + return this; + } + + private double minTimeRatio_ ; + /** + * double minTimeRatio = 16; + */ + public double getMinTimeRatio() { + return minTimeRatio_; + } + /** + * double minTimeRatio = 16; + */ + public Builder setMinTimeRatio(double value) { + + minTimeRatio_ = value; + onChanged(); + return this; + } + /** + * double minTimeRatio = 16; + */ + public Builder clearMinTimeRatio() { + + minTimeRatio_ = 0D; + onChanged(); + return this; + } + + private double maxTimeRatio_ ; + /** + * double maxTimeRatio = 17; + */ + public double getMaxTimeRatio() { + return maxTimeRatio_; + } + /** + * double maxTimeRatio = 17; + */ + public Builder setMaxTimeRatio(double value) { + + maxTimeRatio_ = value; + onChanged(); + return this; + } + /** + * double maxTimeRatio = 17; + */ + public Builder clearMaxTimeRatio() { + + maxTimeRatio_ = 0D; + onChanged(); + return this; + } + + private long allowCreationOfContracts_ ; + /** + * int64 allowCreationOfContracts = 18; + */ + public long getAllowCreationOfContracts() { + return allowCreationOfContracts_; + } + /** + * int64 allowCreationOfContracts = 18; + */ + public Builder setAllowCreationOfContracts(long value) { + + allowCreationOfContracts_ = value; + onChanged(); + return this; + } + /** + * int64 allowCreationOfContracts = 18; + */ + public Builder clearAllowCreationOfContracts() { + + allowCreationOfContracts_ = 0L; + onChanged(); + return this; + } + + private long allowAdaptiveEnergy_ ; + /** + * int64 allowAdaptiveEnergy = 19; + */ + public long getAllowAdaptiveEnergy() { + return allowAdaptiveEnergy_; + } + /** + * int64 allowAdaptiveEnergy = 19; + */ + public Builder setAllowAdaptiveEnergy(long value) { + + allowAdaptiveEnergy_ = value; + onChanged(); + return this; + } + /** + * int64 allowAdaptiveEnergy = 19; + */ + public Builder clearAllowAdaptiveEnergy() { + + allowAdaptiveEnergy_ = 0L; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NodeInfo.ConfigNodeInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.NodeInfo.ConfigNodeInfo) + private static final org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo(); + } + + public static org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ConfigNodeInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ConfigNodeInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface MachineInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NodeInfo.MachineInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 threadCount = 1; + */ + int getThreadCount(); + + /** + * int32 deadLockThreadCount = 2; + */ + int getDeadLockThreadCount(); + + /** + * int32 cpuCount = 3; + */ + int getCpuCount(); + + /** + * int64 totalMemory = 4; + */ + long getTotalMemory(); + + /** + * int64 freeMemory = 5; + */ + long getFreeMemory(); + + /** + * double cpuRate = 6; + */ + double getCpuRate(); + + /** + * string javaVersion = 7; + */ + java.lang.String getJavaVersion(); + /** + * string javaVersion = 7; + */ + com.google.protobuf.ByteString + getJavaVersionBytes(); + + /** + * string osName = 8; + */ + java.lang.String getOsName(); + /** + * string osName = 8; + */ + com.google.protobuf.ByteString + getOsNameBytes(); + + /** + * int64 jvmTotalMemoery = 9; + */ + long getJvmTotalMemoery(); + + /** + * int64 jvmFreeMemory = 10; + */ + long getJvmFreeMemory(); + + /** + * double processCpuRate = 11; + */ + double getProcessCpuRate(); + + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + java.util.List + getMemoryDescInfoListList(); + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo getMemoryDescInfoList(int index); + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + int getMemoryDescInfoListCount(); + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + java.util.List + getMemoryDescInfoListOrBuilderList(); + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfoOrBuilder getMemoryDescInfoListOrBuilder( + int index); + + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + java.util.List + getDeadLockThreadInfoListList(); + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo getDeadLockThreadInfoList(int index); + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + int getDeadLockThreadInfoListCount(); + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + java.util.List + getDeadLockThreadInfoListOrBuilderList(); + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfoOrBuilder getDeadLockThreadInfoListOrBuilder( + int index); + } + /** + * Protobuf type {@code protocol.NodeInfo.MachineInfo} + */ + public static final class MachineInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NodeInfo.MachineInfo) + MachineInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use MachineInfo.newBuilder() to construct. + private MachineInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MachineInfo() { + threadCount_ = 0; + deadLockThreadCount_ = 0; + cpuCount_ = 0; + totalMemory_ = 0L; + freeMemory_ = 0L; + cpuRate_ = 0D; + javaVersion_ = ""; + osName_ = ""; + jvmTotalMemoery_ = 0L; + jvmFreeMemory_ = 0L; + processCpuRate_ = 0D; + memoryDescInfoList_ = java.util.Collections.emptyList(); + deadLockThreadInfoList_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MachineInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + threadCount_ = input.readInt32(); + break; + } + case 16: { + + deadLockThreadCount_ = input.readInt32(); + break; + } + case 24: { + + cpuCount_ = input.readInt32(); + break; + } + case 32: { + + totalMemory_ = input.readInt64(); + break; + } + case 40: { + + freeMemory_ = input.readInt64(); + break; + } + case 49: { + + cpuRate_ = input.readDouble(); + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + + javaVersion_ = s; + break; + } + case 66: { + java.lang.String s = input.readStringRequireUtf8(); + + osName_ = s; + break; + } + case 72: { + + jvmTotalMemoery_ = input.readInt64(); + break; + } + case 80: { + + jvmFreeMemory_ = input.readInt64(); + break; + } + case 89: { + + processCpuRate_ = input.readDouble(); + break; + } + case 98: { + if (!((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + memoryDescInfoList_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000800; + } + memoryDescInfoList_.add( + input.readMessage(org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.parser(), extensionRegistry)); + break; + } + case 106: { + if (!((mutable_bitField0_ & 0x00001000) == 0x00001000)) { + deadLockThreadInfoList_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00001000; + } + deadLockThreadInfoList_.add( + input.readMessage(org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + memoryDescInfoList_ = java.util.Collections.unmodifiableList(memoryDescInfoList_); + } + if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) { + deadLockThreadInfoList_ = java.util.Collections.unmodifiableList(deadLockThreadInfoList_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.MachineInfo.class, org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder.class); + } + + public interface MemoryDescInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NodeInfo.MachineInfo.MemoryDescInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + */ + java.lang.String getName(); + /** + * string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * int64 initSize = 2; + */ + long getInitSize(); + + /** + * int64 useSize = 3; + */ + long getUseSize(); + + /** + * int64 maxSize = 4; + */ + long getMaxSize(); + + /** + * double useRate = 5; + */ + double getUseRate(); + } + /** + * Protobuf type {@code protocol.NodeInfo.MachineInfo.MemoryDescInfo} + */ + public static final class MemoryDescInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NodeInfo.MachineInfo.MemoryDescInfo) + MemoryDescInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use MemoryDescInfo.newBuilder() to construct. + private MemoryDescInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MemoryDescInfo() { + name_ = ""; + initSize_ = 0L; + useSize_ = 0L; + maxSize_ = 0L; + useRate_ = 0D; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MemoryDescInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 16: { + + initSize_ = input.readInt64(); + break; + } + case 24: { + + useSize_ = input.readInt64(); + break; + } + case 32: { + + maxSize_ = input.readInt64(); + break; + } + case 41: { + + useRate_ = input.readDouble(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.class, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INITSIZE_FIELD_NUMBER = 2; + private long initSize_; + /** + * int64 initSize = 2; + */ + public long getInitSize() { + return initSize_; + } + + public static final int USESIZE_FIELD_NUMBER = 3; + private long useSize_; + /** + * int64 useSize = 3; + */ + public long getUseSize() { + return useSize_; + } + + public static final int MAXSIZE_FIELD_NUMBER = 4; + private long maxSize_; + /** + * int64 maxSize = 4; + */ + public long getMaxSize() { + return maxSize_; + } + + public static final int USERATE_FIELD_NUMBER = 5; + private double useRate_; + /** + * double useRate = 5; + */ + public double getUseRate() { + return useRate_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (initSize_ != 0L) { + output.writeInt64(2, initSize_); + } + if (useSize_ != 0L) { + output.writeInt64(3, useSize_); + } + if (maxSize_ != 0L) { + output.writeInt64(4, maxSize_); + } + if (useRate_ != 0D) { + output.writeDouble(5, useRate_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (initSize_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, initSize_); + } + if (useSize_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, useSize_); + } + if (maxSize_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, maxSize_); + } + if (useRate_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(5, useRate_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo other = (org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && (getInitSize() + == other.getInitSize()); + result = result && (getUseSize() + == other.getUseSize()); + result = result && (getMaxSize() + == other.getMaxSize()); + result = result && ( + java.lang.Double.doubleToLongBits(getUseRate()) + == java.lang.Double.doubleToLongBits( + other.getUseRate())); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + INITSIZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getInitSize()); + hash = (37 * hash) + USESIZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getUseSize()); + hash = (37 * hash) + MAXSIZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getMaxSize()); + hash = (37 * hash) + USERATE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getUseRate())); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.NodeInfo.MachineInfo.MemoryDescInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NodeInfo.MachineInfo.MemoryDescInfo) + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.class, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + initSize_ = 0L; + + useSize_ = 0L; + + maxSize_ = 0L; + + useRate_ = 0D; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_descriptor; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo build() { + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo buildPartial() { + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo result = new org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo(this); + result.name_ = name_; + result.initSize_ = initSize_; + result.useSize_ = useSize_; + result.maxSize_ = maxSize_; + result.useRate_ = useRate_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo) { + return mergeFrom((org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo other) { + if (other == org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.getInitSize() != 0L) { + setInitSize(other.getInitSize()); + } + if (other.getUseSize() != 0L) { + setUseSize(other.getUseSize()); + } + if (other.getMaxSize() != 0L) { + setMaxSize(other.getMaxSize()); + } + if (other.getUseRate() != 0D) { + setUseRate(other.getUseRate()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private long initSize_ ; + /** + * int64 initSize = 2; + */ + public long getInitSize() { + return initSize_; + } + /** + * int64 initSize = 2; + */ + public Builder setInitSize(long value) { + + initSize_ = value; + onChanged(); + return this; + } + /** + * int64 initSize = 2; + */ + public Builder clearInitSize() { + + initSize_ = 0L; + onChanged(); + return this; + } + + private long useSize_ ; + /** + * int64 useSize = 3; + */ + public long getUseSize() { + return useSize_; + } + /** + * int64 useSize = 3; + */ + public Builder setUseSize(long value) { + + useSize_ = value; + onChanged(); + return this; + } + /** + * int64 useSize = 3; + */ + public Builder clearUseSize() { + + useSize_ = 0L; + onChanged(); + return this; + } + + private long maxSize_ ; + /** + * int64 maxSize = 4; + */ + public long getMaxSize() { + return maxSize_; + } + /** + * int64 maxSize = 4; + */ + public Builder setMaxSize(long value) { + + maxSize_ = value; + onChanged(); + return this; + } + /** + * int64 maxSize = 4; + */ + public Builder clearMaxSize() { + + maxSize_ = 0L; + onChanged(); + return this; + } + + private double useRate_ ; + /** + * double useRate = 5; + */ + public double getUseRate() { + return useRate_; + } + /** + * double useRate = 5; + */ + public Builder setUseRate(double value) { + + useRate_ = value; + onChanged(); + return this; + } + /** + * double useRate = 5; + */ + public Builder clearUseRate() { + + useRate_ = 0D; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NodeInfo.MachineInfo.MemoryDescInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.NodeInfo.MachineInfo.MemoryDescInfo) + private static final org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo(); + } + + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public MemoryDescInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MemoryDescInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DeadLockThreadInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + */ + java.lang.String getName(); + /** + * string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * string lockName = 2; + */ + java.lang.String getLockName(); + /** + * string lockName = 2; + */ + com.google.protobuf.ByteString + getLockNameBytes(); + + /** + * string lockOwner = 3; + */ + java.lang.String getLockOwner(); + /** + * string lockOwner = 3; + */ + com.google.protobuf.ByteString + getLockOwnerBytes(); + + /** + * string state = 4; + */ + java.lang.String getState(); + /** + * string state = 4; + */ + com.google.protobuf.ByteString + getStateBytes(); + + /** + * int64 blockTime = 5; + */ + long getBlockTime(); + + /** + * int64 waitTime = 6; + */ + long getWaitTime(); + + /** + * string stackTrace = 7; + */ + java.lang.String getStackTrace(); + /** + * string stackTrace = 7; + */ + com.google.protobuf.ByteString + getStackTraceBytes(); + } + /** + * Protobuf type {@code protocol.NodeInfo.MachineInfo.DeadLockThreadInfo} + */ + public static final class DeadLockThreadInfo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) + DeadLockThreadInfoOrBuilder { + private static final long serialVersionUID = 0L; + // Use DeadLockThreadInfo.newBuilder() to construct. + private DeadLockThreadInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DeadLockThreadInfo() { + name_ = ""; + lockName_ = ""; + lockOwner_ = ""; + state_ = ""; + blockTime_ = 0L; + waitTime_ = 0L; + stackTrace_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DeadLockThreadInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + lockName_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + lockOwner_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + state_ = s; + break; + } + case 40: { + + blockTime_ = input.readInt64(); + break; + } + case 48: { + + waitTime_ = input.readInt64(); + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + + stackTrace_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.class, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LOCKNAME_FIELD_NUMBER = 2; + private volatile java.lang.Object lockName_; + /** + * string lockName = 2; + */ + public java.lang.String getLockName() { + java.lang.Object ref = lockName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + lockName_ = s; + return s; + } + } + /** + * string lockName = 2; + */ + public com.google.protobuf.ByteString + getLockNameBytes() { + java.lang.Object ref = lockName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + lockName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LOCKOWNER_FIELD_NUMBER = 3; + private volatile java.lang.Object lockOwner_; + /** + * string lockOwner = 3; + */ + public java.lang.String getLockOwner() { + java.lang.Object ref = lockOwner_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + lockOwner_ = s; + return s; + } + } + /** + * string lockOwner = 3; + */ + public com.google.protobuf.ByteString + getLockOwnerBytes() { + java.lang.Object ref = lockOwner_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + lockOwner_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STATE_FIELD_NUMBER = 4; + private volatile java.lang.Object state_; + /** + * string state = 4; + */ + public java.lang.String getState() { + java.lang.Object ref = state_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + state_ = s; + return s; + } + } + /** + * string state = 4; + */ + public com.google.protobuf.ByteString + getStateBytes() { + java.lang.Object ref = state_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + state_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BLOCKTIME_FIELD_NUMBER = 5; + private long blockTime_; + /** + * int64 blockTime = 5; + */ + public long getBlockTime() { + return blockTime_; + } + + public static final int WAITTIME_FIELD_NUMBER = 6; + private long waitTime_; + /** + * int64 waitTime = 6; + */ + public long getWaitTime() { + return waitTime_; + } + + public static final int STACKTRACE_FIELD_NUMBER = 7; + private volatile java.lang.Object stackTrace_; + /** + * string stackTrace = 7; + */ + public java.lang.String getStackTrace() { + java.lang.Object ref = stackTrace_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + stackTrace_ = s; + return s; + } + } + /** + * string stackTrace = 7; + */ + public com.google.protobuf.ByteString + getStackTraceBytes() { + java.lang.Object ref = stackTrace_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + stackTrace_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (!getLockNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, lockName_); + } + if (!getLockOwnerBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, lockOwner_); + } + if (!getStateBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, state_); + } + if (blockTime_ != 0L) { + output.writeInt64(5, blockTime_); + } + if (waitTime_ != 0L) { + output.writeInt64(6, waitTime_); + } + if (!getStackTraceBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, stackTrace_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (!getLockNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, lockName_); + } + if (!getLockOwnerBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, lockOwner_); + } + if (!getStateBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, state_); + } + if (blockTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, blockTime_); + } + if (waitTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(6, waitTime_); + } + if (!getStackTraceBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, stackTrace_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo other = (org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && getLockName() + .equals(other.getLockName()); + result = result && getLockOwner() + .equals(other.getLockOwner()); + result = result && getState() + .equals(other.getState()); + result = result && (getBlockTime() + == other.getBlockTime()); + result = result && (getWaitTime() + == other.getWaitTime()); + result = result && getStackTrace() + .equals(other.getStackTrace()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + LOCKNAME_FIELD_NUMBER; + hash = (53 * hash) + getLockName().hashCode(); + hash = (37 * hash) + LOCKOWNER_FIELD_NUMBER; + hash = (53 * hash) + getLockOwner().hashCode(); + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + getState().hashCode(); + hash = (37 * hash) + BLOCKTIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBlockTime()); + hash = (37 * hash) + WAITTIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getWaitTime()); + hash = (37 * hash) + STACKTRACE_FIELD_NUMBER; + hash = (53 * hash) + getStackTrace().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.NodeInfo.MachineInfo.DeadLockThreadInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.class, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + lockName_ = ""; + + lockOwner_ = ""; + + state_ = ""; + + blockTime_ = 0L; + + waitTime_ = 0L; + + stackTrace_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_descriptor; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo build() { + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo buildPartial() { + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo result = new org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo(this); + result.name_ = name_; + result.lockName_ = lockName_; + result.lockOwner_ = lockOwner_; + result.state_ = state_; + result.blockTime_ = blockTime_; + result.waitTime_ = waitTime_; + result.stackTrace_ = stackTrace_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) { + return mergeFrom((org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo other) { + if (other == org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getLockName().isEmpty()) { + lockName_ = other.lockName_; + onChanged(); + } + if (!other.getLockOwner().isEmpty()) { + lockOwner_ = other.lockOwner_; + onChanged(); + } + if (!other.getState().isEmpty()) { + state_ = other.state_; + onChanged(); + } + if (other.getBlockTime() != 0L) { + setBlockTime(other.getBlockTime()); + } + if (other.getWaitTime() != 0L) { + setWaitTime(other.getWaitTime()); + } + if (!other.getStackTrace().isEmpty()) { + stackTrace_ = other.stackTrace_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object lockName_ = ""; + /** + * string lockName = 2; + */ + public java.lang.String getLockName() { + java.lang.Object ref = lockName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + lockName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string lockName = 2; + */ + public com.google.protobuf.ByteString + getLockNameBytes() { + java.lang.Object ref = lockName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + lockName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string lockName = 2; + */ + public Builder setLockName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + lockName_ = value; + onChanged(); + return this; + } + /** + * string lockName = 2; + */ + public Builder clearLockName() { + + lockName_ = getDefaultInstance().getLockName(); + onChanged(); + return this; + } + /** + * string lockName = 2; + */ + public Builder setLockNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + lockName_ = value; + onChanged(); + return this; + } + + private java.lang.Object lockOwner_ = ""; + /** + * string lockOwner = 3; + */ + public java.lang.String getLockOwner() { + java.lang.Object ref = lockOwner_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + lockOwner_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string lockOwner = 3; + */ + public com.google.protobuf.ByteString + getLockOwnerBytes() { + java.lang.Object ref = lockOwner_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + lockOwner_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string lockOwner = 3; + */ + public Builder setLockOwner( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + lockOwner_ = value; + onChanged(); + return this; + } + /** + * string lockOwner = 3; + */ + public Builder clearLockOwner() { + + lockOwner_ = getDefaultInstance().getLockOwner(); + onChanged(); + return this; + } + /** + * string lockOwner = 3; + */ + public Builder setLockOwnerBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + lockOwner_ = value; + onChanged(); + return this; + } + + private java.lang.Object state_ = ""; + /** + * string state = 4; + */ + public java.lang.String getState() { + java.lang.Object ref = state_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + state_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string state = 4; + */ + public com.google.protobuf.ByteString + getStateBytes() { + java.lang.Object ref = state_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + state_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string state = 4; + */ + public Builder setState( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + state_ = value; + onChanged(); + return this; + } + /** + * string state = 4; + */ + public Builder clearState() { + + state_ = getDefaultInstance().getState(); + onChanged(); + return this; + } + /** + * string state = 4; + */ + public Builder setStateBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + state_ = value; + onChanged(); + return this; + } + + private long blockTime_ ; + /** + * int64 blockTime = 5; + */ + public long getBlockTime() { + return blockTime_; + } + /** + * int64 blockTime = 5; + */ + public Builder setBlockTime(long value) { + + blockTime_ = value; + onChanged(); + return this; + } + /** + * int64 blockTime = 5; + */ + public Builder clearBlockTime() { + + blockTime_ = 0L; + onChanged(); + return this; + } + + private long waitTime_ ; + /** + * int64 waitTime = 6; + */ + public long getWaitTime() { + return waitTime_; + } + /** + * int64 waitTime = 6; + */ + public Builder setWaitTime(long value) { + + waitTime_ = value; + onChanged(); + return this; + } + /** + * int64 waitTime = 6; + */ + public Builder clearWaitTime() { + + waitTime_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object stackTrace_ = ""; + /** + * string stackTrace = 7; + */ + public java.lang.String getStackTrace() { + java.lang.Object ref = stackTrace_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + stackTrace_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string stackTrace = 7; + */ + public com.google.protobuf.ByteString + getStackTraceBytes() { + java.lang.Object ref = stackTrace_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + stackTrace_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string stackTrace = 7; + */ + public Builder setStackTrace( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + stackTrace_ = value; + onChanged(); + return this; + } + /** + * string stackTrace = 7; + */ + public Builder clearStackTrace() { + + stackTrace_ = getDefaultInstance().getStackTrace(); + onChanged(); + return this; + } + /** + * string stackTrace = 7; + */ + public Builder setStackTraceBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + stackTrace_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.NodeInfo.MachineInfo.DeadLockThreadInfo) + private static final org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo(); + } + + public static org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DeadLockThreadInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DeadLockThreadInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int THREADCOUNT_FIELD_NUMBER = 1; + private int threadCount_; + /** + * int32 threadCount = 1; + */ + public int getThreadCount() { + return threadCount_; + } + + public static final int DEADLOCKTHREADCOUNT_FIELD_NUMBER = 2; + private int deadLockThreadCount_; + /** + * int32 deadLockThreadCount = 2; + */ + public int getDeadLockThreadCount() { + return deadLockThreadCount_; + } + + public static final int CPUCOUNT_FIELD_NUMBER = 3; + private int cpuCount_; + /** + * int32 cpuCount = 3; + */ + public int getCpuCount() { + return cpuCount_; + } + + public static final int TOTALMEMORY_FIELD_NUMBER = 4; + private long totalMemory_; + /** + * int64 totalMemory = 4; + */ + public long getTotalMemory() { + return totalMemory_; + } + + public static final int FREEMEMORY_FIELD_NUMBER = 5; + private long freeMemory_; + /** + * int64 freeMemory = 5; + */ + public long getFreeMemory() { + return freeMemory_; + } + + public static final int CPURATE_FIELD_NUMBER = 6; + private double cpuRate_; + /** + * double cpuRate = 6; + */ + public double getCpuRate() { + return cpuRate_; + } + + public static final int JAVAVERSION_FIELD_NUMBER = 7; + private volatile java.lang.Object javaVersion_; + /** + * string javaVersion = 7; + */ + public java.lang.String getJavaVersion() { + java.lang.Object ref = javaVersion_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + javaVersion_ = s; + return s; + } + } + /** + * string javaVersion = 7; + */ + public com.google.protobuf.ByteString + getJavaVersionBytes() { + java.lang.Object ref = javaVersion_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + javaVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OSNAME_FIELD_NUMBER = 8; + private volatile java.lang.Object osName_; + /** + * string osName = 8; + */ + public java.lang.String getOsName() { + java.lang.Object ref = osName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + osName_ = s; + return s; + } + } + /** + * string osName = 8; + */ + public com.google.protobuf.ByteString + getOsNameBytes() { + java.lang.Object ref = osName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + osName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int JVMTOTALMEMOERY_FIELD_NUMBER = 9; + private long jvmTotalMemoery_; + /** + * int64 jvmTotalMemoery = 9; + */ + public long getJvmTotalMemoery() { + return jvmTotalMemoery_; + } + + public static final int JVMFREEMEMORY_FIELD_NUMBER = 10; + private long jvmFreeMemory_; + /** + * int64 jvmFreeMemory = 10; + */ + public long getJvmFreeMemory() { + return jvmFreeMemory_; + } + + public static final int PROCESSCPURATE_FIELD_NUMBER = 11; + private double processCpuRate_; + /** + * double processCpuRate = 11; + */ + public double getProcessCpuRate() { + return processCpuRate_; + } + + public static final int MEMORYDESCINFOLIST_FIELD_NUMBER = 12; + private java.util.List memoryDescInfoList_; + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public java.util.List getMemoryDescInfoListList() { + return memoryDescInfoList_; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public java.util.List + getMemoryDescInfoListOrBuilderList() { + return memoryDescInfoList_; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public int getMemoryDescInfoListCount() { + return memoryDescInfoList_.size(); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo getMemoryDescInfoList(int index) { + return memoryDescInfoList_.get(index); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfoOrBuilder getMemoryDescInfoListOrBuilder( + int index) { + return memoryDescInfoList_.get(index); + } + + public static final int DEADLOCKTHREADINFOLIST_FIELD_NUMBER = 13; + private java.util.List deadLockThreadInfoList_; + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public java.util.List getDeadLockThreadInfoListList() { + return deadLockThreadInfoList_; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public java.util.List + getDeadLockThreadInfoListOrBuilderList() { + return deadLockThreadInfoList_; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public int getDeadLockThreadInfoListCount() { + return deadLockThreadInfoList_.size(); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo getDeadLockThreadInfoList(int index) { + return deadLockThreadInfoList_.get(index); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfoOrBuilder getDeadLockThreadInfoListOrBuilder( + int index) { + return deadLockThreadInfoList_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (threadCount_ != 0) { + output.writeInt32(1, threadCount_); + } + if (deadLockThreadCount_ != 0) { + output.writeInt32(2, deadLockThreadCount_); + } + if (cpuCount_ != 0) { + output.writeInt32(3, cpuCount_); + } + if (totalMemory_ != 0L) { + output.writeInt64(4, totalMemory_); + } + if (freeMemory_ != 0L) { + output.writeInt64(5, freeMemory_); + } + if (cpuRate_ != 0D) { + output.writeDouble(6, cpuRate_); + } + if (!getJavaVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, javaVersion_); + } + if (!getOsNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, osName_); + } + if (jvmTotalMemoery_ != 0L) { + output.writeInt64(9, jvmTotalMemoery_); + } + if (jvmFreeMemory_ != 0L) { + output.writeInt64(10, jvmFreeMemory_); + } + if (processCpuRate_ != 0D) { + output.writeDouble(11, processCpuRate_); + } + for (int i = 0; i < memoryDescInfoList_.size(); i++) { + output.writeMessage(12, memoryDescInfoList_.get(i)); + } + for (int i = 0; i < deadLockThreadInfoList_.size(); i++) { + output.writeMessage(13, deadLockThreadInfoList_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (threadCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, threadCount_); + } + if (deadLockThreadCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, deadLockThreadCount_); + } + if (cpuCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, cpuCount_); + } + if (totalMemory_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, totalMemory_); + } + if (freeMemory_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, freeMemory_); + } + if (cpuRate_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(6, cpuRate_); + } + if (!getJavaVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, javaVersion_); + } + if (!getOsNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, osName_); + } + if (jvmTotalMemoery_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(9, jvmTotalMemoery_); + } + if (jvmFreeMemory_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(10, jvmFreeMemory_); + } + if (processCpuRate_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(11, processCpuRate_); + } + for (int i = 0; i < memoryDescInfoList_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(12, memoryDescInfoList_.get(i)); + } + for (int i = 0; i < deadLockThreadInfoList_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(13, deadLockThreadInfoList_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.NodeInfo.MachineInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.NodeInfo.MachineInfo other = (org.tron.protos.Protocol.NodeInfo.MachineInfo) obj; + + boolean result = true; + result = result && (getThreadCount() + == other.getThreadCount()); + result = result && (getDeadLockThreadCount() + == other.getDeadLockThreadCount()); + result = result && (getCpuCount() + == other.getCpuCount()); + result = result && (getTotalMemory() + == other.getTotalMemory()); + result = result && (getFreeMemory() + == other.getFreeMemory()); + result = result && ( + java.lang.Double.doubleToLongBits(getCpuRate()) + == java.lang.Double.doubleToLongBits( + other.getCpuRate())); + result = result && getJavaVersion() + .equals(other.getJavaVersion()); + result = result && getOsName() + .equals(other.getOsName()); + result = result && (getJvmTotalMemoery() + == other.getJvmTotalMemoery()); + result = result && (getJvmFreeMemory() + == other.getJvmFreeMemory()); + result = result && ( + java.lang.Double.doubleToLongBits(getProcessCpuRate()) + == java.lang.Double.doubleToLongBits( + other.getProcessCpuRate())); + result = result && getMemoryDescInfoListList() + .equals(other.getMemoryDescInfoListList()); + result = result && getDeadLockThreadInfoListList() + .equals(other.getDeadLockThreadInfoListList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + THREADCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getThreadCount(); + hash = (37 * hash) + DEADLOCKTHREADCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getDeadLockThreadCount(); + hash = (37 * hash) + CPUCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getCpuCount(); + hash = (37 * hash) + TOTALMEMORY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalMemory()); + hash = (37 * hash) + FREEMEMORY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFreeMemory()); + hash = (37 * hash) + CPURATE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getCpuRate())); + hash = (37 * hash) + JAVAVERSION_FIELD_NUMBER; + hash = (53 * hash) + getJavaVersion().hashCode(); + hash = (37 * hash) + OSNAME_FIELD_NUMBER; + hash = (53 * hash) + getOsName().hashCode(); + hash = (37 * hash) + JVMTOTALMEMOERY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getJvmTotalMemoery()); + hash = (37 * hash) + JVMFREEMEMORY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getJvmFreeMemory()); + hash = (37 * hash) + PROCESSCPURATE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getProcessCpuRate())); + if (getMemoryDescInfoListCount() > 0) { + hash = (37 * hash) + MEMORYDESCINFOLIST_FIELD_NUMBER; + hash = (53 * hash) + getMemoryDescInfoListList().hashCode(); + } + if (getDeadLockThreadInfoListCount() > 0) { + hash = (37 * hash) + DEADLOCKTHREADINFOLIST_FIELD_NUMBER; + hash = (53 * hash) + getDeadLockThreadInfoListList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo.MachineInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.NodeInfo.MachineInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.NodeInfo.MachineInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NodeInfo.MachineInfo) + org.tron.protos.Protocol.NodeInfo.MachineInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.MachineInfo.class, org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.NodeInfo.MachineInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getMemoryDescInfoListFieldBuilder(); + getDeadLockThreadInfoListFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + threadCount_ = 0; + + deadLockThreadCount_ = 0; + + cpuCount_ = 0; + + totalMemory_ = 0L; + + freeMemory_ = 0L; + + cpuRate_ = 0D; + + javaVersion_ = ""; + + osName_ = ""; + + jvmTotalMemoery_ = 0L; + + jvmFreeMemory_ = 0L; + + processCpuRate_ = 0D; + + if (memoryDescInfoListBuilder_ == null) { + memoryDescInfoList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000800); + } else { + memoryDescInfoListBuilder_.clear(); + } + if (deadLockThreadInfoListBuilder_ == null) { + deadLockThreadInfoList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00001000); + } else { + deadLockThreadInfoListBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_MachineInfo_descriptor; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.NodeInfo.MachineInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo build() { + org.tron.protos.Protocol.NodeInfo.MachineInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo buildPartial() { + org.tron.protos.Protocol.NodeInfo.MachineInfo result = new org.tron.protos.Protocol.NodeInfo.MachineInfo(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.threadCount_ = threadCount_; + result.deadLockThreadCount_ = deadLockThreadCount_; + result.cpuCount_ = cpuCount_; + result.totalMemory_ = totalMemory_; + result.freeMemory_ = freeMemory_; + result.cpuRate_ = cpuRate_; + result.javaVersion_ = javaVersion_; + result.osName_ = osName_; + result.jvmTotalMemoery_ = jvmTotalMemoery_; + result.jvmFreeMemory_ = jvmFreeMemory_; + result.processCpuRate_ = processCpuRate_; + if (memoryDescInfoListBuilder_ == null) { + if (((bitField0_ & 0x00000800) == 0x00000800)) { + memoryDescInfoList_ = java.util.Collections.unmodifiableList(memoryDescInfoList_); + bitField0_ = (bitField0_ & ~0x00000800); + } + result.memoryDescInfoList_ = memoryDescInfoList_; + } else { + result.memoryDescInfoList_ = memoryDescInfoListBuilder_.build(); + } + if (deadLockThreadInfoListBuilder_ == null) { + if (((bitField0_ & 0x00001000) == 0x00001000)) { + deadLockThreadInfoList_ = java.util.Collections.unmodifiableList(deadLockThreadInfoList_); + bitField0_ = (bitField0_ & ~0x00001000); + } + result.deadLockThreadInfoList_ = deadLockThreadInfoList_; + } else { + result.deadLockThreadInfoList_ = deadLockThreadInfoListBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.NodeInfo.MachineInfo) { + return mergeFrom((org.tron.protos.Protocol.NodeInfo.MachineInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.NodeInfo.MachineInfo other) { + if (other == org.tron.protos.Protocol.NodeInfo.MachineInfo.getDefaultInstance()) return this; + if (other.getThreadCount() != 0) { + setThreadCount(other.getThreadCount()); + } + if (other.getDeadLockThreadCount() != 0) { + setDeadLockThreadCount(other.getDeadLockThreadCount()); + } + if (other.getCpuCount() != 0) { + setCpuCount(other.getCpuCount()); + } + if (other.getTotalMemory() != 0L) { + setTotalMemory(other.getTotalMemory()); + } + if (other.getFreeMemory() != 0L) { + setFreeMemory(other.getFreeMemory()); + } + if (other.getCpuRate() != 0D) { + setCpuRate(other.getCpuRate()); + } + if (!other.getJavaVersion().isEmpty()) { + javaVersion_ = other.javaVersion_; + onChanged(); + } + if (!other.getOsName().isEmpty()) { + osName_ = other.osName_; + onChanged(); + } + if (other.getJvmTotalMemoery() != 0L) { + setJvmTotalMemoery(other.getJvmTotalMemoery()); + } + if (other.getJvmFreeMemory() != 0L) { + setJvmFreeMemory(other.getJvmFreeMemory()); + } + if (other.getProcessCpuRate() != 0D) { + setProcessCpuRate(other.getProcessCpuRate()); + } + if (memoryDescInfoListBuilder_ == null) { + if (!other.memoryDescInfoList_.isEmpty()) { + if (memoryDescInfoList_.isEmpty()) { + memoryDescInfoList_ = other.memoryDescInfoList_; + bitField0_ = (bitField0_ & ~0x00000800); + } else { + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.addAll(other.memoryDescInfoList_); + } + onChanged(); + } + } else { + if (!other.memoryDescInfoList_.isEmpty()) { + if (memoryDescInfoListBuilder_.isEmpty()) { + memoryDescInfoListBuilder_.dispose(); + memoryDescInfoListBuilder_ = null; + memoryDescInfoList_ = other.memoryDescInfoList_; + bitField0_ = (bitField0_ & ~0x00000800); + memoryDescInfoListBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getMemoryDescInfoListFieldBuilder() : null; + } else { + memoryDescInfoListBuilder_.addAllMessages(other.memoryDescInfoList_); + } + } + } + if (deadLockThreadInfoListBuilder_ == null) { + if (!other.deadLockThreadInfoList_.isEmpty()) { + if (deadLockThreadInfoList_.isEmpty()) { + deadLockThreadInfoList_ = other.deadLockThreadInfoList_; + bitField0_ = (bitField0_ & ~0x00001000); + } else { + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.addAll(other.deadLockThreadInfoList_); + } + onChanged(); + } + } else { + if (!other.deadLockThreadInfoList_.isEmpty()) { + if (deadLockThreadInfoListBuilder_.isEmpty()) { + deadLockThreadInfoListBuilder_.dispose(); + deadLockThreadInfoListBuilder_ = null; + deadLockThreadInfoList_ = other.deadLockThreadInfoList_; + bitField0_ = (bitField0_ & ~0x00001000); + deadLockThreadInfoListBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getDeadLockThreadInfoListFieldBuilder() : null; + } else { + deadLockThreadInfoListBuilder_.addAllMessages(other.deadLockThreadInfoList_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.NodeInfo.MachineInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.NodeInfo.MachineInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int threadCount_ ; + /** + * int32 threadCount = 1; + */ + public int getThreadCount() { + return threadCount_; + } + /** + * int32 threadCount = 1; + */ + public Builder setThreadCount(int value) { + + threadCount_ = value; + onChanged(); + return this; + } + /** + * int32 threadCount = 1; + */ + public Builder clearThreadCount() { + + threadCount_ = 0; + onChanged(); + return this; + } + + private int deadLockThreadCount_ ; + /** + * int32 deadLockThreadCount = 2; + */ + public int getDeadLockThreadCount() { + return deadLockThreadCount_; + } + /** + * int32 deadLockThreadCount = 2; + */ + public Builder setDeadLockThreadCount(int value) { + + deadLockThreadCount_ = value; + onChanged(); + return this; + } + /** + * int32 deadLockThreadCount = 2; + */ + public Builder clearDeadLockThreadCount() { + + deadLockThreadCount_ = 0; + onChanged(); + return this; + } + + private int cpuCount_ ; + /** + * int32 cpuCount = 3; + */ + public int getCpuCount() { + return cpuCount_; + } + /** + * int32 cpuCount = 3; + */ + public Builder setCpuCount(int value) { + + cpuCount_ = value; + onChanged(); + return this; + } + /** + * int32 cpuCount = 3; + */ + public Builder clearCpuCount() { + + cpuCount_ = 0; + onChanged(); + return this; + } + + private long totalMemory_ ; + /** + * int64 totalMemory = 4; + */ + public long getTotalMemory() { + return totalMemory_; + } + /** + * int64 totalMemory = 4; + */ + public Builder setTotalMemory(long value) { + + totalMemory_ = value; + onChanged(); + return this; + } + /** + * int64 totalMemory = 4; + */ + public Builder clearTotalMemory() { + + totalMemory_ = 0L; + onChanged(); + return this; + } + + private long freeMemory_ ; + /** + * int64 freeMemory = 5; + */ + public long getFreeMemory() { + return freeMemory_; + } + /** + * int64 freeMemory = 5; + */ + public Builder setFreeMemory(long value) { + + freeMemory_ = value; + onChanged(); + return this; + } + /** + * int64 freeMemory = 5; + */ + public Builder clearFreeMemory() { + + freeMemory_ = 0L; + onChanged(); + return this; + } + + private double cpuRate_ ; + /** + * double cpuRate = 6; + */ + public double getCpuRate() { + return cpuRate_; + } + /** + * double cpuRate = 6; + */ + public Builder setCpuRate(double value) { + + cpuRate_ = value; + onChanged(); + return this; + } + /** + * double cpuRate = 6; + */ + public Builder clearCpuRate() { + + cpuRate_ = 0D; + onChanged(); + return this; + } + + private java.lang.Object javaVersion_ = ""; + /** + * string javaVersion = 7; + */ + public java.lang.String getJavaVersion() { + java.lang.Object ref = javaVersion_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + javaVersion_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string javaVersion = 7; + */ + public com.google.protobuf.ByteString + getJavaVersionBytes() { + java.lang.Object ref = javaVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + javaVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string javaVersion = 7; + */ + public Builder setJavaVersion( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + javaVersion_ = value; + onChanged(); + return this; + } + /** + * string javaVersion = 7; + */ + public Builder clearJavaVersion() { + + javaVersion_ = getDefaultInstance().getJavaVersion(); + onChanged(); + return this; + } + /** + * string javaVersion = 7; + */ + public Builder setJavaVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + javaVersion_ = value; + onChanged(); + return this; + } + + private java.lang.Object osName_ = ""; + /** + * string osName = 8; + */ + public java.lang.String getOsName() { + java.lang.Object ref = osName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + osName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string osName = 8; + */ + public com.google.protobuf.ByteString + getOsNameBytes() { + java.lang.Object ref = osName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + osName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string osName = 8; + */ + public Builder setOsName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + osName_ = value; + onChanged(); + return this; + } + /** + * string osName = 8; + */ + public Builder clearOsName() { + + osName_ = getDefaultInstance().getOsName(); + onChanged(); + return this; + } + /** + * string osName = 8; + */ + public Builder setOsNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + osName_ = value; + onChanged(); + return this; + } + + private long jvmTotalMemoery_ ; + /** + * int64 jvmTotalMemoery = 9; + */ + public long getJvmTotalMemoery() { + return jvmTotalMemoery_; + } + /** + * int64 jvmTotalMemoery = 9; + */ + public Builder setJvmTotalMemoery(long value) { + + jvmTotalMemoery_ = value; + onChanged(); + return this; + } + /** + * int64 jvmTotalMemoery = 9; + */ + public Builder clearJvmTotalMemoery() { + + jvmTotalMemoery_ = 0L; + onChanged(); + return this; + } + + private long jvmFreeMemory_ ; + /** + * int64 jvmFreeMemory = 10; + */ + public long getJvmFreeMemory() { + return jvmFreeMemory_; + } + /** + * int64 jvmFreeMemory = 10; + */ + public Builder setJvmFreeMemory(long value) { + + jvmFreeMemory_ = value; + onChanged(); + return this; + } + /** + * int64 jvmFreeMemory = 10; + */ + public Builder clearJvmFreeMemory() { + + jvmFreeMemory_ = 0L; + onChanged(); + return this; + } + + private double processCpuRate_ ; + /** + * double processCpuRate = 11; + */ + public double getProcessCpuRate() { + return processCpuRate_; + } + /** + * double processCpuRate = 11; + */ + public Builder setProcessCpuRate(double value) { + + processCpuRate_ = value; + onChanged(); + return this; + } + /** + * double processCpuRate = 11; + */ + public Builder clearProcessCpuRate() { + + processCpuRate_ = 0D; + onChanged(); + return this; + } + + private java.util.List memoryDescInfoList_ = + java.util.Collections.emptyList(); + private void ensureMemoryDescInfoListIsMutable() { + if (!((bitField0_ & 0x00000800) == 0x00000800)) { + memoryDescInfoList_ = new java.util.ArrayList(memoryDescInfoList_); + bitField0_ |= 0x00000800; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfoOrBuilder> memoryDescInfoListBuilder_; + + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public java.util.List getMemoryDescInfoListList() { + if (memoryDescInfoListBuilder_ == null) { + return java.util.Collections.unmodifiableList(memoryDescInfoList_); + } else { + return memoryDescInfoListBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public int getMemoryDescInfoListCount() { + if (memoryDescInfoListBuilder_ == null) { + return memoryDescInfoList_.size(); + } else { + return memoryDescInfoListBuilder_.getCount(); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo getMemoryDescInfoList(int index) { + if (memoryDescInfoListBuilder_ == null) { + return memoryDescInfoList_.get(index); + } else { + return memoryDescInfoListBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder setMemoryDescInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo value) { + if (memoryDescInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.set(index, value); + onChanged(); + } else { + memoryDescInfoListBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder setMemoryDescInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder builderForValue) { + if (memoryDescInfoListBuilder_ == null) { + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.set(index, builderForValue.build()); + onChanged(); + } else { + memoryDescInfoListBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder addMemoryDescInfoList(org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo value) { + if (memoryDescInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.add(value); + onChanged(); + } else { + memoryDescInfoListBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder addMemoryDescInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo value) { + if (memoryDescInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.add(index, value); + onChanged(); + } else { + memoryDescInfoListBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder addMemoryDescInfoList( + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder builderForValue) { + if (memoryDescInfoListBuilder_ == null) { + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.add(builderForValue.build()); + onChanged(); + } else { + memoryDescInfoListBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder addMemoryDescInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder builderForValue) { + if (memoryDescInfoListBuilder_ == null) { + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.add(index, builderForValue.build()); + onChanged(); + } else { + memoryDescInfoListBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder addAllMemoryDescInfoList( + java.lang.Iterable values) { + if (memoryDescInfoListBuilder_ == null) { + ensureMemoryDescInfoListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, memoryDescInfoList_); + onChanged(); + } else { + memoryDescInfoListBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder clearMemoryDescInfoList() { + if (memoryDescInfoListBuilder_ == null) { + memoryDescInfoList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000800); + onChanged(); + } else { + memoryDescInfoListBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public Builder removeMemoryDescInfoList(int index) { + if (memoryDescInfoListBuilder_ == null) { + ensureMemoryDescInfoListIsMutable(); + memoryDescInfoList_.remove(index); + onChanged(); + } else { + memoryDescInfoListBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder getMemoryDescInfoListBuilder( + int index) { + return getMemoryDescInfoListFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfoOrBuilder getMemoryDescInfoListOrBuilder( + int index) { + if (memoryDescInfoListBuilder_ == null) { + return memoryDescInfoList_.get(index); } else { + return memoryDescInfoListBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public java.util.List + getMemoryDescInfoListOrBuilderList() { + if (memoryDescInfoListBuilder_ != null) { + return memoryDescInfoListBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(memoryDescInfoList_); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder addMemoryDescInfoListBuilder() { + return getMemoryDescInfoListFieldBuilder().addBuilder( + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.getDefaultInstance()); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder addMemoryDescInfoListBuilder( + int index) { + return getMemoryDescInfoListFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.getDefaultInstance()); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.MemoryDescInfo memoryDescInfoList = 12; + */ + public java.util.List + getMemoryDescInfoListBuilderList() { + return getMemoryDescInfoListFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfoOrBuilder> + getMemoryDescInfoListFieldBuilder() { + if (memoryDescInfoListBuilder_ == null) { + memoryDescInfoListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfo.MemoryDescInfoOrBuilder>( + memoryDescInfoList_, + ((bitField0_ & 0x00000800) == 0x00000800), + getParentForChildren(), + isClean()); + memoryDescInfoList_ = null; + } + return memoryDescInfoListBuilder_; + } + + private java.util.List deadLockThreadInfoList_ = + java.util.Collections.emptyList(); + private void ensureDeadLockThreadInfoListIsMutable() { + if (!((bitField0_ & 0x00001000) == 0x00001000)) { + deadLockThreadInfoList_ = new java.util.ArrayList(deadLockThreadInfoList_); + bitField0_ |= 0x00001000; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfoOrBuilder> deadLockThreadInfoListBuilder_; + + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public java.util.List getDeadLockThreadInfoListList() { + if (deadLockThreadInfoListBuilder_ == null) { + return java.util.Collections.unmodifiableList(deadLockThreadInfoList_); + } else { + return deadLockThreadInfoListBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public int getDeadLockThreadInfoListCount() { + if (deadLockThreadInfoListBuilder_ == null) { + return deadLockThreadInfoList_.size(); + } else { + return deadLockThreadInfoListBuilder_.getCount(); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo getDeadLockThreadInfoList(int index) { + if (deadLockThreadInfoListBuilder_ == null) { + return deadLockThreadInfoList_.get(index); + } else { + return deadLockThreadInfoListBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder setDeadLockThreadInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo value) { + if (deadLockThreadInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.set(index, value); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder setDeadLockThreadInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder builderForValue) { + if (deadLockThreadInfoListBuilder_ == null) { + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.set(index, builderForValue.build()); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder addDeadLockThreadInfoList(org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo value) { + if (deadLockThreadInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.add(value); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder addDeadLockThreadInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo value) { + if (deadLockThreadInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.add(index, value); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder addDeadLockThreadInfoList( + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder builderForValue) { + if (deadLockThreadInfoListBuilder_ == null) { + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.add(builderForValue.build()); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder addDeadLockThreadInfoList( + int index, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder builderForValue) { + if (deadLockThreadInfoListBuilder_ == null) { + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.add(index, builderForValue.build()); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder addAllDeadLockThreadInfoList( + java.lang.Iterable values) { + if (deadLockThreadInfoListBuilder_ == null) { + ensureDeadLockThreadInfoListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, deadLockThreadInfoList_); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder clearDeadLockThreadInfoList() { + if (deadLockThreadInfoListBuilder_ == null) { + deadLockThreadInfoList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00001000); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public Builder removeDeadLockThreadInfoList(int index) { + if (deadLockThreadInfoListBuilder_ == null) { + ensureDeadLockThreadInfoListIsMutable(); + deadLockThreadInfoList_.remove(index); + onChanged(); + } else { + deadLockThreadInfoListBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder getDeadLockThreadInfoListBuilder( + int index) { + return getDeadLockThreadInfoListFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfoOrBuilder getDeadLockThreadInfoListOrBuilder( + int index) { + if (deadLockThreadInfoListBuilder_ == null) { + return deadLockThreadInfoList_.get(index); } else { + return deadLockThreadInfoListBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public java.util.List + getDeadLockThreadInfoListOrBuilderList() { + if (deadLockThreadInfoListBuilder_ != null) { + return deadLockThreadInfoListBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(deadLockThreadInfoList_); + } + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder addDeadLockThreadInfoListBuilder() { + return getDeadLockThreadInfoListFieldBuilder().addBuilder( + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.getDefaultInstance()); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder addDeadLockThreadInfoListBuilder( + int index) { + return getDeadLockThreadInfoListFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.getDefaultInstance()); + } + /** + * repeated .protocol.NodeInfo.MachineInfo.DeadLockThreadInfo deadLockThreadInfoList = 13; + */ + public java.util.List + getDeadLockThreadInfoListBuilderList() { + return getDeadLockThreadInfoListFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfoOrBuilder> + getDeadLockThreadInfoListFieldBuilder() { + if (deadLockThreadInfoListBuilder_ == null) { + deadLockThreadInfoListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfo.DeadLockThreadInfoOrBuilder>( + deadLockThreadInfoList_, + ((bitField0_ & 0x00001000) == 0x00001000), + getParentForChildren(), + isClean()); + deadLockThreadInfoList_ = null; + } + return deadLockThreadInfoListBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NodeInfo.MachineInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.NodeInfo.MachineInfo) + private static final org.tron.protos.Protocol.NodeInfo.MachineInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.NodeInfo.MachineInfo(); + } + + public static org.tron.protos.Protocol.NodeInfo.MachineInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public MachineInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MachineInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.NodeInfo.MachineInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int BEGINSYNCNUM_FIELD_NUMBER = 1; + private long beginSyncNum_; + /** + * int64 beginSyncNum = 1; + */ + public long getBeginSyncNum() { + return beginSyncNum_; + } + + public static final int BLOCK_FIELD_NUMBER = 2; + private volatile java.lang.Object block_; + /** + * string block = 2; + */ + public java.lang.String getBlock() { + java.lang.Object ref = block_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + block_ = s; + return s; + } + } + /** + * string block = 2; + */ + public com.google.protobuf.ByteString + getBlockBytes() { + java.lang.Object ref = block_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + block_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SOLIDITYBLOCK_FIELD_NUMBER = 3; + private volatile java.lang.Object solidityBlock_; + /** + * string solidityBlock = 3; + */ + public java.lang.String getSolidityBlock() { + java.lang.Object ref = solidityBlock_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + solidityBlock_ = s; + return s; + } + } + /** + * string solidityBlock = 3; + */ + public com.google.protobuf.ByteString + getSolidityBlockBytes() { + java.lang.Object ref = solidityBlock_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + solidityBlock_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CURRENTCONNECTCOUNT_FIELD_NUMBER = 4; + private int currentConnectCount_; + /** + *
+     *connect information
+     * 
+ * + * int32 currentConnectCount = 4; + */ + public int getCurrentConnectCount() { + return currentConnectCount_; + } + + public static final int ACTIVECONNECTCOUNT_FIELD_NUMBER = 5; + private int activeConnectCount_; + /** + * int32 activeConnectCount = 5; + */ + public int getActiveConnectCount() { + return activeConnectCount_; + } + + public static final int PASSIVECONNECTCOUNT_FIELD_NUMBER = 6; + private int passiveConnectCount_; + /** + * int32 passiveConnectCount = 6; + */ + public int getPassiveConnectCount() { + return passiveConnectCount_; + } + + public static final int TOTALFLOW_FIELD_NUMBER = 7; + private long totalFlow_; + /** + * int64 totalFlow = 7; + */ + public long getTotalFlow() { + return totalFlow_; + } + + public static final int PEERINFOLIST_FIELD_NUMBER = 8; + private java.util.List peerInfoList_; + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public java.util.List getPeerInfoListList() { + return peerInfoList_; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public java.util.List + getPeerInfoListOrBuilderList() { + return peerInfoList_; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public int getPeerInfoListCount() { + return peerInfoList_.size(); + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public org.tron.protos.Protocol.NodeInfo.PeerInfo getPeerInfoList(int index) { + return peerInfoList_.get(index); + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public org.tron.protos.Protocol.NodeInfo.PeerInfoOrBuilder getPeerInfoListOrBuilder( + int index) { + return peerInfoList_.get(index); + } + + public static final int CONFIGNODEINFO_FIELD_NUMBER = 9; + private org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo configNodeInfo_; + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public boolean hasConfigNodeInfo() { + return configNodeInfo_ != null; + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo getConfigNodeInfo() { + return configNodeInfo_ == null ? org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.getDefaultInstance() : configNodeInfo_; + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfoOrBuilder getConfigNodeInfoOrBuilder() { + return getConfigNodeInfo(); + } + + public static final int MACHINEINFO_FIELD_NUMBER = 10; + private org.tron.protos.Protocol.NodeInfo.MachineInfo machineInfo_; + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public boolean hasMachineInfo() { + return machineInfo_ != null; + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo getMachineInfo() { + return machineInfo_ == null ? org.tron.protos.Protocol.NodeInfo.MachineInfo.getDefaultInstance() : machineInfo_; + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfoOrBuilder getMachineInfoOrBuilder() { + return getMachineInfo(); + } + + public static final int CHEATWITNESSINFOMAP_FIELD_NUMBER = 11; + private static final class CheatWitnessInfoMapDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.tron.protos.Protocol.internal_static_protocol_NodeInfo_CheatWitnessInfoMapEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> cheatWitnessInfoMap_; + private com.google.protobuf.MapField + internalGetCheatWitnessInfoMap() { + if (cheatWitnessInfoMap_ == null) { + return com.google.protobuf.MapField.emptyMapField( + CheatWitnessInfoMapDefaultEntryHolder.defaultEntry); + } + return cheatWitnessInfoMap_; + } + + public int getCheatWitnessInfoMapCount() { + return internalGetCheatWitnessInfoMap().getMap().size(); + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public boolean containsCheatWitnessInfoMap( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetCheatWitnessInfoMap().getMap().containsKey(key); + } + /** + * Use {@link #getCheatWitnessInfoMapMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getCheatWitnessInfoMap() { + return getCheatWitnessInfoMapMap(); + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public java.util.Map getCheatWitnessInfoMapMap() { + return internalGetCheatWitnessInfoMap().getMap(); + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public java.lang.String getCheatWitnessInfoMapOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetCheatWitnessInfoMap().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public java.lang.String getCheatWitnessInfoMapOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetCheatWitnessInfoMap().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (beginSyncNum_ != 0L) { + output.writeInt64(1, beginSyncNum_); + } + if (!getBlockBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, block_); + } + if (!getSolidityBlockBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, solidityBlock_); + } + if (currentConnectCount_ != 0) { + output.writeInt32(4, currentConnectCount_); + } + if (activeConnectCount_ != 0) { + output.writeInt32(5, activeConnectCount_); + } + if (passiveConnectCount_ != 0) { + output.writeInt32(6, passiveConnectCount_); + } + if (totalFlow_ != 0L) { + output.writeInt64(7, totalFlow_); + } + for (int i = 0; i < peerInfoList_.size(); i++) { + output.writeMessage(8, peerInfoList_.get(i)); + } + if (configNodeInfo_ != null) { + output.writeMessage(9, getConfigNodeInfo()); + } + if (machineInfo_ != null) { + output.writeMessage(10, getMachineInfo()); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetCheatWitnessInfoMap(), + CheatWitnessInfoMapDefaultEntryHolder.defaultEntry, + 11); + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (beginSyncNum_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, beginSyncNum_); + } + if (!getBlockBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, block_); + } + if (!getSolidityBlockBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, solidityBlock_); + } + if (currentConnectCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, currentConnectCount_); + } + if (activeConnectCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, activeConnectCount_); + } + if (passiveConnectCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(6, passiveConnectCount_); + } + if (totalFlow_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, totalFlow_); + } + for (int i = 0; i < peerInfoList_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, peerInfoList_.get(i)); + } + if (configNodeInfo_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(9, getConfigNodeInfo()); + } + if (machineInfo_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(10, getMachineInfo()); + } + for (java.util.Map.Entry entry + : internalGetCheatWitnessInfoMap().getMap().entrySet()) { + com.google.protobuf.MapEntry + cheatWitnessInfoMap__ = CheatWitnessInfoMapDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(11, cheatWitnessInfoMap__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.Protocol.NodeInfo)) { + return super.equals(obj); + } + org.tron.protos.Protocol.NodeInfo other = (org.tron.protos.Protocol.NodeInfo) obj; + + boolean result = true; + result = result && (getBeginSyncNum() + == other.getBeginSyncNum()); + result = result && getBlock() + .equals(other.getBlock()); + result = result && getSolidityBlock() + .equals(other.getSolidityBlock()); + result = result && (getCurrentConnectCount() + == other.getCurrentConnectCount()); + result = result && (getActiveConnectCount() + == other.getActiveConnectCount()); + result = result && (getPassiveConnectCount() + == other.getPassiveConnectCount()); + result = result && (getTotalFlow() + == other.getTotalFlow()); + result = result && getPeerInfoListList() + .equals(other.getPeerInfoListList()); + result = result && (hasConfigNodeInfo() == other.hasConfigNodeInfo()); + if (hasConfigNodeInfo()) { + result = result && getConfigNodeInfo() + .equals(other.getConfigNodeInfo()); + } + result = result && (hasMachineInfo() == other.hasMachineInfo()); + if (hasMachineInfo()) { + result = result && getMachineInfo() + .equals(other.getMachineInfo()); + } + result = result && internalGetCheatWitnessInfoMap().equals( + other.internalGetCheatWitnessInfoMap()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BEGINSYNCNUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBeginSyncNum()); + hash = (37 * hash) + BLOCK_FIELD_NUMBER; + hash = (53 * hash) + getBlock().hashCode(); + hash = (37 * hash) + SOLIDITYBLOCK_FIELD_NUMBER; + hash = (53 * hash) + getSolidityBlock().hashCode(); + hash = (37 * hash) + CURRENTCONNECTCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getCurrentConnectCount(); + hash = (37 * hash) + ACTIVECONNECTCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getActiveConnectCount(); + hash = (37 * hash) + PASSIVECONNECTCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getPassiveConnectCount(); + hash = (37 * hash) + TOTALFLOW_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTotalFlow()); + if (getPeerInfoListCount() > 0) { + hash = (37 * hash) + PEERINFOLIST_FIELD_NUMBER; + hash = (53 * hash) + getPeerInfoListList().hashCode(); + } + if (hasConfigNodeInfo()) { + hash = (37 * hash) + CONFIGNODEINFO_FIELD_NUMBER; + hash = (53 * hash) + getConfigNodeInfo().hashCode(); + } + if (hasMachineInfo()) { + hash = (37 * hash) + MACHINEINFO_FIELD_NUMBER; + hash = (53 * hash) + getMachineInfo().hashCode(); + } + if (!internalGetCheatWitnessInfoMap().getMap().isEmpty()) { + hash = (37 * hash) + CHEATWITNESSINFOMAP_FIELD_NUMBER; + hash = (53 * hash) + internalGetCheatWitnessInfoMap().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.Protocol.NodeInfo parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.Protocol.NodeInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.Protocol.NodeInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.NodeInfo} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.NodeInfo) + org.tron.protos.Protocol.NodeInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 11: + return internalGetCheatWitnessInfoMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 11: + return internalGetMutableCheatWitnessInfoMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.Protocol.NodeInfo.class, org.tron.protos.Protocol.NodeInfo.Builder.class); + } + + // Construct using org.tron.protos.Protocol.NodeInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getPeerInfoListFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + beginSyncNum_ = 0L; + + block_ = ""; + + solidityBlock_ = ""; + + currentConnectCount_ = 0; + + activeConnectCount_ = 0; + + passiveConnectCount_ = 0; + + totalFlow_ = 0L; + + if (peerInfoListBuilder_ == null) { + peerInfoList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + } else { + peerInfoListBuilder_.clear(); + } + if (configNodeInfoBuilder_ == null) { + configNodeInfo_ = null; + } else { + configNodeInfo_ = null; + configNodeInfoBuilder_ = null; + } + if (machineInfoBuilder_ == null) { + machineInfo_ = null; + } else { + machineInfo_ = null; + machineInfoBuilder_ = null; + } + internalGetMutableCheatWitnessInfoMap().clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.Protocol.internal_static_protocol_NodeInfo_descriptor; + } + + public org.tron.protos.Protocol.NodeInfo getDefaultInstanceForType() { + return org.tron.protos.Protocol.NodeInfo.getDefaultInstance(); + } + + public org.tron.protos.Protocol.NodeInfo build() { + org.tron.protos.Protocol.NodeInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.Protocol.NodeInfo buildPartial() { + org.tron.protos.Protocol.NodeInfo result = new org.tron.protos.Protocol.NodeInfo(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.beginSyncNum_ = beginSyncNum_; + result.block_ = block_; + result.solidityBlock_ = solidityBlock_; + result.currentConnectCount_ = currentConnectCount_; + result.activeConnectCount_ = activeConnectCount_; + result.passiveConnectCount_ = passiveConnectCount_; + result.totalFlow_ = totalFlow_; + if (peerInfoListBuilder_ == null) { + if (((bitField0_ & 0x00000080) == 0x00000080)) { + peerInfoList_ = java.util.Collections.unmodifiableList(peerInfoList_); + bitField0_ = (bitField0_ & ~0x00000080); + } + result.peerInfoList_ = peerInfoList_; + } else { + result.peerInfoList_ = peerInfoListBuilder_.build(); + } + if (configNodeInfoBuilder_ == null) { + result.configNodeInfo_ = configNodeInfo_; + } else { + result.configNodeInfo_ = configNodeInfoBuilder_.build(); + } + if (machineInfoBuilder_ == null) { + result.machineInfo_ = machineInfo_; + } else { + result.machineInfo_ = machineInfoBuilder_.build(); + } + result.cheatWitnessInfoMap_ = internalGetCheatWitnessInfoMap(); + result.cheatWitnessInfoMap_.makeImmutable(); + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.Protocol.NodeInfo) { + return mergeFrom((org.tron.protos.Protocol.NodeInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.Protocol.NodeInfo other) { + if (other == org.tron.protos.Protocol.NodeInfo.getDefaultInstance()) return this; + if (other.getBeginSyncNum() != 0L) { + setBeginSyncNum(other.getBeginSyncNum()); + } + if (!other.getBlock().isEmpty()) { + block_ = other.block_; + onChanged(); + } + if (!other.getSolidityBlock().isEmpty()) { + solidityBlock_ = other.solidityBlock_; + onChanged(); + } + if (other.getCurrentConnectCount() != 0) { + setCurrentConnectCount(other.getCurrentConnectCount()); + } + if (other.getActiveConnectCount() != 0) { + setActiveConnectCount(other.getActiveConnectCount()); + } + if (other.getPassiveConnectCount() != 0) { + setPassiveConnectCount(other.getPassiveConnectCount()); + } + if (other.getTotalFlow() != 0L) { + setTotalFlow(other.getTotalFlow()); + } + if (peerInfoListBuilder_ == null) { + if (!other.peerInfoList_.isEmpty()) { + if (peerInfoList_.isEmpty()) { + peerInfoList_ = other.peerInfoList_; + bitField0_ = (bitField0_ & ~0x00000080); + } else { + ensurePeerInfoListIsMutable(); + peerInfoList_.addAll(other.peerInfoList_); + } + onChanged(); + } + } else { + if (!other.peerInfoList_.isEmpty()) { + if (peerInfoListBuilder_.isEmpty()) { + peerInfoListBuilder_.dispose(); + peerInfoListBuilder_ = null; + peerInfoList_ = other.peerInfoList_; + bitField0_ = (bitField0_ & ~0x00000080); + peerInfoListBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getPeerInfoListFieldBuilder() : null; + } else { + peerInfoListBuilder_.addAllMessages(other.peerInfoList_); + } + } + } + if (other.hasConfigNodeInfo()) { + mergeConfigNodeInfo(other.getConfigNodeInfo()); + } + if (other.hasMachineInfo()) { + mergeMachineInfo(other.getMachineInfo()); + } + internalGetMutableCheatWitnessInfoMap().mergeFrom( + other.internalGetCheatWitnessInfoMap()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.Protocol.NodeInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.Protocol.NodeInfo) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long beginSyncNum_ ; + /** + * int64 beginSyncNum = 1; + */ + public long getBeginSyncNum() { + return beginSyncNum_; + } + /** + * int64 beginSyncNum = 1; + */ + public Builder setBeginSyncNum(long value) { + + beginSyncNum_ = value; + onChanged(); + return this; + } + /** + * int64 beginSyncNum = 1; + */ + public Builder clearBeginSyncNum() { + + beginSyncNum_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object block_ = ""; + /** + * string block = 2; + */ + public java.lang.String getBlock() { + java.lang.Object ref = block_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + block_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string block = 2; + */ + public com.google.protobuf.ByteString + getBlockBytes() { + java.lang.Object ref = block_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + block_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string block = 2; + */ + public Builder setBlock( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + block_ = value; + onChanged(); + return this; + } + /** + * string block = 2; + */ + public Builder clearBlock() { + + block_ = getDefaultInstance().getBlock(); + onChanged(); + return this; + } + /** + * string block = 2; + */ + public Builder setBlockBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + block_ = value; + onChanged(); + return this; + } + + private java.lang.Object solidityBlock_ = ""; + /** + * string solidityBlock = 3; + */ + public java.lang.String getSolidityBlock() { + java.lang.Object ref = solidityBlock_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + solidityBlock_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string solidityBlock = 3; + */ + public com.google.protobuf.ByteString + getSolidityBlockBytes() { + java.lang.Object ref = solidityBlock_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + solidityBlock_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string solidityBlock = 3; + */ + public Builder setSolidityBlock( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + solidityBlock_ = value; + onChanged(); + return this; + } + /** + * string solidityBlock = 3; + */ + public Builder clearSolidityBlock() { + + solidityBlock_ = getDefaultInstance().getSolidityBlock(); + onChanged(); + return this; + } + /** + * string solidityBlock = 3; + */ + public Builder setSolidityBlockBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + solidityBlock_ = value; + onChanged(); + return this; + } + + private int currentConnectCount_ ; + /** + *
+       *connect information
+       * 
+ * + * int32 currentConnectCount = 4; + */ + public int getCurrentConnectCount() { + return currentConnectCount_; + } + /** + *
+       *connect information
+       * 
+ * + * int32 currentConnectCount = 4; + */ + public Builder setCurrentConnectCount(int value) { + + currentConnectCount_ = value; + onChanged(); + return this; + } + /** + *
+       *connect information
+       * 
+ * + * int32 currentConnectCount = 4; + */ + public Builder clearCurrentConnectCount() { + + currentConnectCount_ = 0; + onChanged(); + return this; + } + + private int activeConnectCount_ ; + /** + * int32 activeConnectCount = 5; + */ + public int getActiveConnectCount() { + return activeConnectCount_; + } + /** + * int32 activeConnectCount = 5; + */ + public Builder setActiveConnectCount(int value) { + + activeConnectCount_ = value; + onChanged(); + return this; + } + /** + * int32 activeConnectCount = 5; + */ + public Builder clearActiveConnectCount() { + + activeConnectCount_ = 0; + onChanged(); + return this; + } + + private int passiveConnectCount_ ; + /** + * int32 passiveConnectCount = 6; + */ + public int getPassiveConnectCount() { + return passiveConnectCount_; + } + /** + * int32 passiveConnectCount = 6; + */ + public Builder setPassiveConnectCount(int value) { + + passiveConnectCount_ = value; + onChanged(); + return this; + } + /** + * int32 passiveConnectCount = 6; + */ + public Builder clearPassiveConnectCount() { + + passiveConnectCount_ = 0; + onChanged(); + return this; + } + + private long totalFlow_ ; + /** + * int64 totalFlow = 7; + */ + public long getTotalFlow() { + return totalFlow_; + } + /** + * int64 totalFlow = 7; + */ + public Builder setTotalFlow(long value) { + + totalFlow_ = value; + onChanged(); + return this; + } + /** + * int64 totalFlow = 7; + */ + public Builder clearTotalFlow() { + + totalFlow_ = 0L; + onChanged(); + return this; + } + + private java.util.List peerInfoList_ = + java.util.Collections.emptyList(); + private void ensurePeerInfoListIsMutable() { + if (!((bitField0_ & 0x00000080) == 0x00000080)) { + peerInfoList_ = new java.util.ArrayList(peerInfoList_); + bitField0_ |= 0x00000080; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.PeerInfo, org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder, org.tron.protos.Protocol.NodeInfo.PeerInfoOrBuilder> peerInfoListBuilder_; + + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public java.util.List getPeerInfoListList() { + if (peerInfoListBuilder_ == null) { + return java.util.Collections.unmodifiableList(peerInfoList_); + } else { + return peerInfoListBuilder_.getMessageList(); + } + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public int getPeerInfoListCount() { + if (peerInfoListBuilder_ == null) { + return peerInfoList_.size(); + } else { + return peerInfoListBuilder_.getCount(); + } + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public org.tron.protos.Protocol.NodeInfo.PeerInfo getPeerInfoList(int index) { + if (peerInfoListBuilder_ == null) { + return peerInfoList_.get(index); + } else { + return peerInfoListBuilder_.getMessage(index); + } + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder setPeerInfoList( + int index, org.tron.protos.Protocol.NodeInfo.PeerInfo value) { + if (peerInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePeerInfoListIsMutable(); + peerInfoList_.set(index, value); + onChanged(); + } else { + peerInfoListBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder setPeerInfoList( + int index, org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder builderForValue) { + if (peerInfoListBuilder_ == null) { + ensurePeerInfoListIsMutable(); + peerInfoList_.set(index, builderForValue.build()); + onChanged(); + } else { + peerInfoListBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder addPeerInfoList(org.tron.protos.Protocol.NodeInfo.PeerInfo value) { + if (peerInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePeerInfoListIsMutable(); + peerInfoList_.add(value); + onChanged(); + } else { + peerInfoListBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder addPeerInfoList( + int index, org.tron.protos.Protocol.NodeInfo.PeerInfo value) { + if (peerInfoListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePeerInfoListIsMutable(); + peerInfoList_.add(index, value); + onChanged(); + } else { + peerInfoListBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder addPeerInfoList( + org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder builderForValue) { + if (peerInfoListBuilder_ == null) { + ensurePeerInfoListIsMutable(); + peerInfoList_.add(builderForValue.build()); + onChanged(); + } else { + peerInfoListBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder addPeerInfoList( + int index, org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder builderForValue) { + if (peerInfoListBuilder_ == null) { + ensurePeerInfoListIsMutable(); + peerInfoList_.add(index, builderForValue.build()); + onChanged(); + } else { + peerInfoListBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder addAllPeerInfoList( + java.lang.Iterable values) { + if (peerInfoListBuilder_ == null) { + ensurePeerInfoListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, peerInfoList_); + onChanged(); + } else { + peerInfoListBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder clearPeerInfoList() { + if (peerInfoListBuilder_ == null) { + peerInfoList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + onChanged(); + } else { + peerInfoListBuilder_.clear(); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public Builder removePeerInfoList(int index) { + if (peerInfoListBuilder_ == null) { + ensurePeerInfoListIsMutable(); + peerInfoList_.remove(index); + onChanged(); + } else { + peerInfoListBuilder_.remove(index); + } + return this; + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder getPeerInfoListBuilder( + int index) { + return getPeerInfoListFieldBuilder().getBuilder(index); + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public org.tron.protos.Protocol.NodeInfo.PeerInfoOrBuilder getPeerInfoListOrBuilder( + int index) { + if (peerInfoListBuilder_ == null) { + return peerInfoList_.get(index); } else { + return peerInfoListBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public java.util.List + getPeerInfoListOrBuilderList() { + if (peerInfoListBuilder_ != null) { + return peerInfoListBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(peerInfoList_); + } + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder addPeerInfoListBuilder() { + return getPeerInfoListFieldBuilder().addBuilder( + org.tron.protos.Protocol.NodeInfo.PeerInfo.getDefaultInstance()); + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder addPeerInfoListBuilder( + int index) { + return getPeerInfoListFieldBuilder().addBuilder( + index, org.tron.protos.Protocol.NodeInfo.PeerInfo.getDefaultInstance()); + } + /** + * repeated .protocol.NodeInfo.PeerInfo peerInfoList = 8; + */ + public java.util.List + getPeerInfoListBuilderList() { + return getPeerInfoListFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.PeerInfo, org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder, org.tron.protos.Protocol.NodeInfo.PeerInfoOrBuilder> + getPeerInfoListFieldBuilder() { + if (peerInfoListBuilder_ == null) { + peerInfoListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.PeerInfo, org.tron.protos.Protocol.NodeInfo.PeerInfo.Builder, org.tron.protos.Protocol.NodeInfo.PeerInfoOrBuilder>( + peerInfoList_, + ((bitField0_ & 0x00000080) == 0x00000080), + getParentForChildren(), + isClean()); + peerInfoList_ = null; + } + return peerInfoListBuilder_; + } + + private org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo configNodeInfo_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfoOrBuilder> configNodeInfoBuilder_; + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public boolean hasConfigNodeInfo() { + return configNodeInfoBuilder_ != null || configNodeInfo_ != null; + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo getConfigNodeInfo() { + if (configNodeInfoBuilder_ == null) { + return configNodeInfo_ == null ? org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.getDefaultInstance() : configNodeInfo_; + } else { + return configNodeInfoBuilder_.getMessage(); + } + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public Builder setConfigNodeInfo(org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo value) { + if (configNodeInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + configNodeInfo_ = value; + onChanged(); + } else { + configNodeInfoBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public Builder setConfigNodeInfo( + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder builderForValue) { + if (configNodeInfoBuilder_ == null) { + configNodeInfo_ = builderForValue.build(); + onChanged(); + } else { + configNodeInfoBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public Builder mergeConfigNodeInfo(org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo value) { + if (configNodeInfoBuilder_ == null) { + if (configNodeInfo_ != null) { + configNodeInfo_ = + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.newBuilder(configNodeInfo_).mergeFrom(value).buildPartial(); + } else { + configNodeInfo_ = value; + } + onChanged(); + } else { + configNodeInfoBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public Builder clearConfigNodeInfo() { + if (configNodeInfoBuilder_ == null) { + configNodeInfo_ = null; + onChanged(); + } else { + configNodeInfo_ = null; + configNodeInfoBuilder_ = null; + } + + return this; + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder getConfigNodeInfoBuilder() { + + onChanged(); + return getConfigNodeInfoFieldBuilder().getBuilder(); + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + public org.tron.protos.Protocol.NodeInfo.ConfigNodeInfoOrBuilder getConfigNodeInfoOrBuilder() { + if (configNodeInfoBuilder_ != null) { + return configNodeInfoBuilder_.getMessageOrBuilder(); + } else { + return configNodeInfo_ == null ? + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.getDefaultInstance() : configNodeInfo_; + } + } + /** + * .protocol.NodeInfo.ConfigNodeInfo configNodeInfo = 9; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfoOrBuilder> + getConfigNodeInfoFieldBuilder() { + if (configNodeInfoBuilder_ == null) { + configNodeInfoBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfo.Builder, org.tron.protos.Protocol.NodeInfo.ConfigNodeInfoOrBuilder>( + getConfigNodeInfo(), + getParentForChildren(), + isClean()); + configNodeInfo_ = null; + } + return configNodeInfoBuilder_; + } + + private org.tron.protos.Protocol.NodeInfo.MachineInfo machineInfo_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfoOrBuilder> machineInfoBuilder_; + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public boolean hasMachineInfo() { + return machineInfoBuilder_ != null || machineInfo_ != null; + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo getMachineInfo() { + if (machineInfoBuilder_ == null) { + return machineInfo_ == null ? org.tron.protos.Protocol.NodeInfo.MachineInfo.getDefaultInstance() : machineInfo_; + } else { + return machineInfoBuilder_.getMessage(); + } + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public Builder setMachineInfo(org.tron.protos.Protocol.NodeInfo.MachineInfo value) { + if (machineInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + machineInfo_ = value; + onChanged(); + } else { + machineInfoBuilder_.setMessage(value); + } + + return this; + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public Builder setMachineInfo( + org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder builderForValue) { + if (machineInfoBuilder_ == null) { + machineInfo_ = builderForValue.build(); + onChanged(); + } else { + machineInfoBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public Builder mergeMachineInfo(org.tron.protos.Protocol.NodeInfo.MachineInfo value) { + if (machineInfoBuilder_ == null) { + if (machineInfo_ != null) { + machineInfo_ = + org.tron.protos.Protocol.NodeInfo.MachineInfo.newBuilder(machineInfo_).mergeFrom(value).buildPartial(); + } else { + machineInfo_ = value; + } + onChanged(); + } else { + machineInfoBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public Builder clearMachineInfo() { + if (machineInfoBuilder_ == null) { + machineInfo_ = null; + onChanged(); + } else { + machineInfo_ = null; + machineInfoBuilder_ = null; + } + + return this; + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder getMachineInfoBuilder() { + + onChanged(); + return getMachineInfoFieldBuilder().getBuilder(); + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + public org.tron.protos.Protocol.NodeInfo.MachineInfoOrBuilder getMachineInfoOrBuilder() { + if (machineInfoBuilder_ != null) { + return machineInfoBuilder_.getMessageOrBuilder(); + } else { + return machineInfo_ == null ? + org.tron.protos.Protocol.NodeInfo.MachineInfo.getDefaultInstance() : machineInfo_; + } + } + /** + * .protocol.NodeInfo.MachineInfo machineInfo = 10; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfoOrBuilder> + getMachineInfoFieldBuilder() { + if (machineInfoBuilder_ == null) { + machineInfoBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.tron.protos.Protocol.NodeInfo.MachineInfo, org.tron.protos.Protocol.NodeInfo.MachineInfo.Builder, org.tron.protos.Protocol.NodeInfo.MachineInfoOrBuilder>( + getMachineInfo(), + getParentForChildren(), + isClean()); + machineInfo_ = null; + } + return machineInfoBuilder_; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> cheatWitnessInfoMap_; + private com.google.protobuf.MapField + internalGetCheatWitnessInfoMap() { + if (cheatWitnessInfoMap_ == null) { + return com.google.protobuf.MapField.emptyMapField( + CheatWitnessInfoMapDefaultEntryHolder.defaultEntry); + } + return cheatWitnessInfoMap_; + } + private com.google.protobuf.MapField + internalGetMutableCheatWitnessInfoMap() { + onChanged();; + if (cheatWitnessInfoMap_ == null) { + cheatWitnessInfoMap_ = com.google.protobuf.MapField.newMapField( + CheatWitnessInfoMapDefaultEntryHolder.defaultEntry); + } + if (!cheatWitnessInfoMap_.isMutable()) { + cheatWitnessInfoMap_ = cheatWitnessInfoMap_.copy(); + } + return cheatWitnessInfoMap_; + } + + public int getCheatWitnessInfoMapCount() { + return internalGetCheatWitnessInfoMap().getMap().size(); + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public boolean containsCheatWitnessInfoMap( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetCheatWitnessInfoMap().getMap().containsKey(key); + } + /** + * Use {@link #getCheatWitnessInfoMapMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getCheatWitnessInfoMap() { + return getCheatWitnessInfoMapMap(); + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public java.util.Map getCheatWitnessInfoMapMap() { + return internalGetCheatWitnessInfoMap().getMap(); + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public java.lang.String getCheatWitnessInfoMapOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetCheatWitnessInfoMap().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public java.lang.String getCheatWitnessInfoMapOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetCheatWitnessInfoMap().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearCheatWitnessInfoMap() { + internalGetMutableCheatWitnessInfoMap().getMutableMap() + .clear(); + return this; + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public Builder removeCheatWitnessInfoMap( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableCheatWitnessInfoMap().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableCheatWitnessInfoMap() { + return internalGetMutableCheatWitnessInfoMap().getMutableMap(); + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + public Builder putCheatWitnessInfoMap( + java.lang.String key, + java.lang.String value) { + if (key == null) { throw new java.lang.NullPointerException(); } + if (value == null) { throw new java.lang.NullPointerException(); } + internalGetMutableCheatWitnessInfoMap().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, string> cheatWitnessInfoMap = 11; + */ + + public Builder putAllCheatWitnessInfoMap( + java.util.Map values) { + internalGetMutableCheatWitnessInfoMap().getMutableMap() + .putAll(values); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.NodeInfo) + } + + // @@protoc_insertion_point(class_scope:protocol.NodeInfo) + private static final org.tron.protos.Protocol.NodeInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.Protocol.NodeInfo(); + } + + public static org.tron.protos.Protocol.NodeInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public NodeInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NodeInfo(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.Protocol.NodeInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_AccountId_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_AccountId_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Vote_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Vote_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Proposal_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Proposal_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Proposal_ParametersEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Proposal_ParametersEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Exchange_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Exchange_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ChainParameters_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ChainParameters_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ChainParameters_ChainParameter_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ChainParameters_ChainParameter_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_Frozen_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_Frozen_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_AssetEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_AssetEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_AssetV2Entry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_AssetV2Entry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_LatestAssetOperationTimeEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_LatestAssetOperationTimeEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_LatestAssetOperationTimeV2Entry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_LatestAssetOperationTimeV2Entry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_FreeAssetNetUsageEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_FreeAssetNetUsageEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_FreeAssetNetUsageV2Entry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_FreeAssetNetUsageV2Entry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Account_AccountResource_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Account_AccountResource_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Key_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Key_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_DelegatedResource_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_DelegatedResource_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_authority_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_authority_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Permission_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Permission_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Witness_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Witness_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Votes_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Votes_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TXOutput_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TXOutput_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TXInput_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TXInput_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TXInput_raw_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TXInput_raw_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TXOutputs_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TXOutputs_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ResourceReceipt_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ResourceReceipt_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Transaction_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Transaction_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Transaction_Contract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Transaction_Contract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Transaction_Result_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Transaction_Result_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Transaction_raw_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Transaction_raw_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionInfo_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionInfo_Log_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionInfo_Log_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionRet_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionRet_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Transactions_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Transactions_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_TransactionSign_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_TransactionSign_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockHeader_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockHeader_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockHeader_raw_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockHeader_raw_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Block_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Block_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ChainInventory_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ChainInventory_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_ChainInventory_BlockId_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_ChainInventory_BlockId_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockInventory_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockInventory_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_BlockInventory_BlockId_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_BlockInventory_BlockId_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Inventory_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Inventory_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_Items_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_Items_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_DynamicProperties_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_DynamicProperties_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_DisconnectMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_DisconnectMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_HelloMessage_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_HelloMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_HelloMessage_BlockId_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_HelloMessage_BlockId_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_SmartContract_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_SmartContract_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_SmartContract_ABI_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_SmartContract_ABI_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_SmartContract_ABI_Entry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_SmartContract_ABI_Entry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_SmartContract_ABI_Entry_Param_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_SmartContract_ABI_Entry_Param_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_InternalTransaction_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_InternalTransaction_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_InternalTransaction_CallValueInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_InternalTransaction_CallValueInfo_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_DelegatedResourceAccountIndex_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_DelegatedResourceAccountIndex_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeInfo_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeInfo_CheatWitnessInfoMapEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeInfo_CheatWitnessInfoMapEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeInfo_PeerInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeInfo_PeerInfo_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeInfo_ConfigNodeInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeInfo_ConfigNodeInfo_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeInfo_MachineInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeInfo_MachineInfo_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\017core/Tron.proto\022\010protocol\032\031google/prot" + + "obuf/any.proto\032\023core/Discover.proto\"*\n\tA" + + "ccountId\022\014\n\004name\030\001 \001(\014\022\017\n\007address\030\002 \001(\014\"" + + "0\n\004Vote\022\024\n\014vote_address\030\001 \001(\014\022\022\n\nvote_co" + + "unt\030\002 \001(\003\"\321\002\n\010Proposal\022\023\n\013proposal_id\030\001 " + + "\001(\003\022\030\n\020proposer_address\030\002 \001(\014\0226\n\nparamet" + + "ers\030\003 \003(\0132\".protocol.Proposal.Parameters" + + "Entry\022\027\n\017expiration_time\030\004 \001(\003\022\023\n\013create" + + "_time\030\005 \001(\003\022\021\n\tapprovals\030\006 \003(\014\022\'\n\005state\030" + + "\007 \001(\0162\030.protocol.Proposal.State\0321\n\017Param" + + "etersEntry\022\013\n\003key\030\001 \001(\003\022\r\n\005value\030\002 \001(\003:\002" + + "8\001\"A\n\005State\022\013\n\007PENDING\020\000\022\017\n\013DISAPPROVED\020" + + "\001\022\014\n\010APPROVED\020\002\022\014\n\010CANCELED\020\003\"\271\001\n\010Exchan" + + "ge\022\023\n\013exchange_id\030\001 \001(\003\022\027\n\017creator_addre" + + "ss\030\002 \001(\014\022\023\n\013create_time\030\003 \001(\003\022\026\n\016first_t" + + "oken_id\030\006 \001(\014\022\033\n\023first_token_balance\030\007 \001" + + "(\003\022\027\n\017second_token_id\030\010 \001(\014\022\034\n\024second_to" + + "ken_balance\030\t \001(\003\"\201\001\n\017ChainParameters\022@\n" + + "\016chainParameter\030\001 \003(\0132(.protocol.ChainPa" + + "rameters.ChainParameter\032,\n\016ChainParamete" + + "r\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\003\"\360\017\n\007Accoun" + + "t\022\024\n\014account_name\030\001 \001(\014\022#\n\004type\030\002 \001(\0162\025." + + "protocol.AccountType\022\017\n\007address\030\003 \001(\014\022\017\n" + + "\007balance\030\004 \001(\003\022\035\n\005votes\030\005 \003(\0132\016.protocol" + + ".Vote\022+\n\005asset\030\006 \003(\0132\034.protocol.Account." + + "AssetEntry\022/\n\007assetV2\0308 \003(\0132\036.protocol.A" + + "ccount.AssetV2Entry\022(\n\006frozen\030\007 \003(\0132\030.pr" + + "otocol.Account.Frozen\022\021\n\tnet_usage\030\010 \001(\003" + + "\0227\n/acquired_delegated_frozen_balance_fo" + + "r_bandwidth\030) \001(\003\022.\n&delegated_frozen_ba" + + "lance_for_bandwidth\030* \001(\003\022\023\n\013create_time" + + "\030\t \001(\003\022\034\n\024latest_opration_time\030\n \001(\003\022\021\n\t" + + "allowance\030\013 \001(\003\022\034\n\024latest_withdraw_time\030" + + "\014 \001(\003\022\014\n\004code\030\r \001(\014\022\022\n\nis_witness\030\016 \001(\010\022" + + "\024\n\014is_committee\030\017 \001(\010\022/\n\rfrozen_supply\030\020" + + " \003(\0132\030.protocol.Account.Frozen\022\031\n\021asset_" + + "issued_name\030\021 \001(\014\022\027\n\017asset_issued_ID\0309 \001" + + "(\014\022T\n\033latest_asset_operation_time\030\022 \003(\0132" + + "/.protocol.Account.LatestAssetOperationT" + + "imeEntry\022X\n\035latest_asset_operation_timeV" + + "2\030: \003(\01321.protocol.Account.LatestAssetOp" + + "erationTimeV2Entry\022\026\n\016free_net_usage\030\023 \001" + + "(\003\022F\n\024free_asset_net_usage\030\024 \003(\0132(.proto" + + "col.Account.FreeAssetNetUsageEntry\022J\n\026fr" + + "ee_asset_net_usageV2\030; \003(\0132*.protocol.Ac" + + "count.FreeAssetNetUsageV2Entry\022\033\n\023latest" + + "_consume_time\030\025 \001(\003\022 \n\030latest_consume_fr" + + "ee_time\030\026 \001(\003\022\022\n\naccount_id\030\027 \001(\014\022;\n\020acc" + + "ount_resource\030\032 \001(\0132!.protocol.Account.A" + + "ccountResource\022\020\n\010codeHash\030\036 \001(\014\022.\n\020owne" + + "r_permission\030\037 \001(\0132\024.protocol.Permission" + + "\0220\n\022witness_permission\030 \001(\0132\024.protocol." + + "Permission\022/\n\021active_permission\030! \003(\0132\024." + + "protocol.Permission\0325\n\006Frozen\022\026\n\016frozen_" + + "balance\030\001 \001(\003\022\023\n\013expire_time\030\002 \001(\003\032,\n\nAs" + + "setEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\003:\0028\001" + + "\032.\n\014AssetV2Entry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002" + + " \001(\003:\0028\001\032?\n\035LatestAssetOperationTimeEntr" + + "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\003:\0028\001\032A\n\037Lat" + + "estAssetOperationTimeV2Entry\022\013\n\003key\030\001 \001(" + + "\t\022\r\n\005value\030\002 \001(\003:\0028\001\0328\n\026FreeAssetNetUsag" + + "eEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\003:\0028\001\032:" + + "\n\030FreeAssetNetUsageV2Entry\022\013\n\003key\030\001 \001(\t\022" + + "\r\n\005value\030\002 \001(\003:\0028\001\032\303\002\n\017AccountResource\022\024" + + "\n\014energy_usage\030\001 \001(\003\022;\n\031frozen_balance_f" + + "or_energy\030\002 \001(\0132\030.protocol.Account.Froze" + + "n\022&\n\036latest_consume_time_for_energy\030\003 \001(" + + "\003\0224\n,acquired_delegated_frozen_balance_f" + + "or_energy\030\004 \001(\003\022+\n#delegated_frozen_bala" + + "nce_for_energy\030\005 \001(\003\022\025\n\rstorage_limit\030\006 " + + "\001(\003\022\025\n\rstorage_usage\030\007 \001(\003\022$\n\034latest_exc" + + "hange_storage_time\030\010 \001(\003\"&\n\003Key\022\017\n\007addre" + + "ss\030\001 \001(\014\022\016\n\006weight\030\002 \001(\003\"\271\001\n\021DelegatedRe" + + "source\022\014\n\004from\030\001 \001(\014\022\n\n\002to\030\002 \001(\014\022$\n\034froz" + + "en_balance_for_bandwidth\030\003 \001(\003\022!\n\031frozen" + + "_balance_for_energy\030\004 \001(\003\022!\n\031expire_time" + + "_for_bandwidth\030\005 \001(\003\022\036\n\026expire_time_for_" + + "energy\030\006 \001(\003\"J\n\tauthority\022$\n\007account\030\001 \001" + + "(\0132\023.protocol.AccountId\022\027\n\017permission_na" + + "me\030\002 \001(\014\"\361\001\n\nPermission\0221\n\004type\030\001 \001(\0162#." + + "protocol.Permission.PermissionType\022\n\n\002id" + + "\030\002 \001(\005\022\027\n\017permission_name\030\003 \001(\t\022\021\n\tthres" + + "hold\030\004 \001(\003\022\021\n\tparent_id\030\005 \001(\005\022\022\n\noperati" + + "ons\030\006 \001(\014\022\033\n\004keys\030\007 \003(\0132\r.protocol.Key\"4" + + "\n\016PermissionType\022\t\n\005Owner\020\000\022\013\n\007Witness\020\001" + + "\022\n\n\006Active\020\002\"\265\001\n\007Witness\022\017\n\007address\030\001 \001(" + + "\014\022\021\n\tvoteCount\030\002 \001(\003\022\016\n\006pubKey\030\003 \001(\014\022\013\n\003" + + "url\030\004 \001(\t\022\025\n\rtotalProduced\030\005 \001(\003\022\023\n\013tota" + + "lMissed\030\006 \001(\003\022\026\n\016latestBlockNum\030\007 \001(\003\022\025\n" + + "\rlatestSlotNum\030\010 \001(\003\022\016\n\006isJobs\030\t \001(\010\"^\n\005" + + "Votes\022\017\n\007address\030\001 \001(\014\022!\n\told_votes\030\002 \003(" + + "\0132\016.protocol.Vote\022!\n\tnew_votes\030\003 \003(\0132\016.p" + + "rotocol.Vote\"-\n\010TXOutput\022\r\n\005value\030\001 \001(\003\022" + + "\022\n\npubKeyHash\030\002 \001(\014\"x\n\007TXInput\022\'\n\010raw_da" + + "ta\030\001 \001(\0132\025.protocol.TXInput.raw\022\021\n\tsigna" + + "ture\030\004 \001(\014\0321\n\003raw\022\014\n\004txID\030\001 \001(\014\022\014\n\004vout\030" + + "\002 \001(\003\022\016\n\006pubKey\030\003 \001(\014\"0\n\tTXOutputs\022#\n\007ou" + + "tputs\030\001 \003(\0132\022.protocol.TXOutput\"\325\001\n\017Reso" + + "urceReceipt\022\024\n\014energy_usage\030\001 \001(\003\022\022\n\nene" + + "rgy_fee\030\002 \001(\003\022\033\n\023origin_energy_usage\030\003 \001" + + "(\003\022\032\n\022energy_usage_total\030\004 \001(\003\022\021\n\tnet_us" + + "age\030\005 \001(\003\022\017\n\007net_fee\030\006 \001(\003\022;\n\006result\030\007 \001" + + "(\0162+.protocol.Transaction.Result.contrac" + + "tResult\"\253\020\n\013Transaction\022+\n\010raw_data\030\001 \001(" + + "\0132\031.protocol.Transaction.raw\022\021\n\tsignatur" + + "e\030\002 \003(\014\022)\n\003ret\030\005 \003(\0132\034.protocol.Transact" + + "ion.Result\032\202\010\n\010Contract\0229\n\004type\030\001 \001(\0162+." + + "protocol.Transaction.Contract.ContractTy" + + "pe\022\'\n\tparameter\030\002 \001(\0132\024.google.protobuf." + + "Any\022\020\n\010provider\030\003 \001(\014\022\024\n\014ContractName\030\004 " + + "\001(\014\022\025\n\rPermission_id\030\005 \001(\005\"\322\006\n\014ContractT" + + "ype\022\031\n\025AccountCreateContract\020\000\022\024\n\020Transf" + + "erContract\020\001\022\031\n\025TransferAssetContract\020\002\022" + + "\025\n\021VoteAssetContract\020\003\022\027\n\023VoteWitnessCon" + + "tract\020\004\022\031\n\025WitnessCreateContract\020\005\022\026\n\022As" + + "setIssueContract\020\006\022\031\n\025WitnessUpdateContr" + + "act\020\010\022!\n\035ParticipateAssetIssueContract\020\t" + + "\022\031\n\025AccountUpdateContract\020\n\022\031\n\025FreezeBal" + + "anceContract\020\013\022\033\n\027UnfreezeBalanceContrac" + + "t\020\014\022\033\n\027WithdrawBalanceContract\020\r\022\031\n\025Unfr" + + "eezeAssetContract\020\016\022\027\n\023UpdateAssetContra" + + "ct\020\017\022\032\n\026ProposalCreateContract\020\020\022\033\n\027Prop" + + "osalApproveContract\020\021\022\032\n\026ProposalDeleteC" + + "ontract\020\022\022\030\n\024SetAccountIdContract\020\023\022\022\n\016C" + + "ustomContract\020\024\022\027\n\023CreateSmartContract\020\036" + + "\022\030\n\024TriggerSmartContract\020\037\022\017\n\013GetContrac" + + "t\020 \022\031\n\025UpdateSettingContract\020!\022\032\n\026Exchan" + + "geCreateContract\020)\022\032\n\026ExchangeInjectCont" + + "ract\020*\022\034\n\030ExchangeWithdrawContract\020+\022\037\n\033" + + "ExchangeTransactionContract\020,\022\035\n\031UpdateE" + + "nergyLimitContract\020-\022#\n\037AccountPermissio" + + "nUpdateContract\020.\022\024\n\020ClearABIContract\0200\032" + + "\254\005\n\006Result\022\013\n\003fee\030\001 \001(\003\022.\n\003ret\030\002 \001(\0162!.p" + + "rotocol.Transaction.Result.code\022@\n\013contr" + + "actRet\030\003 \001(\0162+.protocol.Transaction.Resu" + + "lt.contractResult\022\024\n\014assetIssueID\030\016 \001(\t\022" + + "\027\n\017withdraw_amount\030\017 \001(\003\022\027\n\017unfreeze_amo" + + "unt\030\020 \001(\003\022 \n\030exchange_received_amount\030\022 " + + "\001(\003\022&\n\036exchange_inject_another_amount\030\023 " + + "\001(\003\022(\n exchange_withdraw_another_amount\030" + + "\024 \001(\003\022\023\n\013exchange_id\030\025 \001(\003\"\036\n\004code\022\n\n\006SU" + + "CESS\020\000\022\n\n\006FAILED\020\001\"\261\002\n\016contractResult\022\013\n" + + "\007DEFAULT\020\000\022\013\n\007SUCCESS\020\001\022\n\n\006REVERT\020\002\022\030\n\024B" + + "AD_JUMP_DESTINATION\020\003\022\021\n\rOUT_OF_MEMORY\020\004" + + "\022\030\n\024PRECOMPILED_CONTRACT\020\005\022\023\n\017STACK_TOO_" + + "SMALL\020\006\022\023\n\017STACK_TOO_LARGE\020\007\022\025\n\021ILLEGAL_" + + "OPERATION\020\010\022\022\n\016STACK_OVERFLOW\020\t\022\021\n\rOUT_O" + + "F_ENERGY\020\n\022\017\n\013OUT_OF_TIME\020\013\022\027\n\023JVM_STACK" + + "_OVER_FLOW\020\014\022\013\n\007UNKNOWN\020\r\022\023\n\017TRANSFER_FA" + + "ILED\020\016\032\374\001\n\003raw\022\027\n\017ref_block_bytes\030\001 \001(\014\022" + + "\025\n\rref_block_num\030\003 \001(\003\022\026\n\016ref_block_hash" + + "\030\004 \001(\014\022\022\n\nexpiration\030\010 \001(\003\022\"\n\005auths\030\t \003(" + + "\0132\023.protocol.authority\022\014\n\004data\030\n \001(\014\0220\n\010" + + "contract\030\013 \003(\0132\036.protocol.Transaction.Co" + + "ntract\022\017\n\007scripts\030\014 \001(\014\022\021\n\ttimestamp\030\016 \001" + + "(\003\022\021\n\tfee_limit\030\022 \001(\003\"\212\005\n\017TransactionInf" + + "o\022\n\n\002id\030\001 \001(\014\022\013\n\003fee\030\002 \001(\003\022\023\n\013blockNumbe" + + "r\030\003 \001(\003\022\026\n\016blockTimeStamp\030\004 \001(\003\022\026\n\016contr" + + "actResult\030\005 \003(\014\022\030\n\020contract_address\030\006 \001(" + + "\014\022*\n\007receipt\030\007 \001(\0132\031.protocol.ResourceRe" + + "ceipt\022*\n\003log\030\010 \003(\0132\035.protocol.Transactio" + + "nInfo.Log\022.\n\006result\030\t \001(\0162\036.protocol.Tra" + + "nsactionInfo.code\022\022\n\nresMessage\030\n \001(\014\022\024\n" + + "\014assetIssueID\030\016 \001(\t\022\027\n\017withdraw_amount\030\017" + + " \001(\003\022\027\n\017unfreeze_amount\030\020 \001(\003\022<\n\025interna" + + "l_transactions\030\021 \003(\0132\035.protocol.Internal" + + "Transaction\022 \n\030exchange_received_amount\030" + + "\022 \001(\003\022&\n\036exchange_inject_another_amount\030" + + "\023 \001(\003\022(\n exchange_withdraw_another_amoun" + + "t\030\024 \001(\003\022\023\n\013exchange_id\030\025 \001(\003\0324\n\003Log\022\017\n\007a" + + "ddress\030\001 \001(\014\022\016\n\006topics\030\002 \003(\014\022\014\n\004data\030\003 \001" + + "(\014\"\036\n\004code\022\n\n\006SUCESS\020\000\022\n\n\006FAILED\020\001\"q\n\016Tr" + + "ansactionRet\022\023\n\013blockNumber\030\001 \001(\003\022\026\n\016blo" + + "ckTimeStamp\030\002 \001(\003\0222\n\017transactioninfo\030\003 \003" + + "(\0132\031.protocol.TransactionInfo\";\n\014Transac" + + "tions\022+\n\014transactions\030\001 \003(\0132\025.protocol.T" + + "ransaction\"Q\n\017TransactionSign\022*\n\013transac" + + "tion\030\001 \001(\0132\025.protocol.Transaction\022\022\n\npri" + + "vateKey\030\002 \001(\014\"\200\002\n\013BlockHeader\022+\n\010raw_dat" + + "a\030\001 \001(\0132\031.protocol.BlockHeader.raw\022\031\n\021wi" + + "tness_signature\030\002 \001(\014\032\250\001\n\003raw\022\021\n\ttimesta" + + "mp\030\001 \001(\003\022\022\n\ntxTrieRoot\030\002 \001(\014\022\022\n\nparentHa" + + "sh\030\003 \001(\014\022\016\n\006number\030\007 \001(\003\022\022\n\nwitness_id\030\010" + + " \001(\003\022\027\n\017witness_address\030\t \001(\014\022\017\n\007version" + + "\030\n \001(\005\022\030\n\020accountStateRoot\030\013 \001(\014\"a\n\005Bloc" + + "k\022+\n\014transactions\030\001 \003(\0132\025.protocol.Trans" + + "action\022+\n\014block_header\030\002 \001(\0132\025.protocol." + + "BlockHeader\"|\n\016ChainInventory\022-\n\003ids\030\001 \003" + + "(\0132 .protocol.ChainInventory.BlockId\022\022\n\n" + + "remain_num\030\002 \001(\003\032\'\n\007BlockId\022\014\n\004hash\030\001 \001(" + + "\014\022\016\n\006number\030\002 \001(\003\"\277\001\n\016BlockInventory\022-\n\003" + + "ids\030\001 \003(\0132 .protocol.BlockInventory.Bloc" + + "kId\022+\n\004type\030\002 \001(\0162\035.protocol.BlockInvent" + + "ory.Type\032\'\n\007BlockId\022\014\n\004hash\030\001 \001(\014\022\016\n\006num" + + "ber\030\002 \001(\003\"(\n\004Type\022\010\n\004SYNC\020\000\022\013\n\007ADVTISE\020\001" + + "\022\t\n\005FETCH\020\002\"n\n\tInventory\022/\n\004type\030\001 \001(\0162!" + + ".protocol.Inventory.InventoryType\022\013\n\003ids" + + "\030\002 \003(\014\"#\n\rInventoryType\022\007\n\003TRX\020\000\022\t\n\005BLOC" + + "K\020\001\"\345\001\n\005Items\022&\n\004type\030\001 \001(\0162\030.protocol.I" + + "tems.ItemType\022\037\n\006blocks\030\002 \003(\0132\017.protocol" + + ".Block\022,\n\rblock_headers\030\003 \003(\0132\025.protocol" + + ".BlockHeader\022+\n\014transactions\030\004 \003(\0132\025.pro" + + "tocol.Transaction\"8\n\010ItemType\022\007\n\003ERR\020\000\022\007" + + "\n\003TRX\020\001\022\t\n\005BLOCK\020\002\022\017\n\013BLOCKHEADER\020\003\"4\n\021D" + + "ynamicProperties\022\037\n\027last_solidity_block_" + + "num\030\001 \001(\003\"9\n\021DisconnectMessage\022$\n\006reason" + + "\030\001 \001(\0162\024.protocol.ReasonCode\"\240\002\n\014HelloMe" + + "ssage\022 \n\004from\030\001 \001(\0132\022.protocol.Endpoint\022" + + "\017\n\007version\030\002 \001(\005\022\021\n\ttimestamp\030\003 \001(\003\0226\n\016g" + + "enesisBlockId\030\004 \001(\0132\036.protocol.HelloMess" + + "age.BlockId\0224\n\014solidBlockId\030\005 \001(\0132\036.prot" + + "ocol.HelloMessage.BlockId\0223\n\013headBlockId" + + "\030\006 \001(\0132\036.protocol.HelloMessage.BlockId\032\'" + + "\n\007BlockId\022\014\n\004hash\030\001 \001(\014\022\016\n\006number\030\002 \001(\003\"" + + "\203\007\n\rSmartContract\022\026\n\016origin_address\030\001 \001(" + + "\014\022\030\n\020contract_address\030\002 \001(\014\022(\n\003abi\030\003 \001(\013" + + "2\033.protocol.SmartContract.ABI\022\020\n\010bytecod" + + "e\030\004 \001(\014\022\022\n\ncall_value\030\005 \001(\003\022%\n\035consume_u" + + "ser_resource_percent\030\006 \001(\003\022\014\n\004name\030\007 \001(\t" + + "\022\033\n\023origin_energy_limit\030\010 \001(\003\022\021\n\tcode_ha" + + "sh\030\t \001(\014\022\020\n\010trx_hash\030\n \001(\014\032\370\004\n\003ABI\0221\n\006en" + + "trys\030\001 \003(\0132!.protocol.SmartContract.ABI." + + "Entry\032\275\004\n\005Entry\022\021\n\tanonymous\030\001 \001(\010\022\020\n\010co" + + "nstant\030\002 \001(\010\022\014\n\004name\030\003 \001(\t\0227\n\006inputs\030\004 \003" + + "(\0132\'.protocol.SmartContract.ABI.Entry.Pa" + + "ram\0228\n\007outputs\030\005 \003(\0132\'.protocol.SmartCon" + + "tract.ABI.Entry.Param\0229\n\004type\030\006 \001(\0162+.pr" + + "otocol.SmartContract.ABI.Entry.EntryType" + + "\022\017\n\007payable\030\007 \001(\010\022N\n\017stateMutability\030\010 \001" + + "(\01625.protocol.SmartContract.ABI.Entry.St" + + "ateMutabilityType\0324\n\005Param\022\017\n\007indexed\030\001 " + + "\001(\010\022\014\n\004name\030\002 \001(\t\022\014\n\004type\030\003 \001(\t\"Y\n\tEntry" + + "Type\022\024\n\020UnknownEntryType\020\000\022\017\n\013Constructo" + + "r\020\001\022\014\n\010Function\020\002\022\t\n\005Event\020\003\022\014\n\010Fallback" + + "\020\004\"a\n\023StateMutabilityType\022\031\n\025UnknownMuta" + + "bilityType\020\000\022\010\n\004Pure\020\001\022\010\n\004View\020\002\022\016\n\nNonp" + + "ayable\020\003\022\013\n\007Payable\020\004\"\360\001\n\023InternalTransa" + + "ction\022\014\n\004hash\030\001 \001(\014\022\026\n\016caller_address\030\002 " + + "\001(\014\022\032\n\022transferTo_address\030\003 \001(\014\022B\n\rcallV" + + "alueInfo\030\004 \003(\0132+.protocol.InternalTransa" + + "ction.CallValueInfo\022\014\n\004note\030\005 \001(\014\022\020\n\010rej" + + "ected\030\006 \001(\010\0323\n\rCallValueInfo\022\021\n\tcallValu" + + "e\030\001 \001(\003\022\017\n\007tokenId\030\002 \001(\t\"Z\n\035DelegatedRes" + + "ourceAccountIndex\022\017\n\007account\030\001 \001(\014\022\024\n\014fr" + + "omAccounts\030\002 \003(\014\022\022\n\ntoAccounts\030\003 \003(\014\"\240\021\n" + + "\010NodeInfo\022\024\n\014beginSyncNum\030\001 \001(\003\022\r\n\005block" + + "\030\002 \001(\t\022\025\n\rsolidityBlock\030\003 \001(\t\022\033\n\023current" + + "ConnectCount\030\004 \001(\005\022\032\n\022activeConnectCount" + + "\030\005 \001(\005\022\033\n\023passiveConnectCount\030\006 \001(\005\022\021\n\tt" + + "otalFlow\030\007 \001(\003\0221\n\014peerInfoList\030\010 \003(\0132\033.p" + + "rotocol.NodeInfo.PeerInfo\0229\n\016configNodeI" + + "nfo\030\t \001(\0132!.protocol.NodeInfo.ConfigNode" + + "Info\0223\n\013machineInfo\030\n \001(\0132\036.protocol.Nod" + + "eInfo.MachineInfo\022H\n\023cheatWitnessInfoMap" + + "\030\013 \003(\0132+.protocol.NodeInfo.CheatWitnessI" + + "nfoMapEntry\032:\n\030CheatWitnessInfoMapEntry\022" + + "\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\032\315\004\n\010Peer" + + "Info\022\025\n\rlastSyncBlock\030\001 \001(\t\022\021\n\tremainNum" + + "\030\002 \001(\003\022\033\n\023lastBlockUpdateTime\030\003 \001(\003\022\020\n\010s" + + "yncFlag\030\004 \001(\010\022\037\n\027headBlockTimeWeBothHave" + + "\030\005 \001(\003\022\030\n\020needSyncFromPeer\030\006 \001(\010\022\026\n\016need" + + "SyncFromUs\030\007 \001(\010\022\014\n\004host\030\010 \001(\t\022\014\n\004port\030\t" + + " \001(\005\022\016\n\006nodeId\030\n \001(\t\022\023\n\013connectTime\030\013 \001(" + + "\003\022\022\n\navgLatency\030\014 \001(\001\022\027\n\017syncToFetchSize" + + "\030\r \001(\005\022\036\n\026syncToFetchSizePeekNum\030\016 \001(\003\022\036" + + "\n\026syncBlockRequestedSize\030\017 \001(\005\022\025\n\runFetc" + + "hSynNum\030\020 \001(\003\022\027\n\017blockInPorcSize\030\021 \001(\005\022\033" + + "\n\023headBlockWeBothHave\030\022 \001(\t\022\020\n\010isActive\030" + + "\023 \001(\010\022\r\n\005score\030\024 \001(\005\022\021\n\tnodeCount\030\025 \001(\005\022" + + "\016\n\006inFlow\030\026 \001(\003\022\027\n\017disconnectTimes\030\027 \001(\005" + + "\022\035\n\025localDisconnectReason\030\030 \001(\t\022\036\n\026remot" + + "eDisconnectReason\030\031 \001(\t\032\345\003\n\016ConfigNodeIn" + + "fo\022\023\n\013codeVersion\030\001 \001(\t\022\022\n\np2pVersion\030\002 " + + "\001(\t\022\022\n\nlistenPort\030\003 \001(\005\022\026\n\016discoverEnabl" + + "e\030\004 \001(\010\022\026\n\016activeNodeSize\030\005 \001(\005\022\027\n\017passi" + + "veNodeSize\030\006 \001(\005\022\024\n\014sendNodeSize\030\007 \001(\005\022\027" + + "\n\017maxConnectCount\030\010 \001(\005\022\035\n\025sameIpMaxConn" + + "ectCount\030\t \001(\005\022\030\n\020backupListenPort\030\n \001(\005" + + "\022\030\n\020backupMemberSize\030\013 \001(\005\022\026\n\016backupPrio" + + "rity\030\014 \001(\005\022\021\n\tdbVersion\030\r \001(\005\022\034\n\024minPart" + + "icipationRate\030\016 \001(\005\022\027\n\017supportConstant\030\017" + + " \001(\010\022\024\n\014minTimeRatio\030\020 \001(\001\022\024\n\014maxTimeRat" + + "io\030\021 \001(\001\022 \n\030allowCreationOfContracts\030\022 \001" + + "(\003\022\033\n\023allowAdaptiveEnergy\030\023 \001(\003\032\215\005\n\013Mach" + + "ineInfo\022\023\n\013threadCount\030\001 \001(\005\022\033\n\023deadLock" + + "ThreadCount\030\002 \001(\005\022\020\n\010cpuCount\030\003 \001(\005\022\023\n\013t" + + "otalMemory\030\004 \001(\003\022\022\n\nfreeMemory\030\005 \001(\003\022\017\n\007" + + "cpuRate\030\006 \001(\001\022\023\n\013javaVersion\030\007 \001(\t\022\016\n\006os" + + "Name\030\010 \001(\t\022\027\n\017jvmTotalMemoery\030\t \001(\003\022\025\n\rj" + + "vmFreeMemory\030\n \001(\003\022\026\n\016processCpuRate\030\013 \001" + + "(\001\022I\n\022memoryDescInfoList\030\014 \003(\0132-.protoco" + + "l.NodeInfo.MachineInfo.MemoryDescInfo\022Q\n" + + "\026deadLockThreadInfoList\030\r \003(\01321.protocol" + + ".NodeInfo.MachineInfo.DeadLockThreadInfo" + + "\032c\n\016MemoryDescInfo\022\014\n\004name\030\001 \001(\t\022\020\n\010init" + + "Size\030\002 \001(\003\022\017\n\007useSize\030\003 \001(\003\022\017\n\007maxSize\030\004" + + " \001(\003\022\017\n\007useRate\030\005 \001(\001\032\217\001\n\022DeadLockThread" + + "Info\022\014\n\004name\030\001 \001(\t\022\020\n\010lockName\030\002 \001(\t\022\021\n\t" + + "lockOwner\030\003 \001(\t\022\r\n\005state\030\004 \001(\t\022\021\n\tblockT" + + "ime\030\005 \001(\003\022\020\n\010waitTime\030\006 \001(\003\022\022\n\nstackTrac" + + "e\030\007 \001(\t*7\n\013AccountType\022\n\n\006Normal\020\000\022\016\n\nAs" + + "setIssue\020\001\022\014\n\010Contract\020\002*\307\003\n\nReasonCode\022" + + "\r\n\tREQUESTED\020\000\022\020\n\014BAD_PROTOCOL\020\002\022\022\n\016TOO_" + + "MANY_PEERS\020\004\022\022\n\016DUPLICATE_PEER\020\005\022\031\n\025INCO" + + "MPATIBLE_PROTOCOL\020\006\022\021\n\rNULL_IDENTITY\020\007\022\020" + + "\n\014PEER_QUITING\020\010\022\027\n\023UNEXPECTED_IDENTITY\020" + + "\t\022\022\n\016LOCAL_IDENTITY\020\n\022\020\n\014PING_TIMEOUT\020\013\022" + + "\017\n\013USER_REASON\020\020\022\t\n\005RESET\020\021\022\r\n\tSYNC_FAIL" + + "\020\022\022\016\n\nFETCH_FAIL\020\023\022\n\n\006BAD_TX\020\024\022\r\n\tBAD_BL" + + "OCK\020\025\022\n\n\006FORKED\020\026\022\016\n\nUNLINKABLE\020\027\022\030\n\024INC" + + "OMPATIBLE_VERSION\020\030\022\026\n\022INCOMPATIBLE_CHAI" + + "N\020\031\022\014\n\010TIME_OUT\020 \022\020\n\014CONNECT_FAIL\020!\022\037\n\033T" + + "OO_MANY_PEERS_WITH_SAME_IP\020\"\022\014\n\007UNKNOWN\020" + + "\377\001BF\n\017org.tron.protosB\010ProtocolZ)github." + + "com/tronprotocol/grpc-gateway/coreb\006prot" + + "o3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.AnyProto.getDescriptor(), + org.tron.protos.Discover.getDescriptor(), + }, assigner); + internal_static_protocol_AccountId_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_protocol_AccountId_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_AccountId_descriptor, + new java.lang.String[] { "Name", "Address", }); + internal_static_protocol_Vote_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_protocol_Vote_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Vote_descriptor, + new java.lang.String[] { "VoteAddress", "VoteCount", }); + internal_static_protocol_Proposal_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_protocol_Proposal_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Proposal_descriptor, + new java.lang.String[] { "ProposalId", "ProposerAddress", "Parameters", "ExpirationTime", "CreateTime", "Approvals", "State", }); + internal_static_protocol_Proposal_ParametersEntry_descriptor = + internal_static_protocol_Proposal_descriptor.getNestedTypes().get(0); + internal_static_protocol_Proposal_ParametersEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Proposal_ParametersEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Exchange_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_protocol_Exchange_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Exchange_descriptor, + new java.lang.String[] { "ExchangeId", "CreatorAddress", "CreateTime", "FirstTokenId", "FirstTokenBalance", "SecondTokenId", "SecondTokenBalance", }); + internal_static_protocol_ChainParameters_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_protocol_ChainParameters_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ChainParameters_descriptor, + new java.lang.String[] { "ChainParameter", }); + internal_static_protocol_ChainParameters_ChainParameter_descriptor = + internal_static_protocol_ChainParameters_descriptor.getNestedTypes().get(0); + internal_static_protocol_ChainParameters_ChainParameter_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ChainParameters_ChainParameter_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Account_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_protocol_Account_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_descriptor, + new java.lang.String[] { "AccountName", "Type", "Address", "Balance", "Votes", "Asset", "AssetV2", "Frozen", "NetUsage", "AcquiredDelegatedFrozenBalanceForBandwidth", "DelegatedFrozenBalanceForBandwidth", "CreateTime", "LatestOprationTime", "Allowance", "LatestWithdrawTime", "Code", "IsWitness", "IsCommittee", "FrozenSupply", "AssetIssuedName", "AssetIssuedID", "LatestAssetOperationTime", "LatestAssetOperationTimeV2", "FreeNetUsage", "FreeAssetNetUsage", "FreeAssetNetUsageV2", "LatestConsumeTime", "LatestConsumeFreeTime", "AccountId", "AccountResource", "CodeHash", "OwnerPermission", "WitnessPermission", "ActivePermission", }); + internal_static_protocol_Account_Frozen_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(0); + internal_static_protocol_Account_Frozen_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_Frozen_descriptor, + new java.lang.String[] { "FrozenBalance", "ExpireTime", }); + internal_static_protocol_Account_AssetEntry_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(1); + internal_static_protocol_Account_AssetEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_AssetEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Account_AssetV2Entry_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(2); + internal_static_protocol_Account_AssetV2Entry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_AssetV2Entry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Account_LatestAssetOperationTimeEntry_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(3); + internal_static_protocol_Account_LatestAssetOperationTimeEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_LatestAssetOperationTimeEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Account_LatestAssetOperationTimeV2Entry_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(4); + internal_static_protocol_Account_LatestAssetOperationTimeV2Entry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_LatestAssetOperationTimeV2Entry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Account_FreeAssetNetUsageEntry_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(5); + internal_static_protocol_Account_FreeAssetNetUsageEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_FreeAssetNetUsageEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Account_FreeAssetNetUsageV2Entry_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(6); + internal_static_protocol_Account_FreeAssetNetUsageV2Entry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_FreeAssetNetUsageV2Entry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_Account_AccountResource_descriptor = + internal_static_protocol_Account_descriptor.getNestedTypes().get(7); + internal_static_protocol_Account_AccountResource_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Account_AccountResource_descriptor, + new java.lang.String[] { "EnergyUsage", "FrozenBalanceForEnergy", "LatestConsumeTimeForEnergy", "AcquiredDelegatedFrozenBalanceForEnergy", "DelegatedFrozenBalanceForEnergy", "StorageLimit", "StorageUsage", "LatestExchangeStorageTime", }); + internal_static_protocol_Key_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_protocol_Key_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Key_descriptor, + new java.lang.String[] { "Address", "Weight", }); + internal_static_protocol_DelegatedResource_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_protocol_DelegatedResource_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_DelegatedResource_descriptor, + new java.lang.String[] { "From", "To", "FrozenBalanceForBandwidth", "FrozenBalanceForEnergy", "ExpireTimeForBandwidth", "ExpireTimeForEnergy", }); + internal_static_protocol_authority_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_protocol_authority_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_authority_descriptor, + new java.lang.String[] { "Account", "PermissionName", }); + internal_static_protocol_Permission_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_protocol_Permission_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Permission_descriptor, + new java.lang.String[] { "Type", "Id", "PermissionName", "Threshold", "ParentId", "Operations", "Keys", }); + internal_static_protocol_Witness_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_protocol_Witness_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Witness_descriptor, + new java.lang.String[] { "Address", "VoteCount", "PubKey", "Url", "TotalProduced", "TotalMissed", "LatestBlockNum", "LatestSlotNum", "IsJobs", }); + internal_static_protocol_Votes_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_protocol_Votes_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Votes_descriptor, + new java.lang.String[] { "Address", "OldVotes", "NewVotes", }); + internal_static_protocol_TXOutput_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_protocol_TXOutput_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TXOutput_descriptor, + new java.lang.String[] { "Value", "PubKeyHash", }); + internal_static_protocol_TXInput_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_protocol_TXInput_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TXInput_descriptor, + new java.lang.String[] { "RawData", "Signature", }); + internal_static_protocol_TXInput_raw_descriptor = + internal_static_protocol_TXInput_descriptor.getNestedTypes().get(0); + internal_static_protocol_TXInput_raw_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TXInput_raw_descriptor, + new java.lang.String[] { "TxID", "Vout", "PubKey", }); + internal_static_protocol_TXOutputs_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_protocol_TXOutputs_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TXOutputs_descriptor, + new java.lang.String[] { "Outputs", }); + internal_static_protocol_ResourceReceipt_descriptor = + getDescriptor().getMessageTypes().get(15); + internal_static_protocol_ResourceReceipt_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ResourceReceipt_descriptor, + new java.lang.String[] { "EnergyUsage", "EnergyFee", "OriginEnergyUsage", "EnergyUsageTotal", "NetUsage", "NetFee", "Result", }); + internal_static_protocol_Transaction_descriptor = + getDescriptor().getMessageTypes().get(16); + internal_static_protocol_Transaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Transaction_descriptor, + new java.lang.String[] { "RawData", "Signature", "Ret", }); + internal_static_protocol_Transaction_Contract_descriptor = + internal_static_protocol_Transaction_descriptor.getNestedTypes().get(0); + internal_static_protocol_Transaction_Contract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Transaction_Contract_descriptor, + new java.lang.String[] { "Type", "Parameter", "Provider", "ContractName", "PermissionId", }); + internal_static_protocol_Transaction_Result_descriptor = + internal_static_protocol_Transaction_descriptor.getNestedTypes().get(1); + internal_static_protocol_Transaction_Result_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Transaction_Result_descriptor, + new java.lang.String[] { "Fee", "Ret", "ContractRet", "AssetIssueID", "WithdrawAmount", "UnfreezeAmount", "ExchangeReceivedAmount", "ExchangeInjectAnotherAmount", "ExchangeWithdrawAnotherAmount", "ExchangeId", }); + internal_static_protocol_Transaction_raw_descriptor = + internal_static_protocol_Transaction_descriptor.getNestedTypes().get(2); + internal_static_protocol_Transaction_raw_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Transaction_raw_descriptor, + new java.lang.String[] { "RefBlockBytes", "RefBlockNum", "RefBlockHash", "Expiration", "Auths", "Data", "Contract", "Scripts", "Timestamp", "FeeLimit", }); + internal_static_protocol_TransactionInfo_descriptor = + getDescriptor().getMessageTypes().get(17); + internal_static_protocol_TransactionInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionInfo_descriptor, + new java.lang.String[] { "Id", "Fee", "BlockNumber", "BlockTimeStamp", "ContractResult", "ContractAddress", "Receipt", "Log", "Result", "ResMessage", "AssetIssueID", "WithdrawAmount", "UnfreezeAmount", "InternalTransactions", "ExchangeReceivedAmount", "ExchangeInjectAnotherAmount", "ExchangeWithdrawAnotherAmount", "ExchangeId", }); + internal_static_protocol_TransactionInfo_Log_descriptor = + internal_static_protocol_TransactionInfo_descriptor.getNestedTypes().get(0); + internal_static_protocol_TransactionInfo_Log_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionInfo_Log_descriptor, + new java.lang.String[] { "Address", "Topics", "Data", }); + internal_static_protocol_TransactionRet_descriptor = + getDescriptor().getMessageTypes().get(18); + internal_static_protocol_TransactionRet_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionRet_descriptor, + new java.lang.String[] { "BlockNumber", "BlockTimeStamp", "Transactioninfo", }); + internal_static_protocol_Transactions_descriptor = + getDescriptor().getMessageTypes().get(19); + internal_static_protocol_Transactions_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Transactions_descriptor, + new java.lang.String[] { "Transactions", }); + internal_static_protocol_TransactionSign_descriptor = + getDescriptor().getMessageTypes().get(20); + internal_static_protocol_TransactionSign_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_TransactionSign_descriptor, + new java.lang.String[] { "Transaction", "PrivateKey", }); + internal_static_protocol_BlockHeader_descriptor = + getDescriptor().getMessageTypes().get(21); + internal_static_protocol_BlockHeader_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockHeader_descriptor, + new java.lang.String[] { "RawData", "WitnessSignature", }); + internal_static_protocol_BlockHeader_raw_descriptor = + internal_static_protocol_BlockHeader_descriptor.getNestedTypes().get(0); + internal_static_protocol_BlockHeader_raw_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockHeader_raw_descriptor, + new java.lang.String[] { "Timestamp", "TxTrieRoot", "ParentHash", "Number", "WitnessId", "WitnessAddress", "Version", "AccountStateRoot", }); + internal_static_protocol_Block_descriptor = + getDescriptor().getMessageTypes().get(22); + internal_static_protocol_Block_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Block_descriptor, + new java.lang.String[] { "Transactions", "BlockHeader", }); + internal_static_protocol_ChainInventory_descriptor = + getDescriptor().getMessageTypes().get(23); + internal_static_protocol_ChainInventory_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ChainInventory_descriptor, + new java.lang.String[] { "Ids", "RemainNum", }); + internal_static_protocol_ChainInventory_BlockId_descriptor = + internal_static_protocol_ChainInventory_descriptor.getNestedTypes().get(0); + internal_static_protocol_ChainInventory_BlockId_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_ChainInventory_BlockId_descriptor, + new java.lang.String[] { "Hash", "Number", }); + internal_static_protocol_BlockInventory_descriptor = + getDescriptor().getMessageTypes().get(24); + internal_static_protocol_BlockInventory_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockInventory_descriptor, + new java.lang.String[] { "Ids", "Type", }); + internal_static_protocol_BlockInventory_BlockId_descriptor = + internal_static_protocol_BlockInventory_descriptor.getNestedTypes().get(0); + internal_static_protocol_BlockInventory_BlockId_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_BlockInventory_BlockId_descriptor, + new java.lang.String[] { "Hash", "Number", }); + internal_static_protocol_Inventory_descriptor = + getDescriptor().getMessageTypes().get(25); + internal_static_protocol_Inventory_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Inventory_descriptor, + new java.lang.String[] { "Type", "Ids", }); + internal_static_protocol_Items_descriptor = + getDescriptor().getMessageTypes().get(26); + internal_static_protocol_Items_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_Items_descriptor, + new java.lang.String[] { "Type", "Blocks", "BlockHeaders", "Transactions", }); + internal_static_protocol_DynamicProperties_descriptor = + getDescriptor().getMessageTypes().get(27); + internal_static_protocol_DynamicProperties_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_DynamicProperties_descriptor, + new java.lang.String[] { "LastSolidityBlockNum", }); + internal_static_protocol_DisconnectMessage_descriptor = + getDescriptor().getMessageTypes().get(28); + internal_static_protocol_DisconnectMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_DisconnectMessage_descriptor, + new java.lang.String[] { "Reason", }); + internal_static_protocol_HelloMessage_descriptor = + getDescriptor().getMessageTypes().get(29); + internal_static_protocol_HelloMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_HelloMessage_descriptor, + new java.lang.String[] { "From", "Version", "Timestamp", "GenesisBlockId", "SolidBlockId", "HeadBlockId", }); + internal_static_protocol_HelloMessage_BlockId_descriptor = + internal_static_protocol_HelloMessage_descriptor.getNestedTypes().get(0); + internal_static_protocol_HelloMessage_BlockId_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_HelloMessage_BlockId_descriptor, + new java.lang.String[] { "Hash", "Number", }); + internal_static_protocol_SmartContract_descriptor = + getDescriptor().getMessageTypes().get(30); + internal_static_protocol_SmartContract_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_SmartContract_descriptor, + new java.lang.String[] { "OriginAddress", "ContractAddress", "Abi", "Bytecode", "CallValue", "ConsumeUserResourcePercent", "Name", "OriginEnergyLimit", "CodeHash", "TrxHash", }); + internal_static_protocol_SmartContract_ABI_descriptor = + internal_static_protocol_SmartContract_descriptor.getNestedTypes().get(0); + internal_static_protocol_SmartContract_ABI_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_SmartContract_ABI_descriptor, + new java.lang.String[] { "Entrys", }); + internal_static_protocol_SmartContract_ABI_Entry_descriptor = + internal_static_protocol_SmartContract_ABI_descriptor.getNestedTypes().get(0); + internal_static_protocol_SmartContract_ABI_Entry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_SmartContract_ABI_Entry_descriptor, + new java.lang.String[] { "Anonymous", "Constant", "Name", "Inputs", "Outputs", "Type", "Payable", "StateMutability", }); + internal_static_protocol_SmartContract_ABI_Entry_Param_descriptor = + internal_static_protocol_SmartContract_ABI_Entry_descriptor.getNestedTypes().get(0); + internal_static_protocol_SmartContract_ABI_Entry_Param_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_SmartContract_ABI_Entry_Param_descriptor, + new java.lang.String[] { "Indexed", "Name", "Type", }); + internal_static_protocol_InternalTransaction_descriptor = + getDescriptor().getMessageTypes().get(31); + internal_static_protocol_InternalTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_InternalTransaction_descriptor, + new java.lang.String[] { "Hash", "CallerAddress", "TransferToAddress", "CallValueInfo", "Note", "Rejected", }); + internal_static_protocol_InternalTransaction_CallValueInfo_descriptor = + internal_static_protocol_InternalTransaction_descriptor.getNestedTypes().get(0); + internal_static_protocol_InternalTransaction_CallValueInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_InternalTransaction_CallValueInfo_descriptor, + new java.lang.String[] { "CallValue", "TokenId", }); + internal_static_protocol_DelegatedResourceAccountIndex_descriptor = + getDescriptor().getMessageTypes().get(32); + internal_static_protocol_DelegatedResourceAccountIndex_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_DelegatedResourceAccountIndex_descriptor, + new java.lang.String[] { "Account", "FromAccounts", "ToAccounts", }); + internal_static_protocol_NodeInfo_descriptor = + getDescriptor().getMessageTypes().get(33); + internal_static_protocol_NodeInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeInfo_descriptor, + new java.lang.String[] { "BeginSyncNum", "Block", "SolidityBlock", "CurrentConnectCount", "ActiveConnectCount", "PassiveConnectCount", "TotalFlow", "PeerInfoList", "ConfigNodeInfo", "MachineInfo", "CheatWitnessInfoMap", }); + internal_static_protocol_NodeInfo_CheatWitnessInfoMapEntry_descriptor = + internal_static_protocol_NodeInfo_descriptor.getNestedTypes().get(0); + internal_static_protocol_NodeInfo_CheatWitnessInfoMapEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeInfo_CheatWitnessInfoMapEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_protocol_NodeInfo_PeerInfo_descriptor = + internal_static_protocol_NodeInfo_descriptor.getNestedTypes().get(1); + internal_static_protocol_NodeInfo_PeerInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeInfo_PeerInfo_descriptor, + new java.lang.String[] { "LastSyncBlock", "RemainNum", "LastBlockUpdateTime", "SyncFlag", "HeadBlockTimeWeBothHave", "NeedSyncFromPeer", "NeedSyncFromUs", "Host", "Port", "NodeId", "ConnectTime", "AvgLatency", "SyncToFetchSize", "SyncToFetchSizePeekNum", "SyncBlockRequestedSize", "UnFetchSynNum", "BlockInPorcSize", "HeadBlockWeBothHave", "IsActive", "Score", "NodeCount", "InFlow", "DisconnectTimes", "LocalDisconnectReason", "RemoteDisconnectReason", }); + internal_static_protocol_NodeInfo_ConfigNodeInfo_descriptor = + internal_static_protocol_NodeInfo_descriptor.getNestedTypes().get(2); + internal_static_protocol_NodeInfo_ConfigNodeInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeInfo_ConfigNodeInfo_descriptor, + new java.lang.String[] { "CodeVersion", "P2PVersion", "ListenPort", "DiscoverEnable", "ActiveNodeSize", "PassiveNodeSize", "SendNodeSize", "MaxConnectCount", "SameIpMaxConnectCount", "BackupListenPort", "BackupMemberSize", "BackupPriority", "DbVersion", "MinParticipationRate", "SupportConstant", "MinTimeRatio", "MaxTimeRatio", "AllowCreationOfContracts", "AllowAdaptiveEnergy", }); + internal_static_protocol_NodeInfo_MachineInfo_descriptor = + internal_static_protocol_NodeInfo_descriptor.getNestedTypes().get(3); + internal_static_protocol_NodeInfo_MachineInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeInfo_MachineInfo_descriptor, + new java.lang.String[] { "ThreadCount", "DeadLockThreadCount", "CpuCount", "TotalMemory", "FreeMemory", "CpuRate", "JavaVersion", "OsName", "JvmTotalMemoery", "JvmFreeMemory", "ProcessCpuRate", "MemoryDescInfoList", "DeadLockThreadInfoList", }); + internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_descriptor = + internal_static_protocol_NodeInfo_MachineInfo_descriptor.getNestedTypes().get(0); + internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeInfo_MachineInfo_MemoryDescInfo_descriptor, + new java.lang.String[] { "Name", "InitSize", "UseSize", "MaxSize", "UseRate", }); + internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_descriptor = + internal_static_protocol_NodeInfo_MachineInfo_descriptor.getNestedTypes().get(1); + internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_NodeInfo_MachineInfo_DeadLockThreadInfo_descriptor, + new java.lang.String[] { "Name", "LockName", "LockOwner", "State", "BlockTime", "WaitTime", "StackTrace", }); + com.google.protobuf.AnyProto.getDescriptor(); + org.tron.protos.Discover.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/framework/src/main/gen/org/tron/protos/TronInventoryItems.java b/framework/src/main/gen/org/tron/protos/TronInventoryItems.java new file mode 100644 index 00000000000..875fca2dfc5 --- /dev/null +++ b/framework/src/main/gen/org/tron/protos/TronInventoryItems.java @@ -0,0 +1,668 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: core/TronInventoryItems.proto + +package org.tron.protos; + +public final class TronInventoryItems { + private TronInventoryItems() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface InventoryItemsOrBuilder extends + // @@protoc_insertion_point(interface_extends:protocol.InventoryItems) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 type = 1; + */ + int getType(); + + /** + * repeated bytes items = 2; + */ + java.util.List getItemsList(); + /** + * repeated bytes items = 2; + */ + int getItemsCount(); + /** + * repeated bytes items = 2; + */ + com.google.protobuf.ByteString getItems(int index); + } + /** + * Protobuf type {@code protocol.InventoryItems} + */ + public static final class InventoryItems extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:protocol.InventoryItems) + InventoryItemsOrBuilder { + private static final long serialVersionUID = 0L; + // Use InventoryItems.newBuilder() to construct. + private InventoryItems(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private InventoryItems() { + type_ = 0; + items_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private InventoryItems( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + type_ = input.readInt32(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + items_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + items_.add(input.readBytes()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + items_ = java.util.Collections.unmodifiableList(items_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.TronInventoryItems.internal_static_protocol_InventoryItems_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.TronInventoryItems.internal_static_protocol_InventoryItems_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.TronInventoryItems.InventoryItems.class, org.tron.protos.TronInventoryItems.InventoryItems.Builder.class); + } + + private int bitField0_; + public static final int TYPE_FIELD_NUMBER = 1; + private int type_; + /** + * int32 type = 1; + */ + public int getType() { + return type_; + } + + public static final int ITEMS_FIELD_NUMBER = 2; + private java.util.List items_; + /** + * repeated bytes items = 2; + */ + public java.util.List + getItemsList() { + return items_; + } + /** + * repeated bytes items = 2; + */ + public int getItemsCount() { + return items_.size(); + } + /** + * repeated bytes items = 2; + */ + public com.google.protobuf.ByteString getItems(int index) { + return items_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (type_ != 0) { + output.writeInt32(1, type_); + } + for (int i = 0; i < items_.size(); i++) { + output.writeBytes(2, items_.get(i)); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (type_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, type_); + } + { + int dataSize = 0; + for (int i = 0; i < items_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(items_.get(i)); + } + size += dataSize; + size += 1 * getItemsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.tron.protos.TronInventoryItems.InventoryItems)) { + return super.equals(obj); + } + org.tron.protos.TronInventoryItems.InventoryItems other = (org.tron.protos.TronInventoryItems.InventoryItems) obj; + + boolean result = true; + result = result && (getType() + == other.getType()); + result = result && getItemsList() + .equals(other.getItemsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType(); + if (getItemsCount() > 0) { + hash = (37 * hash) + ITEMS_FIELD_NUMBER; + hash = (53 * hash) + getItemsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.tron.protos.TronInventoryItems.InventoryItems parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.tron.protos.TronInventoryItems.InventoryItems prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code protocol.InventoryItems} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:protocol.InventoryItems) + org.tron.protos.TronInventoryItems.InventoryItemsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.tron.protos.TronInventoryItems.internal_static_protocol_InventoryItems_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.tron.protos.TronInventoryItems.internal_static_protocol_InventoryItems_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.tron.protos.TronInventoryItems.InventoryItems.class, org.tron.protos.TronInventoryItems.InventoryItems.Builder.class); + } + + // Construct using org.tron.protos.TronInventoryItems.InventoryItems.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + type_ = 0; + + items_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.tron.protos.TronInventoryItems.internal_static_protocol_InventoryItems_descriptor; + } + + public org.tron.protos.TronInventoryItems.InventoryItems getDefaultInstanceForType() { + return org.tron.protos.TronInventoryItems.InventoryItems.getDefaultInstance(); + } + + public org.tron.protos.TronInventoryItems.InventoryItems build() { + org.tron.protos.TronInventoryItems.InventoryItems result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.tron.protos.TronInventoryItems.InventoryItems buildPartial() { + org.tron.protos.TronInventoryItems.InventoryItems result = new org.tron.protos.TronInventoryItems.InventoryItems(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.type_ = type_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + items_ = java.util.Collections.unmodifiableList(items_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.items_ = items_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.tron.protos.TronInventoryItems.InventoryItems) { + return mergeFrom((org.tron.protos.TronInventoryItems.InventoryItems)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.tron.protos.TronInventoryItems.InventoryItems other) { + if (other == org.tron.protos.TronInventoryItems.InventoryItems.getDefaultInstance()) return this; + if (other.getType() != 0) { + setType(other.getType()); + } + if (!other.items_.isEmpty()) { + if (items_.isEmpty()) { + items_ = other.items_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureItemsIsMutable(); + items_.addAll(other.items_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.tron.protos.TronInventoryItems.InventoryItems parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.tron.protos.TronInventoryItems.InventoryItems) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int type_ ; + /** + * int32 type = 1; + */ + public int getType() { + return type_; + } + /** + * int32 type = 1; + */ + public Builder setType(int value) { + + type_ = value; + onChanged(); + return this; + } + /** + * int32 type = 1; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private java.util.List items_ = java.util.Collections.emptyList(); + private void ensureItemsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + items_ = new java.util.ArrayList(items_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bytes items = 2; + */ + public java.util.List + getItemsList() { + return java.util.Collections.unmodifiableList(items_); + } + /** + * repeated bytes items = 2; + */ + public int getItemsCount() { + return items_.size(); + } + /** + * repeated bytes items = 2; + */ + public com.google.protobuf.ByteString getItems(int index) { + return items_.get(index); + } + /** + * repeated bytes items = 2; + */ + public Builder setItems( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureItemsIsMutable(); + items_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bytes items = 2; + */ + public Builder addItems(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureItemsIsMutable(); + items_.add(value); + onChanged(); + return this; + } + /** + * repeated bytes items = 2; + */ + public Builder addAllItems( + java.lang.Iterable values) { + ensureItemsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, items_); + onChanged(); + return this; + } + /** + * repeated bytes items = 2; + */ + public Builder clearItems() { + items_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:protocol.InventoryItems) + } + + // @@protoc_insertion_point(class_scope:protocol.InventoryItems) + private static final org.tron.protos.TronInventoryItems.InventoryItems DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.tron.protos.TronInventoryItems.InventoryItems(); + } + + public static org.tron.protos.TronInventoryItems.InventoryItems getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public InventoryItems parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new InventoryItems(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.tron.protos.TronInventoryItems.InventoryItems getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_protocol_InventoryItems_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_protocol_InventoryItems_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\035core/TronInventoryItems.proto\022\010protoco" + + "l\"-\n\016InventoryItems\022\014\n\004type\030\001 \001(\005\022\r\n\005ite" + + "ms\030\002 \003(\014BP\n\017org.tron.protosB\022TronInvento" + + "ryItemsZ)github.com/tronprotocol/grpc-ga" + + "teway/coreb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_protocol_InventoryItems_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_protocol_InventoryItems_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_protocol_InventoryItems_descriptor, + new java.lang.String[] { "Type", "Items", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/org/tron/common/application/Application.java b/framework/src/main/java/org/tron/common/application/Application.java similarity index 100% rename from src/main/java/org/tron/common/application/Application.java rename to framework/src/main/java/org/tron/common/application/Application.java diff --git a/src/main/java/org/tron/common/application/ApplicationFactory.java b/framework/src/main/java/org/tron/common/application/ApplicationFactory.java similarity index 100% rename from src/main/java/org/tron/common/application/ApplicationFactory.java rename to framework/src/main/java/org/tron/common/application/ApplicationFactory.java diff --git a/src/main/java/org/tron/common/application/ApplicationImpl.java b/framework/src/main/java/org/tron/common/application/ApplicationImpl.java similarity index 100% rename from src/main/java/org/tron/common/application/ApplicationImpl.java rename to framework/src/main/java/org/tron/common/application/ApplicationImpl.java diff --git a/src/main/java/org/tron/common/application/CliApplication.java b/framework/src/main/java/org/tron/common/application/CliApplication.java similarity index 100% rename from src/main/java/org/tron/common/application/CliApplication.java rename to framework/src/main/java/org/tron/common/application/CliApplication.java diff --git a/src/main/java/org/tron/common/application/Service.java b/framework/src/main/java/org/tron/common/application/Service.java similarity index 100% rename from src/main/java/org/tron/common/application/Service.java rename to framework/src/main/java/org/tron/common/application/Service.java diff --git a/src/main/java/org/tron/common/application/ServiceContainer.java b/framework/src/main/java/org/tron/common/application/ServiceContainer.java similarity index 100% rename from src/main/java/org/tron/common/application/ServiceContainer.java rename to framework/src/main/java/org/tron/common/application/ServiceContainer.java diff --git a/src/main/java/org/tron/common/application/TronApplicationContext.java b/framework/src/main/java/org/tron/common/application/TronApplicationContext.java similarity index 100% rename from src/main/java/org/tron/common/application/TronApplicationContext.java rename to framework/src/main/java/org/tron/common/application/TronApplicationContext.java diff --git a/src/main/java/org/tron/common/backup/BackupManager.java b/framework/src/main/java/org/tron/common/backup/BackupManager.java similarity index 100% rename from src/main/java/org/tron/common/backup/BackupManager.java rename to framework/src/main/java/org/tron/common/backup/BackupManager.java diff --git a/src/main/java/org/tron/common/backup/BackupServer.java b/framework/src/main/java/org/tron/common/backup/BackupServer.java similarity index 100% rename from src/main/java/org/tron/common/backup/BackupServer.java rename to framework/src/main/java/org/tron/common/backup/BackupServer.java diff --git a/src/main/java/org/tron/common/crypto/ECKey.java b/framework/src/main/java/org/tron/common/crypto/ECKey.java similarity index 100% rename from src/main/java/org/tron/common/crypto/ECKey.java rename to framework/src/main/java/org/tron/common/crypto/ECKey.java diff --git a/src/main/java/org/tron/common/crypto/Hash.java b/framework/src/main/java/org/tron/common/crypto/Hash.java similarity index 100% rename from src/main/java/org/tron/common/crypto/Hash.java rename to framework/src/main/java/org/tron/common/crypto/Hash.java diff --git a/src/main/java/org/tron/common/crypto/cryptohash/Digest.java b/framework/src/main/java/org/tron/common/crypto/cryptohash/Digest.java similarity index 100% rename from src/main/java/org/tron/common/crypto/cryptohash/Digest.java rename to framework/src/main/java/org/tron/common/crypto/cryptohash/Digest.java diff --git a/src/main/java/org/tron/common/crypto/cryptohash/DigestEngine.java b/framework/src/main/java/org/tron/common/crypto/cryptohash/DigestEngine.java similarity index 100% rename from src/main/java/org/tron/common/crypto/cryptohash/DigestEngine.java rename to framework/src/main/java/org/tron/common/crypto/cryptohash/DigestEngine.java diff --git a/src/main/java/org/tron/common/crypto/cryptohash/Keccak256.java b/framework/src/main/java/org/tron/common/crypto/cryptohash/Keccak256.java similarity index 100% rename from src/main/java/org/tron/common/crypto/cryptohash/Keccak256.java rename to framework/src/main/java/org/tron/common/crypto/cryptohash/Keccak256.java diff --git a/src/main/java/org/tron/common/crypto/cryptohash/Keccak512.java b/framework/src/main/java/org/tron/common/crypto/cryptohash/Keccak512.java similarity index 100% rename from src/main/java/org/tron/common/crypto/cryptohash/Keccak512.java rename to framework/src/main/java/org/tron/common/crypto/cryptohash/Keccak512.java diff --git a/src/main/java/org/tron/common/crypto/cryptohash/KeccakCore.java b/framework/src/main/java/org/tron/common/crypto/cryptohash/KeccakCore.java similarity index 100% rename from src/main/java/org/tron/common/crypto/cryptohash/KeccakCore.java rename to framework/src/main/java/org/tron/common/crypto/cryptohash/KeccakCore.java diff --git a/src/main/java/org/tron/common/crypto/jce/ECAlgorithmParameters.java b/framework/src/main/java/org/tron/common/crypto/jce/ECAlgorithmParameters.java similarity index 100% rename from src/main/java/org/tron/common/crypto/jce/ECAlgorithmParameters.java rename to framework/src/main/java/org/tron/common/crypto/jce/ECAlgorithmParameters.java diff --git a/src/main/java/org/tron/common/crypto/jce/ECKeyAgreement.java b/framework/src/main/java/org/tron/common/crypto/jce/ECKeyAgreement.java similarity index 100% rename from src/main/java/org/tron/common/crypto/jce/ECKeyAgreement.java rename to framework/src/main/java/org/tron/common/crypto/jce/ECKeyAgreement.java diff --git a/src/main/java/org/tron/common/crypto/jce/ECKeyFactory.java b/framework/src/main/java/org/tron/common/crypto/jce/ECKeyFactory.java similarity index 100% rename from src/main/java/org/tron/common/crypto/jce/ECKeyFactory.java rename to framework/src/main/java/org/tron/common/crypto/jce/ECKeyFactory.java diff --git a/src/main/java/org/tron/common/crypto/jce/ECKeyPairGenerator.java b/framework/src/main/java/org/tron/common/crypto/jce/ECKeyPairGenerator.java similarity index 100% rename from src/main/java/org/tron/common/crypto/jce/ECKeyPairGenerator.java rename to framework/src/main/java/org/tron/common/crypto/jce/ECKeyPairGenerator.java diff --git a/src/main/java/org/tron/common/crypto/jce/ECSignatureFactory.java b/framework/src/main/java/org/tron/common/crypto/jce/ECSignatureFactory.java similarity index 100% rename from src/main/java/org/tron/common/crypto/jce/ECSignatureFactory.java rename to framework/src/main/java/org/tron/common/crypto/jce/ECSignatureFactory.java diff --git a/src/main/java/org/tron/common/crypto/jce/TronCastleProvider.java b/framework/src/main/java/org/tron/common/crypto/jce/TronCastleProvider.java similarity index 100% rename from src/main/java/org/tron/common/crypto/jce/TronCastleProvider.java rename to framework/src/main/java/org/tron/common/crypto/jce/TronCastleProvider.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/BN128.java b/framework/src/main/java/org/tron/common/crypto/zksnark/BN128.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/BN128.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/BN128.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/BN128Fp.java b/framework/src/main/java/org/tron/common/crypto/zksnark/BN128Fp.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/BN128Fp.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/BN128Fp.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/BN128Fp2.java b/framework/src/main/java/org/tron/common/crypto/zksnark/BN128Fp2.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/BN128Fp2.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/BN128Fp2.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/BN128G1.java b/framework/src/main/java/org/tron/common/crypto/zksnark/BN128G1.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/BN128G1.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/BN128G1.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/BN128G2.java b/framework/src/main/java/org/tron/common/crypto/zksnark/BN128G2.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/BN128G2.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/BN128G2.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/Field.java b/framework/src/main/java/org/tron/common/crypto/zksnark/Field.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/Field.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/Field.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/Fp.java b/framework/src/main/java/org/tron/common/crypto/zksnark/Fp.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/Fp.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/Fp.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/Fp12.java b/framework/src/main/java/org/tron/common/crypto/zksnark/Fp12.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/Fp12.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/Fp12.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/Fp2.java b/framework/src/main/java/org/tron/common/crypto/zksnark/Fp2.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/Fp2.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/Fp2.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/Fp6.java b/framework/src/main/java/org/tron/common/crypto/zksnark/Fp6.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/Fp6.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/Fp6.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/PairingCheck.java b/framework/src/main/java/org/tron/common/crypto/zksnark/PairingCheck.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/PairingCheck.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/PairingCheck.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/Params.java b/framework/src/main/java/org/tron/common/crypto/zksnark/Params.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/Params.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/Params.java diff --git a/src/main/java/org/tron/common/crypto/zksnark/ZksnarkUtils.java b/framework/src/main/java/org/tron/common/crypto/zksnark/ZksnarkUtils.java similarity index 100% rename from src/main/java/org/tron/common/crypto/zksnark/ZksnarkUtils.java rename to framework/src/main/java/org/tron/common/crypto/zksnark/ZksnarkUtils.java diff --git a/src/main/java/org/tron/common/entity/NodeInfo.java b/framework/src/main/java/org/tron/common/entity/NodeInfo.java similarity index 100% rename from src/main/java/org/tron/common/entity/NodeInfo.java rename to framework/src/main/java/org/tron/common/entity/NodeInfo.java diff --git a/src/main/java/org/tron/common/entity/PeerInfo.java b/framework/src/main/java/org/tron/common/entity/PeerInfo.java similarity index 100% rename from src/main/java/org/tron/common/entity/PeerInfo.java rename to framework/src/main/java/org/tron/common/entity/PeerInfo.java diff --git a/src/main/java/org/tron/common/logsfilter/ContractEventParser.java b/framework/src/main/java/org/tron/common/logsfilter/ContractEventParser.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/ContractEventParser.java rename to framework/src/main/java/org/tron/common/logsfilter/ContractEventParser.java diff --git a/src/main/java/org/tron/common/logsfilter/ContractEventParserAbi.java b/framework/src/main/java/org/tron/common/logsfilter/ContractEventParserAbi.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/ContractEventParserAbi.java rename to framework/src/main/java/org/tron/common/logsfilter/ContractEventParserAbi.java diff --git a/src/main/java/org/tron/common/logsfilter/ContractEventParserJson.java b/framework/src/main/java/org/tron/common/logsfilter/ContractEventParserJson.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/ContractEventParserJson.java rename to framework/src/main/java/org/tron/common/logsfilter/ContractEventParserJson.java diff --git a/src/main/java/org/tron/common/logsfilter/EventPluginConfig.java b/framework/src/main/java/org/tron/common/logsfilter/EventPluginConfig.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/EventPluginConfig.java rename to framework/src/main/java/org/tron/common/logsfilter/EventPluginConfig.java diff --git a/src/main/java/org/tron/common/logsfilter/EventPluginLoader.java b/framework/src/main/java/org/tron/common/logsfilter/EventPluginLoader.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/EventPluginLoader.java rename to framework/src/main/java/org/tron/common/logsfilter/EventPluginLoader.java diff --git a/src/main/java/org/tron/common/logsfilter/FilterQuery.java b/framework/src/main/java/org/tron/common/logsfilter/FilterQuery.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/FilterQuery.java rename to framework/src/main/java/org/tron/common/logsfilter/FilterQuery.java diff --git a/src/main/java/org/tron/common/logsfilter/IPluginEventListener.java b/framework/src/main/java/org/tron/common/logsfilter/IPluginEventListener.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/IPluginEventListener.java rename to framework/src/main/java/org/tron/common/logsfilter/IPluginEventListener.java diff --git a/src/main/java/org/tron/common/logsfilter/TriggerConfig.java b/framework/src/main/java/org/tron/common/logsfilter/TriggerConfig.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/TriggerConfig.java rename to framework/src/main/java/org/tron/common/logsfilter/TriggerConfig.java diff --git a/src/main/java/org/tron/common/logsfilter/capsule/BlockLogTriggerCapsule.java b/framework/src/main/java/org/tron/common/logsfilter/capsule/BlockLogTriggerCapsule.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/capsule/BlockLogTriggerCapsule.java rename to framework/src/main/java/org/tron/common/logsfilter/capsule/BlockLogTriggerCapsule.java diff --git a/src/main/java/org/tron/common/logsfilter/capsule/ContractEventTriggerCapsule.java b/framework/src/main/java/org/tron/common/logsfilter/capsule/ContractEventTriggerCapsule.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/capsule/ContractEventTriggerCapsule.java rename to framework/src/main/java/org/tron/common/logsfilter/capsule/ContractEventTriggerCapsule.java diff --git a/src/main/java/org/tron/common/logsfilter/capsule/ContractLogTriggerCapsule.java b/framework/src/main/java/org/tron/common/logsfilter/capsule/ContractLogTriggerCapsule.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/capsule/ContractLogTriggerCapsule.java rename to framework/src/main/java/org/tron/common/logsfilter/capsule/ContractLogTriggerCapsule.java diff --git a/src/main/java/org/tron/common/logsfilter/capsule/ContractTriggerCapsule.java b/framework/src/main/java/org/tron/common/logsfilter/capsule/ContractTriggerCapsule.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/capsule/ContractTriggerCapsule.java rename to framework/src/main/java/org/tron/common/logsfilter/capsule/ContractTriggerCapsule.java diff --git a/src/main/java/org/tron/common/logsfilter/capsule/RawData.java b/framework/src/main/java/org/tron/common/logsfilter/capsule/RawData.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/capsule/RawData.java rename to framework/src/main/java/org/tron/common/logsfilter/capsule/RawData.java diff --git a/src/main/java/org/tron/common/logsfilter/capsule/TransactionLogTriggerCapsule.java b/framework/src/main/java/org/tron/common/logsfilter/capsule/TransactionLogTriggerCapsule.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/capsule/TransactionLogTriggerCapsule.java rename to framework/src/main/java/org/tron/common/logsfilter/capsule/TransactionLogTriggerCapsule.java diff --git a/src/main/java/org/tron/common/logsfilter/capsule/TriggerCapsule.java b/framework/src/main/java/org/tron/common/logsfilter/capsule/TriggerCapsule.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/capsule/TriggerCapsule.java rename to framework/src/main/java/org/tron/common/logsfilter/capsule/TriggerCapsule.java diff --git a/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java b/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java rename to framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java diff --git a/src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java b/framework/src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java rename to framework/src/main/java/org/tron/common/logsfilter/trigger/BlockLogTrigger.java diff --git a/src/main/java/org/tron/common/logsfilter/trigger/ContractEventTrigger.java b/framework/src/main/java/org/tron/common/logsfilter/trigger/ContractEventTrigger.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/trigger/ContractEventTrigger.java rename to framework/src/main/java/org/tron/common/logsfilter/trigger/ContractEventTrigger.java diff --git a/src/main/java/org/tron/common/logsfilter/trigger/ContractLogTrigger.java b/framework/src/main/java/org/tron/common/logsfilter/trigger/ContractLogTrigger.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/trigger/ContractLogTrigger.java rename to framework/src/main/java/org/tron/common/logsfilter/trigger/ContractLogTrigger.java diff --git a/src/main/java/org/tron/common/logsfilter/trigger/ContractTrigger.java b/framework/src/main/java/org/tron/common/logsfilter/trigger/ContractTrigger.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/trigger/ContractTrigger.java rename to framework/src/main/java/org/tron/common/logsfilter/trigger/ContractTrigger.java diff --git a/src/main/java/org/tron/common/logsfilter/trigger/InternalTransactionPojo.java b/framework/src/main/java/org/tron/common/logsfilter/trigger/InternalTransactionPojo.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/trigger/InternalTransactionPojo.java rename to framework/src/main/java/org/tron/common/logsfilter/trigger/InternalTransactionPojo.java diff --git a/src/main/java/org/tron/common/logsfilter/trigger/TransactionLogTrigger.java b/framework/src/main/java/org/tron/common/logsfilter/trigger/TransactionLogTrigger.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/trigger/TransactionLogTrigger.java rename to framework/src/main/java/org/tron/common/logsfilter/trigger/TransactionLogTrigger.java diff --git a/src/main/java/org/tron/common/logsfilter/trigger/Trigger.java b/framework/src/main/java/org/tron/common/logsfilter/trigger/Trigger.java similarity index 100% rename from src/main/java/org/tron/common/logsfilter/trigger/Trigger.java rename to framework/src/main/java/org/tron/common/logsfilter/trigger/Trigger.java diff --git a/src/main/java/org/tron/common/net/udp/handler/EventHandler.java b/framework/src/main/java/org/tron/common/net/udp/handler/EventHandler.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/handler/EventHandler.java rename to framework/src/main/java/org/tron/common/net/udp/handler/EventHandler.java diff --git a/src/main/java/org/tron/common/net/udp/handler/MessageHandler.java b/framework/src/main/java/org/tron/common/net/udp/handler/MessageHandler.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/handler/MessageHandler.java rename to framework/src/main/java/org/tron/common/net/udp/handler/MessageHandler.java diff --git a/src/main/java/org/tron/common/net/udp/handler/PacketDecoder.java b/framework/src/main/java/org/tron/common/net/udp/handler/PacketDecoder.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/handler/PacketDecoder.java rename to framework/src/main/java/org/tron/common/net/udp/handler/PacketDecoder.java diff --git a/src/main/java/org/tron/common/net/udp/handler/UdpEvent.java b/framework/src/main/java/org/tron/common/net/udp/handler/UdpEvent.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/handler/UdpEvent.java rename to framework/src/main/java/org/tron/common/net/udp/handler/UdpEvent.java diff --git a/src/main/java/org/tron/common/net/udp/message/Message.java b/framework/src/main/java/org/tron/common/net/udp/message/Message.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/message/Message.java rename to framework/src/main/java/org/tron/common/net/udp/message/Message.java diff --git a/src/main/java/org/tron/common/net/udp/message/UdpMessageTypeEnum.java b/framework/src/main/java/org/tron/common/net/udp/message/UdpMessageTypeEnum.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/message/UdpMessageTypeEnum.java rename to framework/src/main/java/org/tron/common/net/udp/message/UdpMessageTypeEnum.java diff --git a/src/main/java/org/tron/common/net/udp/message/backup/KeepAliveMessage.java b/framework/src/main/java/org/tron/common/net/udp/message/backup/KeepAliveMessage.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/message/backup/KeepAliveMessage.java rename to framework/src/main/java/org/tron/common/net/udp/message/backup/KeepAliveMessage.java diff --git a/src/main/java/org/tron/common/net/udp/message/discover/FindNodeMessage.java b/framework/src/main/java/org/tron/common/net/udp/message/discover/FindNodeMessage.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/message/discover/FindNodeMessage.java rename to framework/src/main/java/org/tron/common/net/udp/message/discover/FindNodeMessage.java diff --git a/src/main/java/org/tron/common/net/udp/message/discover/NeighborsMessage.java b/framework/src/main/java/org/tron/common/net/udp/message/discover/NeighborsMessage.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/message/discover/NeighborsMessage.java rename to framework/src/main/java/org/tron/common/net/udp/message/discover/NeighborsMessage.java diff --git a/src/main/java/org/tron/common/net/udp/message/discover/PingMessage.java b/framework/src/main/java/org/tron/common/net/udp/message/discover/PingMessage.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/message/discover/PingMessage.java rename to framework/src/main/java/org/tron/common/net/udp/message/discover/PingMessage.java diff --git a/src/main/java/org/tron/common/net/udp/message/discover/PongMessage.java b/framework/src/main/java/org/tron/common/net/udp/message/discover/PongMessage.java similarity index 100% rename from src/main/java/org/tron/common/net/udp/message/discover/PongMessage.java rename to framework/src/main/java/org/tron/common/net/udp/message/discover/PongMessage.java diff --git a/src/main/java/org/tron/common/overlay/client/PeerClient.java b/framework/src/main/java/org/tron/common/overlay/client/PeerClient.java similarity index 100% rename from src/main/java/org/tron/common/overlay/client/PeerClient.java rename to framework/src/main/java/org/tron/common/overlay/client/PeerClient.java diff --git a/src/main/java/org/tron/common/overlay/client/WalletGrpcClient.java b/framework/src/main/java/org/tron/common/overlay/client/WalletGrpcClient.java similarity index 100% rename from src/main/java/org/tron/common/overlay/client/WalletGrpcClient.java rename to framework/src/main/java/org/tron/common/overlay/client/WalletGrpcClient.java diff --git a/src/main/java/org/tron/common/overlay/discover/DiscoverListener.java b/framework/src/main/java/org/tron/common/overlay/discover/DiscoverListener.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/DiscoverListener.java rename to framework/src/main/java/org/tron/common/overlay/discover/DiscoverListener.java diff --git a/src/main/java/org/tron/common/overlay/discover/DiscoverServer.java b/framework/src/main/java/org/tron/common/overlay/discover/DiscoverServer.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/DiscoverServer.java rename to framework/src/main/java/org/tron/common/overlay/discover/DiscoverServer.java diff --git a/src/main/java/org/tron/common/overlay/discover/DiscoverTask.java b/framework/src/main/java/org/tron/common/overlay/discover/DiscoverTask.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/DiscoverTask.java rename to framework/src/main/java/org/tron/common/overlay/discover/DiscoverTask.java diff --git a/src/main/java/org/tron/common/overlay/discover/DiscoveryExecutor.java b/framework/src/main/java/org/tron/common/overlay/discover/DiscoveryExecutor.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/DiscoveryExecutor.java rename to framework/src/main/java/org/tron/common/overlay/discover/DiscoveryExecutor.java diff --git a/src/main/java/org/tron/common/overlay/discover/RefreshTask.java b/framework/src/main/java/org/tron/common/overlay/discover/RefreshTask.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/RefreshTask.java rename to framework/src/main/java/org/tron/common/overlay/discover/RefreshTask.java diff --git a/src/main/java/org/tron/common/overlay/discover/dht/Bucket.java b/framework/src/main/java/org/tron/common/overlay/discover/dht/Bucket.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/dht/Bucket.java rename to framework/src/main/java/org/tron/common/overlay/discover/dht/Bucket.java diff --git a/src/main/java/org/tron/common/overlay/discover/dht/DHTUtils.java b/framework/src/main/java/org/tron/common/overlay/discover/dht/DHTUtils.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/dht/DHTUtils.java rename to framework/src/main/java/org/tron/common/overlay/discover/dht/DHTUtils.java diff --git a/src/main/java/org/tron/common/overlay/discover/dht/Peer.java b/framework/src/main/java/org/tron/common/overlay/discover/dht/Peer.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/dht/Peer.java rename to framework/src/main/java/org/tron/common/overlay/discover/dht/Peer.java diff --git a/src/main/java/org/tron/common/overlay/discover/node/Node.java b/framework/src/main/java/org/tron/common/overlay/discover/node/Node.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/node/Node.java rename to framework/src/main/java/org/tron/common/overlay/discover/node/Node.java diff --git a/src/main/java/org/tron/common/overlay/discover/node/NodeHandler.java b/framework/src/main/java/org/tron/common/overlay/discover/node/NodeHandler.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/node/NodeHandler.java rename to framework/src/main/java/org/tron/common/overlay/discover/node/NodeHandler.java diff --git a/src/main/java/org/tron/common/overlay/discover/node/NodeManager.java b/framework/src/main/java/org/tron/common/overlay/discover/node/NodeManager.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/node/NodeManager.java rename to framework/src/main/java/org/tron/common/overlay/discover/node/NodeManager.java diff --git a/src/main/java/org/tron/common/overlay/discover/node/statistics/MessageCount.java b/framework/src/main/java/org/tron/common/overlay/discover/node/statistics/MessageCount.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/node/statistics/MessageCount.java rename to framework/src/main/java/org/tron/common/overlay/discover/node/statistics/MessageCount.java diff --git a/src/main/java/org/tron/common/overlay/discover/node/statistics/MessageStatistics.java b/framework/src/main/java/org/tron/common/overlay/discover/node/statistics/MessageStatistics.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/node/statistics/MessageStatistics.java rename to framework/src/main/java/org/tron/common/overlay/discover/node/statistics/MessageStatistics.java diff --git a/src/main/java/org/tron/common/overlay/discover/node/statistics/NodeStatistics.java b/framework/src/main/java/org/tron/common/overlay/discover/node/statistics/NodeStatistics.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/node/statistics/NodeStatistics.java rename to framework/src/main/java/org/tron/common/overlay/discover/node/statistics/NodeStatistics.java diff --git a/src/main/java/org/tron/common/overlay/discover/node/statistics/Reputation.java b/framework/src/main/java/org/tron/common/overlay/discover/node/statistics/Reputation.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/node/statistics/Reputation.java rename to framework/src/main/java/org/tron/common/overlay/discover/node/statistics/Reputation.java diff --git a/src/main/java/org/tron/common/overlay/discover/table/DistanceComparator.java b/framework/src/main/java/org/tron/common/overlay/discover/table/DistanceComparator.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/table/DistanceComparator.java rename to framework/src/main/java/org/tron/common/overlay/discover/table/DistanceComparator.java diff --git a/src/main/java/org/tron/common/overlay/discover/table/KademliaOptions.java b/framework/src/main/java/org/tron/common/overlay/discover/table/KademliaOptions.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/table/KademliaOptions.java rename to framework/src/main/java/org/tron/common/overlay/discover/table/KademliaOptions.java diff --git a/src/main/java/org/tron/common/overlay/discover/table/NodeBucket.java b/framework/src/main/java/org/tron/common/overlay/discover/table/NodeBucket.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/table/NodeBucket.java rename to framework/src/main/java/org/tron/common/overlay/discover/table/NodeBucket.java diff --git a/src/main/java/org/tron/common/overlay/discover/table/NodeEntry.java b/framework/src/main/java/org/tron/common/overlay/discover/table/NodeEntry.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/table/NodeEntry.java rename to framework/src/main/java/org/tron/common/overlay/discover/table/NodeEntry.java diff --git a/src/main/java/org/tron/common/overlay/discover/table/NodeTable.java b/framework/src/main/java/org/tron/common/overlay/discover/table/NodeTable.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/table/NodeTable.java rename to framework/src/main/java/org/tron/common/overlay/discover/table/NodeTable.java diff --git a/src/main/java/org/tron/common/overlay/discover/table/TimeComparator.java b/framework/src/main/java/org/tron/common/overlay/discover/table/TimeComparator.java similarity index 100% rename from src/main/java/org/tron/common/overlay/discover/table/TimeComparator.java rename to framework/src/main/java/org/tron/common/overlay/discover/table/TimeComparator.java diff --git a/src/main/java/org/tron/common/overlay/message/DisconnectMessage.java b/framework/src/main/java/org/tron/common/overlay/message/DisconnectMessage.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/DisconnectMessage.java rename to framework/src/main/java/org/tron/common/overlay/message/DisconnectMessage.java diff --git a/src/main/java/org/tron/common/overlay/message/HelloMessage.java b/framework/src/main/java/org/tron/common/overlay/message/HelloMessage.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/HelloMessage.java rename to framework/src/main/java/org/tron/common/overlay/message/HelloMessage.java diff --git a/src/main/java/org/tron/common/overlay/message/Message.java b/framework/src/main/java/org/tron/common/overlay/message/Message.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/Message.java rename to framework/src/main/java/org/tron/common/overlay/message/Message.java diff --git a/src/main/java/org/tron/common/overlay/message/MessageCodec.java b/framework/src/main/java/org/tron/common/overlay/message/MessageCodec.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/MessageCodec.java rename to framework/src/main/java/org/tron/common/overlay/message/MessageCodec.java diff --git a/src/main/java/org/tron/common/overlay/message/MessageFactory.java b/framework/src/main/java/org/tron/common/overlay/message/MessageFactory.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/MessageFactory.java rename to framework/src/main/java/org/tron/common/overlay/message/MessageFactory.java diff --git a/src/main/java/org/tron/common/overlay/message/P2pMessage.java b/framework/src/main/java/org/tron/common/overlay/message/P2pMessage.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/P2pMessage.java rename to framework/src/main/java/org/tron/common/overlay/message/P2pMessage.java diff --git a/src/main/java/org/tron/common/overlay/message/P2pMessageFactory.java b/framework/src/main/java/org/tron/common/overlay/message/P2pMessageFactory.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/P2pMessageFactory.java rename to framework/src/main/java/org/tron/common/overlay/message/P2pMessageFactory.java diff --git a/src/main/java/org/tron/common/overlay/message/PingMessage.java b/framework/src/main/java/org/tron/common/overlay/message/PingMessage.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/PingMessage.java rename to framework/src/main/java/org/tron/common/overlay/message/PingMessage.java diff --git a/src/main/java/org/tron/common/overlay/message/PongMessage.java b/framework/src/main/java/org/tron/common/overlay/message/PongMessage.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/PongMessage.java rename to framework/src/main/java/org/tron/common/overlay/message/PongMessage.java diff --git a/src/main/java/org/tron/common/overlay/message/StaticMessages.java b/framework/src/main/java/org/tron/common/overlay/message/StaticMessages.java similarity index 100% rename from src/main/java/org/tron/common/overlay/message/StaticMessages.java rename to framework/src/main/java/org/tron/common/overlay/message/StaticMessages.java diff --git a/src/main/java/org/tron/common/overlay/server/Channel.java b/framework/src/main/java/org/tron/common/overlay/server/Channel.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/Channel.java rename to framework/src/main/java/org/tron/common/overlay/server/Channel.java diff --git a/src/main/java/org/tron/common/overlay/server/ChannelManager.java b/framework/src/main/java/org/tron/common/overlay/server/ChannelManager.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/ChannelManager.java rename to framework/src/main/java/org/tron/common/overlay/server/ChannelManager.java diff --git a/src/main/java/org/tron/common/overlay/server/FastForward.java b/framework/src/main/java/org/tron/common/overlay/server/FastForward.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/FastForward.java rename to framework/src/main/java/org/tron/common/overlay/server/FastForward.java diff --git a/src/main/java/org/tron/common/overlay/server/HandshakeHandler.java b/framework/src/main/java/org/tron/common/overlay/server/HandshakeHandler.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/HandshakeHandler.java rename to framework/src/main/java/org/tron/common/overlay/server/HandshakeHandler.java diff --git a/src/main/java/org/tron/common/overlay/server/MessageQueue.java b/framework/src/main/java/org/tron/common/overlay/server/MessageQueue.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/MessageQueue.java rename to framework/src/main/java/org/tron/common/overlay/server/MessageQueue.java diff --git a/src/main/java/org/tron/common/overlay/server/MessageRoundtrip.java b/framework/src/main/java/org/tron/common/overlay/server/MessageRoundtrip.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/MessageRoundtrip.java rename to framework/src/main/java/org/tron/common/overlay/server/MessageRoundtrip.java diff --git a/src/main/java/org/tron/common/overlay/server/P2pHandler.java b/framework/src/main/java/org/tron/common/overlay/server/P2pHandler.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/P2pHandler.java rename to framework/src/main/java/org/tron/common/overlay/server/P2pHandler.java diff --git a/src/main/java/org/tron/common/overlay/server/PeerConnectionCheckService.java b/framework/src/main/java/org/tron/common/overlay/server/PeerConnectionCheckService.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/PeerConnectionCheckService.java rename to framework/src/main/java/org/tron/common/overlay/server/PeerConnectionCheckService.java diff --git a/src/main/java/org/tron/common/overlay/server/PeerServer.java b/framework/src/main/java/org/tron/common/overlay/server/PeerServer.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/PeerServer.java rename to framework/src/main/java/org/tron/common/overlay/server/PeerServer.java diff --git a/src/main/java/org/tron/common/overlay/server/SyncPool.java b/framework/src/main/java/org/tron/common/overlay/server/SyncPool.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/SyncPool.java rename to framework/src/main/java/org/tron/common/overlay/server/SyncPool.java diff --git a/src/main/java/org/tron/common/overlay/server/TronChannelInitializer.java b/framework/src/main/java/org/tron/common/overlay/server/TronChannelInitializer.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/TronChannelInitializer.java rename to framework/src/main/java/org/tron/common/overlay/server/TronChannelInitializer.java diff --git a/src/main/java/org/tron/common/overlay/server/TrxProtobufVarint32FrameDecoder.java b/framework/src/main/java/org/tron/common/overlay/server/TrxProtobufVarint32FrameDecoder.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/TrxProtobufVarint32FrameDecoder.java rename to framework/src/main/java/org/tron/common/overlay/server/TrxProtobufVarint32FrameDecoder.java diff --git a/src/main/java/org/tron/common/overlay/server/WireTrafficStats.java b/framework/src/main/java/org/tron/common/overlay/server/WireTrafficStats.java similarity index 100% rename from src/main/java/org/tron/common/overlay/server/WireTrafficStats.java rename to framework/src/main/java/org/tron/common/overlay/server/WireTrafficStats.java diff --git a/src/main/java/org/tron/common/runtime/Runtime.java b/framework/src/main/java/org/tron/common/runtime/Runtime.java similarity index 100% rename from src/main/java/org/tron/common/runtime/Runtime.java rename to framework/src/main/java/org/tron/common/runtime/Runtime.java diff --git a/src/main/java/org/tron/common/runtime/RuntimeImpl.java b/framework/src/main/java/org/tron/common/runtime/RuntimeImpl.java similarity index 100% rename from src/main/java/org/tron/common/runtime/RuntimeImpl.java rename to framework/src/main/java/org/tron/common/runtime/RuntimeImpl.java diff --git a/src/main/java/org/tron/common/runtime/config/VMConfig.java b/framework/src/main/java/org/tron/common/runtime/config/VMConfig.java similarity index 100% rename from src/main/java/org/tron/common/runtime/config/VMConfig.java rename to framework/src/main/java/org/tron/common/runtime/config/VMConfig.java diff --git a/src/main/java/org/tron/common/runtime/utils/MUtil.java b/framework/src/main/java/org/tron/common/runtime/utils/MUtil.java similarity index 100% rename from src/main/java/org/tron/common/runtime/utils/MUtil.java rename to framework/src/main/java/org/tron/common/runtime/utils/MUtil.java diff --git a/src/main/java/org/tron/common/runtime/vm/CallCreate.java b/framework/src/main/java/org/tron/common/runtime/vm/CallCreate.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/CallCreate.java rename to framework/src/main/java/org/tron/common/runtime/vm/CallCreate.java diff --git a/src/main/java/org/tron/common/runtime/vm/DataWord.java b/framework/src/main/java/org/tron/common/runtime/vm/DataWord.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/DataWord.java rename to framework/src/main/java/org/tron/common/runtime/vm/DataWord.java diff --git a/src/main/java/org/tron/common/runtime/vm/EnergyCost.java b/framework/src/main/java/org/tron/common/runtime/vm/EnergyCost.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/EnergyCost.java rename to framework/src/main/java/org/tron/common/runtime/vm/EnergyCost.java diff --git a/src/main/java/org/tron/common/runtime/vm/LogEventWrapper.java b/framework/src/main/java/org/tron/common/runtime/vm/LogEventWrapper.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/LogEventWrapper.java rename to framework/src/main/java/org/tron/common/runtime/vm/LogEventWrapper.java diff --git a/src/main/java/org/tron/common/runtime/vm/LogInfo.java b/framework/src/main/java/org/tron/common/runtime/vm/LogInfo.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/LogInfo.java rename to framework/src/main/java/org/tron/common/runtime/vm/LogInfo.java diff --git a/src/main/java/org/tron/common/runtime/vm/LogInfoTriggerParser.java b/framework/src/main/java/org/tron/common/runtime/vm/LogInfoTriggerParser.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/LogInfoTriggerParser.java rename to framework/src/main/java/org/tron/common/runtime/vm/LogInfoTriggerParser.java diff --git a/src/main/java/org/tron/common/runtime/vm/MessageCall.java b/framework/src/main/java/org/tron/common/runtime/vm/MessageCall.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/MessageCall.java rename to framework/src/main/java/org/tron/common/runtime/vm/MessageCall.java diff --git a/src/main/java/org/tron/common/runtime/vm/OpCode.java b/framework/src/main/java/org/tron/common/runtime/vm/OpCode.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/OpCode.java rename to framework/src/main/java/org/tron/common/runtime/vm/OpCode.java diff --git a/src/main/java/org/tron/common/runtime/vm/PrecompiledContracts.java b/framework/src/main/java/org/tron/common/runtime/vm/PrecompiledContracts.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/PrecompiledContracts.java rename to framework/src/main/java/org/tron/common/runtime/vm/PrecompiledContracts.java diff --git a/src/main/java/org/tron/common/runtime/vm/VM.java b/framework/src/main/java/org/tron/common/runtime/vm/VM.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/VM.java rename to framework/src/main/java/org/tron/common/runtime/vm/VM.java diff --git a/src/main/java/org/tron/common/runtime/vm/VMConstant.java b/framework/src/main/java/org/tron/common/runtime/vm/VMConstant.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/VMConstant.java rename to framework/src/main/java/org/tron/common/runtime/vm/VMConstant.java diff --git a/src/main/java/org/tron/common/runtime/vm/VMUtils.java b/framework/src/main/java/org/tron/common/runtime/vm/VMUtils.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/VMUtils.java rename to framework/src/main/java/org/tron/common/runtime/vm/VMUtils.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/ContractState.java b/framework/src/main/java/org/tron/common/runtime/vm/program/ContractState.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/ContractState.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/ContractState.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/InternalTransaction.java b/framework/src/main/java/org/tron/common/runtime/vm/program/InternalTransaction.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/InternalTransaction.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/InternalTransaction.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/Memory.java b/framework/src/main/java/org/tron/common/runtime/vm/program/Memory.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/Memory.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/Memory.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/Program.java b/framework/src/main/java/org/tron/common/runtime/vm/program/Program.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/Program.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/Program.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/ProgramPrecompile.java b/framework/src/main/java/org/tron/common/runtime/vm/program/ProgramPrecompile.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/ProgramPrecompile.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/ProgramPrecompile.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/ProgramResult.java b/framework/src/main/java/org/tron/common/runtime/vm/program/ProgramResult.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/ProgramResult.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/ProgramResult.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/Stack.java b/framework/src/main/java/org/tron/common/runtime/vm/program/Stack.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/Stack.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/Stack.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/Storage.java b/framework/src/main/java/org/tron/common/runtime/vm/program/Storage.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/Storage.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/Storage.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvoke.java b/framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvoke.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvoke.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvoke.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactory.java b/framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactory.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactory.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactory.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactoryImpl.java b/framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactoryImpl.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactoryImpl.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeFactoryImpl.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeImpl.java b/framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeImpl.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeImpl.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeImpl.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeMockImpl.java b/framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeMockImpl.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeMockImpl.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeMockImpl.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/listener/CompositeProgramListener.java b/framework/src/main/java/org/tron/common/runtime/vm/program/listener/CompositeProgramListener.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/listener/CompositeProgramListener.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/listener/CompositeProgramListener.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListener.java b/framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListener.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListener.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListener.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAdaptor.java b/framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAdaptor.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAdaptor.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAdaptor.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAware.java b/framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAware.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAware.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramListenerAware.java diff --git a/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramStorageChangeListener.java b/framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramStorageChangeListener.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/program/listener/ProgramStorageChangeListener.java rename to framework/src/main/java/org/tron/common/runtime/vm/program/listener/ProgramStorageChangeListener.java diff --git a/src/main/java/org/tron/common/runtime/vm/trace/Op.java b/framework/src/main/java/org/tron/common/runtime/vm/trace/Op.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/trace/Op.java rename to framework/src/main/java/org/tron/common/runtime/vm/trace/Op.java diff --git a/src/main/java/org/tron/common/runtime/vm/trace/OpActions.java b/framework/src/main/java/org/tron/common/runtime/vm/trace/OpActions.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/trace/OpActions.java rename to framework/src/main/java/org/tron/common/runtime/vm/trace/OpActions.java diff --git a/src/main/java/org/tron/common/runtime/vm/trace/ProgramTrace.java b/framework/src/main/java/org/tron/common/runtime/vm/trace/ProgramTrace.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/trace/ProgramTrace.java rename to framework/src/main/java/org/tron/common/runtime/vm/trace/ProgramTrace.java diff --git a/src/main/java/org/tron/common/runtime/vm/trace/ProgramTraceListener.java b/framework/src/main/java/org/tron/common/runtime/vm/trace/ProgramTraceListener.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/trace/ProgramTraceListener.java rename to framework/src/main/java/org/tron/common/runtime/vm/trace/ProgramTraceListener.java diff --git a/src/main/java/org/tron/common/runtime/vm/trace/Serializers.java b/framework/src/main/java/org/tron/common/runtime/vm/trace/Serializers.java similarity index 100% rename from src/main/java/org/tron/common/runtime/vm/trace/Serializers.java rename to framework/src/main/java/org/tron/common/runtime/vm/trace/Serializers.java diff --git a/src/main/java/org/tron/common/storage/Deposit.java b/framework/src/main/java/org/tron/common/storage/Deposit.java similarity index 100% rename from src/main/java/org/tron/common/storage/Deposit.java rename to framework/src/main/java/org/tron/common/storage/Deposit.java diff --git a/src/main/java/org/tron/common/storage/DepositImpl.java b/framework/src/main/java/org/tron/common/storage/DepositImpl.java similarity index 100% rename from src/main/java/org/tron/common/storage/DepositImpl.java rename to framework/src/main/java/org/tron/common/storage/DepositImpl.java diff --git a/src/main/java/org/tron/common/storage/Key.java b/framework/src/main/java/org/tron/common/storage/Key.java similarity index 100% rename from src/main/java/org/tron/common/storage/Key.java rename to framework/src/main/java/org/tron/common/storage/Key.java diff --git a/src/main/java/org/tron/common/storage/Type.java b/framework/src/main/java/org/tron/common/storage/Type.java similarity index 100% rename from src/main/java/org/tron/common/storage/Type.java rename to framework/src/main/java/org/tron/common/storage/Type.java diff --git a/src/main/java/org/tron/common/storage/Value.java b/framework/src/main/java/org/tron/common/storage/Value.java similarity index 100% rename from src/main/java/org/tron/common/storage/Value.java rename to framework/src/main/java/org/tron/common/storage/Value.java diff --git a/src/main/java/org/tron/common/storage/WriteOptionsWrapper.java b/framework/src/main/java/org/tron/common/storage/WriteOptionsWrapper.java similarity index 100% rename from src/main/java/org/tron/common/storage/WriteOptionsWrapper.java rename to framework/src/main/java/org/tron/common/storage/WriteOptionsWrapper.java diff --git a/src/main/java/org/tron/common/utils/ALock.java b/framework/src/main/java/org/tron/common/utils/ALock.java similarity index 100% rename from src/main/java/org/tron/common/utils/ALock.java rename to framework/src/main/java/org/tron/common/utils/ALock.java diff --git a/src/main/java/org/tron/common/utils/BIUtil.java b/framework/src/main/java/org/tron/common/utils/BIUtil.java similarity index 100% rename from src/main/java/org/tron/common/utils/BIUtil.java rename to framework/src/main/java/org/tron/common/utils/BIUtil.java diff --git a/src/main/java/org/tron/common/utils/Base58.java b/framework/src/main/java/org/tron/common/utils/Base58.java similarity index 100% rename from src/main/java/org/tron/common/utils/Base58.java rename to framework/src/main/java/org/tron/common/utils/Base58.java diff --git a/src/main/java/org/tron/common/utils/Bech32.java b/framework/src/main/java/org/tron/common/utils/Bech32.java similarity index 100% rename from src/main/java/org/tron/common/utils/Bech32.java rename to framework/src/main/java/org/tron/common/utils/Bech32.java diff --git a/src/main/java/org/tron/common/utils/ByteArrayMap.java b/framework/src/main/java/org/tron/common/utils/ByteArrayMap.java similarity index 100% rename from src/main/java/org/tron/common/utils/ByteArrayMap.java rename to framework/src/main/java/org/tron/common/utils/ByteArrayMap.java diff --git a/src/main/java/org/tron/common/utils/ByteArraySet.java b/framework/src/main/java/org/tron/common/utils/ByteArraySet.java similarity index 100% rename from src/main/java/org/tron/common/utils/ByteArraySet.java rename to framework/src/main/java/org/tron/common/utils/ByteArraySet.java diff --git a/src/main/java/org/tron/common/utils/ByteUtil.java b/framework/src/main/java/org/tron/common/utils/ByteUtil.java similarity index 100% rename from src/main/java/org/tron/common/utils/ByteUtil.java rename to framework/src/main/java/org/tron/common/utils/ByteUtil.java diff --git a/src/main/java/org/tron/common/utils/CollectionUtils.java b/framework/src/main/java/org/tron/common/utils/CollectionUtils.java similarity index 100% rename from src/main/java/org/tron/common/utils/CollectionUtils.java rename to framework/src/main/java/org/tron/common/utils/CollectionUtils.java diff --git a/src/main/java/org/tron/common/utils/CompactEncoder.java b/framework/src/main/java/org/tron/common/utils/CompactEncoder.java similarity index 100% rename from src/main/java/org/tron/common/utils/CompactEncoder.java rename to framework/src/main/java/org/tron/common/utils/CompactEncoder.java diff --git a/src/main/java/org/tron/common/utils/DecodeResult.java b/framework/src/main/java/org/tron/common/utils/DecodeResult.java similarity index 100% rename from src/main/java/org/tron/common/utils/DecodeResult.java rename to framework/src/main/java/org/tron/common/utils/DecodeResult.java diff --git a/src/main/java/org/tron/common/utils/FastByteComparisons.java b/framework/src/main/java/org/tron/common/utils/FastByteComparisons.java similarity index 100% rename from src/main/java/org/tron/common/utils/FastByteComparisons.java rename to framework/src/main/java/org/tron/common/utils/FastByteComparisons.java diff --git a/src/main/java/org/tron/common/utils/FileUtil.java b/framework/src/main/java/org/tron/common/utils/FileUtil.java similarity index 100% rename from src/main/java/org/tron/common/utils/FileUtil.java rename to framework/src/main/java/org/tron/common/utils/FileUtil.java diff --git a/src/main/java/org/tron/common/utils/ForkController.java b/framework/src/main/java/org/tron/common/utils/ForkController.java similarity index 100% rename from src/main/java/org/tron/common/utils/ForkController.java rename to framework/src/main/java/org/tron/common/utils/ForkController.java diff --git a/src/main/java/org/tron/common/utils/PropUtil.java b/framework/src/main/java/org/tron/common/utils/PropUtil.java similarity index 100% rename from src/main/java/org/tron/common/utils/PropUtil.java rename to framework/src/main/java/org/tron/common/utils/PropUtil.java diff --git a/src/main/java/org/tron/common/utils/RandomGenerator.java b/framework/src/main/java/org/tron/common/utils/RandomGenerator.java similarity index 100% rename from src/main/java/org/tron/common/utils/RandomGenerator.java rename to framework/src/main/java/org/tron/common/utils/RandomGenerator.java diff --git a/src/main/java/org/tron/common/utils/SafeMessageMap.java b/framework/src/main/java/org/tron/common/utils/SafeMessageMap.java similarity index 100% rename from src/main/java/org/tron/common/utils/SafeMessageMap.java rename to framework/src/main/java/org/tron/common/utils/SafeMessageMap.java diff --git a/src/main/java/org/tron/common/utils/SessionOptional.java b/framework/src/main/java/org/tron/common/utils/SessionOptional.java similarity index 100% rename from src/main/java/org/tron/common/utils/SessionOptional.java rename to framework/src/main/java/org/tron/common/utils/SessionOptional.java diff --git a/src/main/java/org/tron/common/utils/SetAdapter.java b/framework/src/main/java/org/tron/common/utils/SetAdapter.java similarity index 100% rename from src/main/java/org/tron/common/utils/SetAdapter.java rename to framework/src/main/java/org/tron/common/utils/SetAdapter.java diff --git a/src/main/java/org/tron/common/utils/SlidingWindowCounter.java b/framework/src/main/java/org/tron/common/utils/SlidingWindowCounter.java similarity index 100% rename from src/main/java/org/tron/common/utils/SlidingWindowCounter.java rename to framework/src/main/java/org/tron/common/utils/SlidingWindowCounter.java diff --git a/src/main/java/org/tron/common/utils/StringUtil.java b/framework/src/main/java/org/tron/common/utils/StringUtil.java similarity index 100% rename from src/main/java/org/tron/common/utils/StringUtil.java rename to framework/src/main/java/org/tron/common/utils/StringUtil.java diff --git a/src/main/java/org/tron/common/utils/Time.java b/framework/src/main/java/org/tron/common/utils/Time.java similarity index 100% rename from src/main/java/org/tron/common/utils/Time.java rename to framework/src/main/java/org/tron/common/utils/Time.java diff --git a/src/main/java/org/tron/common/utils/TypeConversion.java b/framework/src/main/java/org/tron/common/utils/TypeConversion.java similarity index 100% rename from src/main/java/org/tron/common/utils/TypeConversion.java rename to framework/src/main/java/org/tron/common/utils/TypeConversion.java diff --git a/src/main/java/org/tron/common/utils/Utils.java b/framework/src/main/java/org/tron/common/utils/Utils.java similarity index 100% rename from src/main/java/org/tron/common/utils/Utils.java rename to framework/src/main/java/org/tron/common/utils/Utils.java diff --git a/src/main/java/org/tron/common/utils/Value.java b/framework/src/main/java/org/tron/common/utils/Value.java similarity index 100% rename from src/main/java/org/tron/common/utils/Value.java rename to framework/src/main/java/org/tron/common/utils/Value.java diff --git a/src/main/java/org/tron/common/zksnark/JLibrustzcash.java b/framework/src/main/java/org/tron/common/zksnark/JLibrustzcash.java similarity index 100% rename from src/main/java/org/tron/common/zksnark/JLibrustzcash.java rename to framework/src/main/java/org/tron/common/zksnark/JLibrustzcash.java diff --git a/src/main/java/org/tron/common/zksnark/JLibsodium.java b/framework/src/main/java/org/tron/common/zksnark/JLibsodium.java similarity index 100% rename from src/main/java/org/tron/common/zksnark/JLibsodium.java rename to framework/src/main/java/org/tron/common/zksnark/JLibsodium.java diff --git a/src/main/java/org/tron/common/zksnark/LibrustzcashParam.java b/framework/src/main/java/org/tron/common/zksnark/LibrustzcashParam.java similarity index 100% rename from src/main/java/org/tron/common/zksnark/LibrustzcashParam.java rename to framework/src/main/java/org/tron/common/zksnark/LibrustzcashParam.java diff --git a/src/main/java/org/tron/common/zksnark/ZksnarkClient.java b/framework/src/main/java/org/tron/common/zksnark/ZksnarkClient.java similarity index 100% rename from src/main/java/org/tron/common/zksnark/ZksnarkClient.java rename to framework/src/main/java/org/tron/common/zksnark/ZksnarkClient.java diff --git a/src/main/java/org/tron/core/Constant.java b/framework/src/main/java/org/tron/core/Constant.java similarity index 100% rename from src/main/java/org/tron/core/Constant.java rename to framework/src/main/java/org/tron/core/Constant.java diff --git a/src/main/java/org/tron/core/Wallet.java b/framework/src/main/java/org/tron/core/Wallet.java similarity index 100% rename from src/main/java/org/tron/core/Wallet.java rename to framework/src/main/java/org/tron/core/Wallet.java diff --git a/src/main/java/org/tron/core/WalletSolidity.java b/framework/src/main/java/org/tron/core/WalletSolidity.java similarity index 100% rename from src/main/java/org/tron/core/WalletSolidity.java rename to framework/src/main/java/org/tron/core/WalletSolidity.java diff --git a/src/main/java/org/tron/core/actuator/AbstractActuator.java b/framework/src/main/java/org/tron/core/actuator/AbstractActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/AbstractActuator.java rename to framework/src/main/java/org/tron/core/actuator/AbstractActuator.java diff --git a/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java b/framework/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java rename to framework/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java diff --git a/src/main/java/org/tron/core/actuator/Actuator.java b/framework/src/main/java/org/tron/core/actuator/Actuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/Actuator.java rename to framework/src/main/java/org/tron/core/actuator/Actuator.java diff --git a/src/main/java/org/tron/core/actuator/ActuatorConstant.java b/framework/src/main/java/org/tron/core/actuator/ActuatorConstant.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ActuatorConstant.java rename to framework/src/main/java/org/tron/core/actuator/ActuatorConstant.java diff --git a/src/main/java/org/tron/core/actuator/ActuatorFactory.java b/framework/src/main/java/org/tron/core/actuator/ActuatorFactory.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ActuatorFactory.java rename to framework/src/main/java/org/tron/core/actuator/ActuatorFactory.java diff --git a/src/main/java/org/tron/core/actuator/AssetIssueActuator.java b/framework/src/main/java/org/tron/core/actuator/AssetIssueActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/AssetIssueActuator.java rename to framework/src/main/java/org/tron/core/actuator/AssetIssueActuator.java diff --git a/src/main/java/org/tron/core/actuator/BuyStorageActuator.java b/framework/src/main/java/org/tron/core/actuator/BuyStorageActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/BuyStorageActuator.java rename to framework/src/main/java/org/tron/core/actuator/BuyStorageActuator.java diff --git a/src/main/java/org/tron/core/actuator/BuyStorageBytesActuator.java b/framework/src/main/java/org/tron/core/actuator/BuyStorageBytesActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/BuyStorageBytesActuator.java rename to framework/src/main/java/org/tron/core/actuator/BuyStorageBytesActuator.java diff --git a/src/main/java/org/tron/core/actuator/ClearABIContractActuator.java b/framework/src/main/java/org/tron/core/actuator/ClearABIContractActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ClearABIContractActuator.java rename to framework/src/main/java/org/tron/core/actuator/ClearABIContractActuator.java diff --git a/src/main/java/org/tron/core/actuator/CreateAccountActuator.java b/framework/src/main/java/org/tron/core/actuator/CreateAccountActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/CreateAccountActuator.java rename to framework/src/main/java/org/tron/core/actuator/CreateAccountActuator.java diff --git a/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java b/framework/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java rename to framework/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java diff --git a/src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java b/framework/src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java rename to framework/src/main/java/org/tron/core/actuator/ExchangeInjectActuator.java diff --git a/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java b/framework/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java rename to framework/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java diff --git a/src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java b/framework/src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java rename to framework/src/main/java/org/tron/core/actuator/ExchangeWithdrawActuator.java diff --git a/src/main/java/org/tron/core/actuator/FreezeBalanceActuator.java b/framework/src/main/java/org/tron/core/actuator/FreezeBalanceActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/FreezeBalanceActuator.java rename to framework/src/main/java/org/tron/core/actuator/FreezeBalanceActuator.java diff --git a/src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java b/framework/src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java rename to framework/src/main/java/org/tron/core/actuator/ParticipateAssetIssueActuator.java diff --git a/src/main/java/org/tron/core/actuator/ProposalApproveActuator.java b/framework/src/main/java/org/tron/core/actuator/ProposalApproveActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ProposalApproveActuator.java rename to framework/src/main/java/org/tron/core/actuator/ProposalApproveActuator.java diff --git a/src/main/java/org/tron/core/actuator/ProposalCreateActuator.java b/framework/src/main/java/org/tron/core/actuator/ProposalCreateActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ProposalCreateActuator.java rename to framework/src/main/java/org/tron/core/actuator/ProposalCreateActuator.java diff --git a/src/main/java/org/tron/core/actuator/ProposalDeleteActuator.java b/framework/src/main/java/org/tron/core/actuator/ProposalDeleteActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ProposalDeleteActuator.java rename to framework/src/main/java/org/tron/core/actuator/ProposalDeleteActuator.java diff --git a/src/main/java/org/tron/core/actuator/SellStorageActuator.java b/framework/src/main/java/org/tron/core/actuator/SellStorageActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/SellStorageActuator.java rename to framework/src/main/java/org/tron/core/actuator/SellStorageActuator.java diff --git a/src/main/java/org/tron/core/actuator/SetAccountIdActuator.java b/framework/src/main/java/org/tron/core/actuator/SetAccountIdActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/SetAccountIdActuator.java rename to framework/src/main/java/org/tron/core/actuator/SetAccountIdActuator.java diff --git a/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java b/framework/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java rename to framework/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java diff --git a/src/main/java/org/tron/core/actuator/TransferActuator.java b/framework/src/main/java/org/tron/core/actuator/TransferActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/TransferActuator.java rename to framework/src/main/java/org/tron/core/actuator/TransferActuator.java diff --git a/src/main/java/org/tron/core/actuator/TransferAssetActuator.java b/framework/src/main/java/org/tron/core/actuator/TransferAssetActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/TransferAssetActuator.java rename to framework/src/main/java/org/tron/core/actuator/TransferAssetActuator.java diff --git a/src/main/java/org/tron/core/actuator/UnfreezeAssetActuator.java b/framework/src/main/java/org/tron/core/actuator/UnfreezeAssetActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/UnfreezeAssetActuator.java rename to framework/src/main/java/org/tron/core/actuator/UnfreezeAssetActuator.java diff --git a/src/main/java/org/tron/core/actuator/UnfreezeBalanceActuator.java b/framework/src/main/java/org/tron/core/actuator/UnfreezeBalanceActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/UnfreezeBalanceActuator.java rename to framework/src/main/java/org/tron/core/actuator/UnfreezeBalanceActuator.java diff --git a/src/main/java/org/tron/core/actuator/UpdateAccountActuator.java b/framework/src/main/java/org/tron/core/actuator/UpdateAccountActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/UpdateAccountActuator.java rename to framework/src/main/java/org/tron/core/actuator/UpdateAccountActuator.java diff --git a/src/main/java/org/tron/core/actuator/UpdateAssetActuator.java b/framework/src/main/java/org/tron/core/actuator/UpdateAssetActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/UpdateAssetActuator.java rename to framework/src/main/java/org/tron/core/actuator/UpdateAssetActuator.java diff --git a/src/main/java/org/tron/core/actuator/UpdateEnergyLimitContractActuator.java b/framework/src/main/java/org/tron/core/actuator/UpdateEnergyLimitContractActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/UpdateEnergyLimitContractActuator.java rename to framework/src/main/java/org/tron/core/actuator/UpdateEnergyLimitContractActuator.java diff --git a/src/main/java/org/tron/core/actuator/UpdateSettingContractActuator.java b/framework/src/main/java/org/tron/core/actuator/UpdateSettingContractActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/UpdateSettingContractActuator.java rename to framework/src/main/java/org/tron/core/actuator/UpdateSettingContractActuator.java diff --git a/src/main/java/org/tron/core/actuator/VoteWitnessActuator.java b/framework/src/main/java/org/tron/core/actuator/VoteWitnessActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/VoteWitnessActuator.java rename to framework/src/main/java/org/tron/core/actuator/VoteWitnessActuator.java diff --git a/src/main/java/org/tron/core/actuator/WithdrawBalanceActuator.java b/framework/src/main/java/org/tron/core/actuator/WithdrawBalanceActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/WithdrawBalanceActuator.java rename to framework/src/main/java/org/tron/core/actuator/WithdrawBalanceActuator.java diff --git a/src/main/java/org/tron/core/actuator/WitnessCreateActuator.java b/framework/src/main/java/org/tron/core/actuator/WitnessCreateActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/WitnessCreateActuator.java rename to framework/src/main/java/org/tron/core/actuator/WitnessCreateActuator.java diff --git a/src/main/java/org/tron/core/actuator/WitnessUpdateActuator.java b/framework/src/main/java/org/tron/core/actuator/WitnessUpdateActuator.java similarity index 100% rename from src/main/java/org/tron/core/actuator/WitnessUpdateActuator.java rename to framework/src/main/java/org/tron/core/actuator/WitnessUpdateActuator.java diff --git a/src/main/java/org/tron/core/capsule/AccountCapsule.java b/framework/src/main/java/org/tron/core/capsule/AccountCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/AccountCapsule.java rename to framework/src/main/java/org/tron/core/capsule/AccountCapsule.java diff --git a/src/main/java/org/tron/core/capsule/AssetIssueCapsule.java b/framework/src/main/java/org/tron/core/capsule/AssetIssueCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/AssetIssueCapsule.java rename to framework/src/main/java/org/tron/core/capsule/AssetIssueCapsule.java diff --git a/src/main/java/org/tron/core/capsule/BlockCapsule.java b/framework/src/main/java/org/tron/core/capsule/BlockCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/BlockCapsule.java rename to framework/src/main/java/org/tron/core/capsule/BlockCapsule.java diff --git a/src/main/java/org/tron/core/capsule/BlockIdCapsule.java b/framework/src/main/java/org/tron/core/capsule/BlockIdCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/BlockIdCapsule.java rename to framework/src/main/java/org/tron/core/capsule/BlockIdCapsule.java diff --git a/src/main/java/org/tron/core/capsule/BlockIdentifierCapsule.java b/framework/src/main/java/org/tron/core/capsule/BlockIdentifierCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/BlockIdentifierCapsule.java rename to framework/src/main/java/org/tron/core/capsule/BlockIdentifierCapsule.java diff --git a/src/main/java/org/tron/core/capsule/CodeCapsule.java b/framework/src/main/java/org/tron/core/capsule/CodeCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/CodeCapsule.java rename to framework/src/main/java/org/tron/core/capsule/CodeCapsule.java diff --git a/src/main/java/org/tron/core/capsule/ContractCapsule.java b/framework/src/main/java/org/tron/core/capsule/ContractCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/ContractCapsule.java rename to framework/src/main/java/org/tron/core/capsule/ContractCapsule.java diff --git a/src/main/java/org/tron/core/capsule/DelegatedResourceAccountIndexCapsule.java b/framework/src/main/java/org/tron/core/capsule/DelegatedResourceAccountIndexCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/DelegatedResourceAccountIndexCapsule.java rename to framework/src/main/java/org/tron/core/capsule/DelegatedResourceAccountIndexCapsule.java diff --git a/src/main/java/org/tron/core/capsule/DelegatedResourceCapsule.java b/framework/src/main/java/org/tron/core/capsule/DelegatedResourceCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/DelegatedResourceCapsule.java rename to framework/src/main/java/org/tron/core/capsule/DelegatedResourceCapsule.java diff --git a/src/main/java/org/tron/core/capsule/ExchangeCapsule.java b/framework/src/main/java/org/tron/core/capsule/ExchangeCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/ExchangeCapsule.java rename to framework/src/main/java/org/tron/core/capsule/ExchangeCapsule.java diff --git a/src/main/java/org/tron/core/capsule/IncrementalMerkleTreeCapsule.java b/framework/src/main/java/org/tron/core/capsule/IncrementalMerkleTreeCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/IncrementalMerkleTreeCapsule.java rename to framework/src/main/java/org/tron/core/capsule/IncrementalMerkleTreeCapsule.java diff --git a/src/main/java/org/tron/core/capsule/IncrementalMerkleVoucherCapsule.java b/framework/src/main/java/org/tron/core/capsule/IncrementalMerkleVoucherCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/IncrementalMerkleVoucherCapsule.java rename to framework/src/main/java/org/tron/core/capsule/IncrementalMerkleVoucherCapsule.java diff --git a/src/main/java/org/tron/core/capsule/PedersenHashCapsule.java b/framework/src/main/java/org/tron/core/capsule/PedersenHashCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/PedersenHashCapsule.java rename to framework/src/main/java/org/tron/core/capsule/PedersenHashCapsule.java diff --git a/src/main/java/org/tron/core/capsule/ProposalCapsule.java b/framework/src/main/java/org/tron/core/capsule/ProposalCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/ProposalCapsule.java rename to framework/src/main/java/org/tron/core/capsule/ProposalCapsule.java diff --git a/src/main/java/org/tron/core/capsule/ReceiptCapsule.java b/framework/src/main/java/org/tron/core/capsule/ReceiptCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/ReceiptCapsule.java rename to framework/src/main/java/org/tron/core/capsule/ReceiptCapsule.java diff --git a/src/main/java/org/tron/core/capsule/ReceiveDescriptionCapsule.java b/framework/src/main/java/org/tron/core/capsule/ReceiveDescriptionCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/ReceiveDescriptionCapsule.java rename to framework/src/main/java/org/tron/core/capsule/ReceiveDescriptionCapsule.java diff --git a/src/main/java/org/tron/core/capsule/SpendDescriptionCapsule.java b/framework/src/main/java/org/tron/core/capsule/SpendDescriptionCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/SpendDescriptionCapsule.java rename to framework/src/main/java/org/tron/core/capsule/SpendDescriptionCapsule.java diff --git a/src/main/java/org/tron/core/capsule/StorageRowCapsule.java b/framework/src/main/java/org/tron/core/capsule/StorageRowCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/StorageRowCapsule.java rename to framework/src/main/java/org/tron/core/capsule/StorageRowCapsule.java diff --git a/src/main/java/org/tron/core/capsule/TransactionCapsule.java b/framework/src/main/java/org/tron/core/capsule/TransactionCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/TransactionCapsule.java rename to framework/src/main/java/org/tron/core/capsule/TransactionCapsule.java diff --git a/src/main/java/org/tron/core/capsule/TransactionInfoCapsule.java b/framework/src/main/java/org/tron/core/capsule/TransactionInfoCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/TransactionInfoCapsule.java rename to framework/src/main/java/org/tron/core/capsule/TransactionInfoCapsule.java diff --git a/src/main/java/org/tron/core/capsule/TransactionResultCapsule.java b/framework/src/main/java/org/tron/core/capsule/TransactionResultCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/TransactionResultCapsule.java rename to framework/src/main/java/org/tron/core/capsule/TransactionResultCapsule.java diff --git a/src/main/java/org/tron/core/capsule/TransactionRetCapsule.java b/framework/src/main/java/org/tron/core/capsule/TransactionRetCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/TransactionRetCapsule.java rename to framework/src/main/java/org/tron/core/capsule/TransactionRetCapsule.java diff --git a/src/main/java/org/tron/core/capsule/TxInputCapsule.java b/framework/src/main/java/org/tron/core/capsule/TxInputCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/TxInputCapsule.java rename to framework/src/main/java/org/tron/core/capsule/TxInputCapsule.java diff --git a/src/main/java/org/tron/core/capsule/TxOutputCapsule.java b/framework/src/main/java/org/tron/core/capsule/TxOutputCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/TxOutputCapsule.java rename to framework/src/main/java/org/tron/core/capsule/TxOutputCapsule.java diff --git a/src/main/java/org/tron/core/capsule/VotesCapsule.java b/framework/src/main/java/org/tron/core/capsule/VotesCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/VotesCapsule.java rename to framework/src/main/java/org/tron/core/capsule/VotesCapsule.java diff --git a/src/main/java/org/tron/core/capsule/WitnessCapsule.java b/framework/src/main/java/org/tron/core/capsule/WitnessCapsule.java similarity index 100% rename from src/main/java/org/tron/core/capsule/WitnessCapsule.java rename to framework/src/main/java/org/tron/core/capsule/WitnessCapsule.java diff --git a/src/main/java/org/tron/core/capsule/utils/BlockUtil.java b/framework/src/main/java/org/tron/core/capsule/utils/BlockUtil.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/BlockUtil.java rename to framework/src/main/java/org/tron/core/capsule/utils/BlockUtil.java diff --git a/src/main/java/org/tron/core/capsule/utils/ByteArrayWrapper.java b/framework/src/main/java/org/tron/core/capsule/utils/ByteArrayWrapper.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/ByteArrayWrapper.java rename to framework/src/main/java/org/tron/core/capsule/utils/ByteArrayWrapper.java diff --git a/src/main/java/org/tron/core/capsule/utils/DecodeResult.java b/framework/src/main/java/org/tron/core/capsule/utils/DecodeResult.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/DecodeResult.java rename to framework/src/main/java/org/tron/core/capsule/utils/DecodeResult.java diff --git a/src/main/java/org/tron/core/capsule/utils/ExchangeProcessor.java b/framework/src/main/java/org/tron/core/capsule/utils/ExchangeProcessor.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/ExchangeProcessor.java rename to framework/src/main/java/org/tron/core/capsule/utils/ExchangeProcessor.java diff --git a/src/main/java/org/tron/core/capsule/utils/FastByteComparisons.java b/framework/src/main/java/org/tron/core/capsule/utils/FastByteComparisons.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/FastByteComparisons.java rename to framework/src/main/java/org/tron/core/capsule/utils/FastByteComparisons.java diff --git a/src/main/java/org/tron/core/capsule/utils/MerkleTree.java b/framework/src/main/java/org/tron/core/capsule/utils/MerkleTree.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/MerkleTree.java rename to framework/src/main/java/org/tron/core/capsule/utils/MerkleTree.java diff --git a/src/main/java/org/tron/core/capsule/utils/RLP.java b/framework/src/main/java/org/tron/core/capsule/utils/RLP.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/RLP.java rename to framework/src/main/java/org/tron/core/capsule/utils/RLP.java diff --git a/src/main/java/org/tron/core/capsule/utils/RLPElement.java b/framework/src/main/java/org/tron/core/capsule/utils/RLPElement.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/RLPElement.java rename to framework/src/main/java/org/tron/core/capsule/utils/RLPElement.java diff --git a/src/main/java/org/tron/core/capsule/utils/RLPItem.java b/framework/src/main/java/org/tron/core/capsule/utils/RLPItem.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/RLPItem.java rename to framework/src/main/java/org/tron/core/capsule/utils/RLPItem.java diff --git a/src/main/java/org/tron/core/capsule/utils/RLPList.java b/framework/src/main/java/org/tron/core/capsule/utils/RLPList.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/RLPList.java rename to framework/src/main/java/org/tron/core/capsule/utils/RLPList.java diff --git a/src/main/java/org/tron/core/capsule/utils/TransactionUtil.java b/framework/src/main/java/org/tron/core/capsule/utils/TransactionUtil.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/TransactionUtil.java rename to framework/src/main/java/org/tron/core/capsule/utils/TransactionUtil.java diff --git a/src/main/java/org/tron/core/capsule/utils/TxInputUtil.java b/framework/src/main/java/org/tron/core/capsule/utils/TxInputUtil.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/TxInputUtil.java rename to framework/src/main/java/org/tron/core/capsule/utils/TxInputUtil.java diff --git a/src/main/java/org/tron/core/capsule/utils/TxOutputUtil.java b/framework/src/main/java/org/tron/core/capsule/utils/TxOutputUtil.java similarity index 100% rename from src/main/java/org/tron/core/capsule/utils/TxOutputUtil.java rename to framework/src/main/java/org/tron/core/capsule/utils/TxOutputUtil.java diff --git a/src/main/java/org/tron/core/config/CommonConfig.java b/framework/src/main/java/org/tron/core/config/CommonConfig.java similarity index 100% rename from src/main/java/org/tron/core/config/CommonConfig.java rename to framework/src/main/java/org/tron/core/config/CommonConfig.java diff --git a/src/main/java/org/tron/core/config/Configuration.java b/framework/src/main/java/org/tron/core/config/Configuration.java similarity index 100% rename from src/main/java/org/tron/core/config/Configuration.java rename to framework/src/main/java/org/tron/core/config/Configuration.java diff --git a/src/main/java/org/tron/core/config/DefaultConfig.java b/framework/src/main/java/org/tron/core/config/DefaultConfig.java similarity index 100% rename from src/main/java/org/tron/core/config/DefaultConfig.java rename to framework/src/main/java/org/tron/core/config/DefaultConfig.java diff --git a/src/main/java/org/tron/core/config/Parameter.java b/framework/src/main/java/org/tron/core/config/Parameter.java similarity index 100% rename from src/main/java/org/tron/core/config/Parameter.java rename to framework/src/main/java/org/tron/core/config/Parameter.java diff --git a/src/main/java/org/tron/core/config/README.md b/framework/src/main/java/org/tron/core/config/README.md similarity index 100% rename from src/main/java/org/tron/core/config/README.md rename to framework/src/main/java/org/tron/core/config/README.md diff --git a/src/main/java/org/tron/core/config/args/Account.java b/framework/src/main/java/org/tron/core/config/args/Account.java similarity index 100% rename from src/main/java/org/tron/core/config/args/Account.java rename to framework/src/main/java/org/tron/core/config/args/Account.java diff --git a/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java similarity index 100% rename from src/main/java/org/tron/core/config/args/Args.java rename to framework/src/main/java/org/tron/core/config/args/Args.java diff --git a/src/main/java/org/tron/core/config/args/GenesisBlock.java b/framework/src/main/java/org/tron/core/config/args/GenesisBlock.java similarity index 100% rename from src/main/java/org/tron/core/config/args/GenesisBlock.java rename to framework/src/main/java/org/tron/core/config/args/GenesisBlock.java diff --git a/src/main/java/org/tron/core/config/args/LocalWitnesses.java b/framework/src/main/java/org/tron/core/config/args/LocalWitnesses.java similarity index 100% rename from src/main/java/org/tron/core/config/args/LocalWitnesses.java rename to framework/src/main/java/org/tron/core/config/args/LocalWitnesses.java diff --git a/src/main/java/org/tron/core/config/args/Overlay.java b/framework/src/main/java/org/tron/core/config/args/Overlay.java similarity index 100% rename from src/main/java/org/tron/core/config/args/Overlay.java rename to framework/src/main/java/org/tron/core/config/args/Overlay.java diff --git a/src/main/java/org/tron/core/config/args/SeedNode.java b/framework/src/main/java/org/tron/core/config/args/SeedNode.java similarity index 100% rename from src/main/java/org/tron/core/config/args/SeedNode.java rename to framework/src/main/java/org/tron/core/config/args/SeedNode.java diff --git a/src/main/java/org/tron/core/config/args/Storage.java b/framework/src/main/java/org/tron/core/config/args/Storage.java similarity index 100% rename from src/main/java/org/tron/core/config/args/Storage.java rename to framework/src/main/java/org/tron/core/config/args/Storage.java diff --git a/src/main/java/org/tron/core/config/args/Witness.java b/framework/src/main/java/org/tron/core/config/args/Witness.java similarity index 100% rename from src/main/java/org/tron/core/config/args/Witness.java rename to framework/src/main/java/org/tron/core/config/args/Witness.java diff --git a/src/main/java/org/tron/core/db/AccountIdIndexStore.java b/framework/src/main/java/org/tron/core/db/AccountIdIndexStore.java similarity index 100% rename from src/main/java/org/tron/core/db/AccountIdIndexStore.java rename to framework/src/main/java/org/tron/core/db/AccountIdIndexStore.java diff --git a/src/main/java/org/tron/core/db/AccountIndexStore.java b/framework/src/main/java/org/tron/core/db/AccountIndexStore.java similarity index 100% rename from src/main/java/org/tron/core/db/AccountIndexStore.java rename to framework/src/main/java/org/tron/core/db/AccountIndexStore.java diff --git a/src/main/java/org/tron/core/db/AccountStore.java b/framework/src/main/java/org/tron/core/db/AccountStore.java similarity index 100% rename from src/main/java/org/tron/core/db/AccountStore.java rename to framework/src/main/java/org/tron/core/db/AccountStore.java diff --git a/src/main/java/org/tron/core/db/AssetIssueStore.java b/framework/src/main/java/org/tron/core/db/AssetIssueStore.java similarity index 100% rename from src/main/java/org/tron/core/db/AssetIssueStore.java rename to framework/src/main/java/org/tron/core/db/AssetIssueStore.java diff --git a/src/main/java/org/tron/core/db/AssetIssueV2Store.java b/framework/src/main/java/org/tron/core/db/AssetIssueV2Store.java similarity index 100% rename from src/main/java/org/tron/core/db/AssetIssueV2Store.java rename to framework/src/main/java/org/tron/core/db/AssetIssueV2Store.java diff --git a/src/main/java/org/tron/core/db/BandwidthProcessor.java b/framework/src/main/java/org/tron/core/db/BandwidthProcessor.java similarity index 100% rename from src/main/java/org/tron/core/db/BandwidthProcessor.java rename to framework/src/main/java/org/tron/core/db/BandwidthProcessor.java diff --git a/src/main/java/org/tron/core/db/BlockIndexStore.java b/framework/src/main/java/org/tron/core/db/BlockIndexStore.java similarity index 100% rename from src/main/java/org/tron/core/db/BlockIndexStore.java rename to framework/src/main/java/org/tron/core/db/BlockIndexStore.java diff --git a/src/main/java/org/tron/core/db/BlockStore.java b/framework/src/main/java/org/tron/core/db/BlockStore.java similarity index 100% rename from src/main/java/org/tron/core/db/BlockStore.java rename to framework/src/main/java/org/tron/core/db/BlockStore.java diff --git a/src/main/java/org/tron/core/db/ByteArrayWrapper.java b/framework/src/main/java/org/tron/core/db/ByteArrayWrapper.java similarity index 100% rename from src/main/java/org/tron/core/db/ByteArrayWrapper.java rename to framework/src/main/java/org/tron/core/db/ByteArrayWrapper.java diff --git a/src/main/java/org/tron/core/db/CheckTmpStore.java b/framework/src/main/java/org/tron/core/db/CheckTmpStore.java similarity index 100% rename from src/main/java/org/tron/core/db/CheckTmpStore.java rename to framework/src/main/java/org/tron/core/db/CheckTmpStore.java diff --git a/src/main/java/org/tron/core/db/CodeStore.java b/framework/src/main/java/org/tron/core/db/CodeStore.java similarity index 100% rename from src/main/java/org/tron/core/db/CodeStore.java rename to framework/src/main/java/org/tron/core/db/CodeStore.java diff --git a/src/main/java/org/tron/core/db/ContractStore.java b/framework/src/main/java/org/tron/core/db/ContractStore.java similarity index 100% rename from src/main/java/org/tron/core/db/ContractStore.java rename to framework/src/main/java/org/tron/core/db/ContractStore.java diff --git a/src/main/java/org/tron/core/db/DelegatedResourceAccountIndexStore.java b/framework/src/main/java/org/tron/core/db/DelegatedResourceAccountIndexStore.java similarity index 100% rename from src/main/java/org/tron/core/db/DelegatedResourceAccountIndexStore.java rename to framework/src/main/java/org/tron/core/db/DelegatedResourceAccountIndexStore.java diff --git a/src/main/java/org/tron/core/db/DelegatedResourceStore.java b/framework/src/main/java/org/tron/core/db/DelegatedResourceStore.java similarity index 100% rename from src/main/java/org/tron/core/db/DelegatedResourceStore.java rename to framework/src/main/java/org/tron/core/db/DelegatedResourceStore.java diff --git a/src/main/java/org/tron/core/db/EnergyProcessor.java b/framework/src/main/java/org/tron/core/db/EnergyProcessor.java similarity index 100% rename from src/main/java/org/tron/core/db/EnergyProcessor.java rename to framework/src/main/java/org/tron/core/db/EnergyProcessor.java diff --git a/src/main/java/org/tron/core/db/ExchangeStore.java b/framework/src/main/java/org/tron/core/db/ExchangeStore.java similarity index 100% rename from src/main/java/org/tron/core/db/ExchangeStore.java rename to framework/src/main/java/org/tron/core/db/ExchangeStore.java diff --git a/src/main/java/org/tron/core/db/ExchangeV2Store.java b/framework/src/main/java/org/tron/core/db/ExchangeV2Store.java similarity index 100% rename from src/main/java/org/tron/core/db/ExchangeV2Store.java rename to framework/src/main/java/org/tron/core/db/ExchangeV2Store.java diff --git a/src/main/java/org/tron/core/db/IncrementalMerkleTreeStore.java b/framework/src/main/java/org/tron/core/db/IncrementalMerkleTreeStore.java similarity index 100% rename from src/main/java/org/tron/core/db/IncrementalMerkleTreeStore.java rename to framework/src/main/java/org/tron/core/db/IncrementalMerkleTreeStore.java diff --git a/src/main/java/org/tron/core/db/IncrementalMerkleVoucherStore.java b/framework/src/main/java/org/tron/core/db/IncrementalMerkleVoucherStore.java similarity index 100% rename from src/main/java/org/tron/core/db/IncrementalMerkleVoucherStore.java rename to framework/src/main/java/org/tron/core/db/IncrementalMerkleVoucherStore.java diff --git a/src/main/java/org/tron/core/db/KhaosDatabase.java b/framework/src/main/java/org/tron/core/db/KhaosDatabase.java similarity index 100% rename from src/main/java/org/tron/core/db/KhaosDatabase.java rename to framework/src/main/java/org/tron/core/db/KhaosDatabase.java diff --git a/src/main/java/org/tron/core/db/Manager.java b/framework/src/main/java/org/tron/core/db/Manager.java similarity index 100% rename from src/main/java/org/tron/core/db/Manager.java rename to framework/src/main/java/org/tron/core/db/Manager.java diff --git a/src/main/java/org/tron/core/db/NullifierStore.java b/framework/src/main/java/org/tron/core/db/NullifierStore.java similarity index 100% rename from src/main/java/org/tron/core/db/NullifierStore.java rename to framework/src/main/java/org/tron/core/db/NullifierStore.java diff --git a/src/main/java/org/tron/core/db/PeersStore.java b/framework/src/main/java/org/tron/core/db/PeersStore.java similarity index 100% rename from src/main/java/org/tron/core/db/PeersStore.java rename to framework/src/main/java/org/tron/core/db/PeersStore.java diff --git a/src/main/java/org/tron/core/db/PendingManager.java b/framework/src/main/java/org/tron/core/db/PendingManager.java similarity index 100% rename from src/main/java/org/tron/core/db/PendingManager.java rename to framework/src/main/java/org/tron/core/db/PendingManager.java diff --git a/src/main/java/org/tron/core/db/ProposalStore.java b/framework/src/main/java/org/tron/core/db/ProposalStore.java similarity index 100% rename from src/main/java/org/tron/core/db/ProposalStore.java rename to framework/src/main/java/org/tron/core/db/ProposalStore.java diff --git a/src/main/java/org/tron/core/db/RecentBlockStore.java b/framework/src/main/java/org/tron/core/db/RecentBlockStore.java similarity index 100% rename from src/main/java/org/tron/core/db/RecentBlockStore.java rename to framework/src/main/java/org/tron/core/db/RecentBlockStore.java diff --git a/src/main/java/org/tron/core/db/ResourceProcessor.java b/framework/src/main/java/org/tron/core/db/ResourceProcessor.java similarity index 100% rename from src/main/java/org/tron/core/db/ResourceProcessor.java rename to framework/src/main/java/org/tron/core/db/ResourceProcessor.java diff --git a/src/main/java/org/tron/core/db/RevokingDatabase.java b/framework/src/main/java/org/tron/core/db/RevokingDatabase.java similarity index 100% rename from src/main/java/org/tron/core/db/RevokingDatabase.java rename to framework/src/main/java/org/tron/core/db/RevokingDatabase.java diff --git a/src/main/java/org/tron/core/db/StorageMarket.java b/framework/src/main/java/org/tron/core/db/StorageMarket.java similarity index 100% rename from src/main/java/org/tron/core/db/StorageMarket.java rename to framework/src/main/java/org/tron/core/db/StorageMarket.java diff --git a/src/main/java/org/tron/core/db/StorageRowStore.java b/framework/src/main/java/org/tron/core/db/StorageRowStore.java similarity index 100% rename from src/main/java/org/tron/core/db/StorageRowStore.java rename to framework/src/main/java/org/tron/core/db/StorageRowStore.java diff --git a/src/main/java/org/tron/core/db/TransactionCache.java b/framework/src/main/java/org/tron/core/db/TransactionCache.java similarity index 100% rename from src/main/java/org/tron/core/db/TransactionCache.java rename to framework/src/main/java/org/tron/core/db/TransactionCache.java diff --git a/src/main/java/org/tron/core/db/TransactionHistoryStore.java b/framework/src/main/java/org/tron/core/db/TransactionHistoryStore.java similarity index 100% rename from src/main/java/org/tron/core/db/TransactionHistoryStore.java rename to framework/src/main/java/org/tron/core/db/TransactionHistoryStore.java diff --git a/src/main/java/org/tron/core/db/TransactionRetStore.java b/framework/src/main/java/org/tron/core/db/TransactionRetStore.java similarity index 100% rename from src/main/java/org/tron/core/db/TransactionRetStore.java rename to framework/src/main/java/org/tron/core/db/TransactionRetStore.java diff --git a/src/main/java/org/tron/core/db/TransactionStore.java b/framework/src/main/java/org/tron/core/db/TransactionStore.java similarity index 100% rename from src/main/java/org/tron/core/db/TransactionStore.java rename to framework/src/main/java/org/tron/core/db/TransactionStore.java diff --git a/src/main/java/org/tron/core/db/TransactionTrace.java b/framework/src/main/java/org/tron/core/db/TransactionTrace.java similarity index 100% rename from src/main/java/org/tron/core/db/TransactionTrace.java rename to framework/src/main/java/org/tron/core/db/TransactionTrace.java diff --git a/src/main/java/org/tron/core/db/TreeBlockIndexStore.java b/framework/src/main/java/org/tron/core/db/TreeBlockIndexStore.java similarity index 100% rename from src/main/java/org/tron/core/db/TreeBlockIndexStore.java rename to framework/src/main/java/org/tron/core/db/TreeBlockIndexStore.java diff --git a/src/main/java/org/tron/core/db/TronDatabase.java b/framework/src/main/java/org/tron/core/db/TronDatabase.java similarity index 100% rename from src/main/java/org/tron/core/db/TronDatabase.java rename to framework/src/main/java/org/tron/core/db/TronDatabase.java diff --git a/src/main/java/org/tron/core/db/VotesStore.java b/framework/src/main/java/org/tron/core/db/VotesStore.java similarity index 100% rename from src/main/java/org/tron/core/db/VotesStore.java rename to framework/src/main/java/org/tron/core/db/VotesStore.java diff --git a/src/main/java/org/tron/core/db/WitnessScheduleStore.java b/framework/src/main/java/org/tron/core/db/WitnessScheduleStore.java similarity index 100% rename from src/main/java/org/tron/core/db/WitnessScheduleStore.java rename to framework/src/main/java/org/tron/core/db/WitnessScheduleStore.java diff --git a/src/main/java/org/tron/core/db/WitnessStore.java b/framework/src/main/java/org/tron/core/db/WitnessStore.java similarity index 100% rename from src/main/java/org/tron/core/db/WitnessStore.java rename to framework/src/main/java/org/tron/core/db/WitnessStore.java diff --git a/src/main/java/org/tron/core/db/ZKProofStore.java b/framework/src/main/java/org/tron/core/db/ZKProofStore.java similarity index 100% rename from src/main/java/org/tron/core/db/ZKProofStore.java rename to framework/src/main/java/org/tron/core/db/ZKProofStore.java diff --git a/src/main/java/org/tron/core/db/accountstate/AccountStateEntity.java b/framework/src/main/java/org/tron/core/db/accountstate/AccountStateEntity.java similarity index 100% rename from src/main/java/org/tron/core/db/accountstate/AccountStateEntity.java rename to framework/src/main/java/org/tron/core/db/accountstate/AccountStateEntity.java diff --git a/src/main/java/org/tron/core/db/accountstate/TrieService.java b/framework/src/main/java/org/tron/core/db/accountstate/TrieService.java similarity index 100% rename from src/main/java/org/tron/core/db/accountstate/TrieService.java rename to framework/src/main/java/org/tron/core/db/accountstate/TrieService.java diff --git a/src/main/java/org/tron/core/db/accountstate/callback/AccountStateCallBack.java b/framework/src/main/java/org/tron/core/db/accountstate/callback/AccountStateCallBack.java similarity index 100% rename from src/main/java/org/tron/core/db/accountstate/callback/AccountStateCallBack.java rename to framework/src/main/java/org/tron/core/db/accountstate/callback/AccountStateCallBack.java diff --git a/src/main/java/org/tron/core/db/accountstate/storetrie/AccountStateStoreTrie.java b/framework/src/main/java/org/tron/core/db/accountstate/storetrie/AccountStateStoreTrie.java similarity index 100% rename from src/main/java/org/tron/core/db/accountstate/storetrie/AccountStateStoreTrie.java rename to framework/src/main/java/org/tron/core/db/accountstate/storetrie/AccountStateStoreTrie.java diff --git a/src/main/java/org/tron/core/db/api/AssetUpdateHelper.java b/framework/src/main/java/org/tron/core/db/api/AssetUpdateHelper.java similarity index 100% rename from src/main/java/org/tron/core/db/api/AssetUpdateHelper.java rename to framework/src/main/java/org/tron/core/db/api/AssetUpdateHelper.java diff --git a/src/main/java/org/tron/core/db/api/IndexHelper.java b/framework/src/main/java/org/tron/core/db/api/IndexHelper.java similarity index 100% rename from src/main/java/org/tron/core/db/api/IndexHelper.java rename to framework/src/main/java/org/tron/core/db/api/IndexHelper.java diff --git a/src/main/java/org/tron/core/db/api/StoreAPI.java b/framework/src/main/java/org/tron/core/db/api/StoreAPI.java similarity index 100% rename from src/main/java/org/tron/core/db/api/StoreAPI.java rename to framework/src/main/java/org/tron/core/db/api/StoreAPI.java diff --git a/src/main/java/org/tron/core/db/api/index/AbstractIndex.java b/framework/src/main/java/org/tron/core/db/api/index/AbstractIndex.java similarity index 100% rename from src/main/java/org/tron/core/db/api/index/AbstractIndex.java rename to framework/src/main/java/org/tron/core/db/api/index/AbstractIndex.java diff --git a/src/main/java/org/tron/core/db/api/index/AccountIndex.java b/framework/src/main/java/org/tron/core/db/api/index/AccountIndex.java similarity index 100% rename from src/main/java/org/tron/core/db/api/index/AccountIndex.java rename to framework/src/main/java/org/tron/core/db/api/index/AccountIndex.java diff --git a/src/main/java/org/tron/core/db/api/index/AssetIssueIndex.java b/framework/src/main/java/org/tron/core/db/api/index/AssetIssueIndex.java similarity index 100% rename from src/main/java/org/tron/core/db/api/index/AssetIssueIndex.java rename to framework/src/main/java/org/tron/core/db/api/index/AssetIssueIndex.java diff --git a/src/main/java/org/tron/core/db/api/index/BlockIndex.java b/framework/src/main/java/org/tron/core/db/api/index/BlockIndex.java similarity index 100% rename from src/main/java/org/tron/core/db/api/index/BlockIndex.java rename to framework/src/main/java/org/tron/core/db/api/index/BlockIndex.java diff --git a/src/main/java/org/tron/core/db/api/index/Index.java b/framework/src/main/java/org/tron/core/db/api/index/Index.java similarity index 100% rename from src/main/java/org/tron/core/db/api/index/Index.java rename to framework/src/main/java/org/tron/core/db/api/index/Index.java diff --git a/src/main/java/org/tron/core/db/api/index/TransactionIndex.java b/framework/src/main/java/org/tron/core/db/api/index/TransactionIndex.java similarity index 100% rename from src/main/java/org/tron/core/db/api/index/TransactionIndex.java rename to framework/src/main/java/org/tron/core/db/api/index/TransactionIndex.java diff --git a/src/main/java/org/tron/core/db/api/index/WitnessIndex.java b/framework/src/main/java/org/tron/core/db/api/index/WitnessIndex.java similarity index 100% rename from src/main/java/org/tron/core/db/api/index/WitnessIndex.java rename to framework/src/main/java/org/tron/core/db/api/index/WitnessIndex.java diff --git a/src/main/java/org/tron/core/db/api/pojo/Account.java b/framework/src/main/java/org/tron/core/db/api/pojo/Account.java similarity index 100% rename from src/main/java/org/tron/core/db/api/pojo/Account.java rename to framework/src/main/java/org/tron/core/db/api/pojo/Account.java diff --git a/src/main/java/org/tron/core/db/api/pojo/AssetIssue.java b/framework/src/main/java/org/tron/core/db/api/pojo/AssetIssue.java similarity index 100% rename from src/main/java/org/tron/core/db/api/pojo/AssetIssue.java rename to framework/src/main/java/org/tron/core/db/api/pojo/AssetIssue.java diff --git a/src/main/java/org/tron/core/db/api/pojo/Block.java b/framework/src/main/java/org/tron/core/db/api/pojo/Block.java similarity index 100% rename from src/main/java/org/tron/core/db/api/pojo/Block.java rename to framework/src/main/java/org/tron/core/db/api/pojo/Block.java diff --git a/src/main/java/org/tron/core/db/api/pojo/Transaction.java b/framework/src/main/java/org/tron/core/db/api/pojo/Transaction.java similarity index 100% rename from src/main/java/org/tron/core/db/api/pojo/Transaction.java rename to framework/src/main/java/org/tron/core/db/api/pojo/Transaction.java diff --git a/src/main/java/org/tron/core/db/api/pojo/Witness.java b/framework/src/main/java/org/tron/core/db/api/pojo/Witness.java similarity index 100% rename from src/main/java/org/tron/core/db/api/pojo/Witness.java rename to framework/src/main/java/org/tron/core/db/api/pojo/Witness.java diff --git a/src/main/java/org/tron/core/db/backup/BackupDbUtil.java b/framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java similarity index 100% rename from src/main/java/org/tron/core/db/backup/BackupDbUtil.java rename to framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java diff --git a/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java b/framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java similarity index 100% rename from src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java rename to framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java diff --git a/src/main/java/org/tron/core/db/backup/DbBackupConfig.java b/framework/src/main/java/org/tron/core/db/backup/DbBackupConfig.java similarity index 100% rename from src/main/java/org/tron/core/db/backup/DbBackupConfig.java rename to framework/src/main/java/org/tron/core/db/backup/DbBackupConfig.java diff --git a/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java b/framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java similarity index 100% rename from src/main/java/org/tron/core/db/backup/NeedBeanCondition.java rename to framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java diff --git a/src/main/java/org/tron/core/db/common/WrappedResultSet.java b/framework/src/main/java/org/tron/core/db/common/WrappedResultSet.java similarity index 100% rename from src/main/java/org/tron/core/db/common/WrappedResultSet.java rename to framework/src/main/java/org/tron/core/db/common/WrappedResultSet.java diff --git a/src/main/java/org/tron/core/db/common/iterator/AbstractIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/AbstractIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/AbstractIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/AbstractIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/AccountIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/AccountIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/AccountIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/AccountIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/AssetIssueIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/AssetIssueIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/AssetIssueIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/AssetIssueIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/BlockIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/BlockIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/BlockIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/BlockIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/DBIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/DBIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/DBIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/DBIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/RockStoreIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/StoreIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/StoreIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/StoreIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/StoreIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/TransactionIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/TransactionIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/TransactionIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/TransactionIterator.java diff --git a/src/main/java/org/tron/core/db/common/iterator/WitnessIterator.java b/framework/src/main/java/org/tron/core/db/common/iterator/WitnessIterator.java similarity index 100% rename from src/main/java/org/tron/core/db/common/iterator/WitnessIterator.java rename to framework/src/main/java/org/tron/core/db/common/iterator/WitnessIterator.java diff --git a/src/main/java/org/tron/core/db2/common/ConcurrentHashDB.java b/framework/src/main/java/org/tron/core/db2/common/ConcurrentHashDB.java similarity index 100% rename from src/main/java/org/tron/core/db2/common/ConcurrentHashDB.java rename to framework/src/main/java/org/tron/core/db2/common/ConcurrentHashDB.java diff --git a/src/main/java/org/tron/core/exception/AccountResourceInsufficientException.java b/framework/src/main/java/org/tron/core/exception/AccountResourceInsufficientException.java similarity index 100% rename from src/main/java/org/tron/core/exception/AccountResourceInsufficientException.java rename to framework/src/main/java/org/tron/core/exception/AccountResourceInsufficientException.java diff --git a/src/main/java/org/tron/core/exception/BadBlockException.java b/framework/src/main/java/org/tron/core/exception/BadBlockException.java similarity index 100% rename from src/main/java/org/tron/core/exception/BadBlockException.java rename to framework/src/main/java/org/tron/core/exception/BadBlockException.java diff --git a/src/main/java/org/tron/core/exception/BadNumberBlockException.java b/framework/src/main/java/org/tron/core/exception/BadNumberBlockException.java similarity index 100% rename from src/main/java/org/tron/core/exception/BadNumberBlockException.java rename to framework/src/main/java/org/tron/core/exception/BadNumberBlockException.java diff --git a/src/main/java/org/tron/core/exception/BadTransactionException.java b/framework/src/main/java/org/tron/core/exception/BadTransactionException.java similarity index 100% rename from src/main/java/org/tron/core/exception/BadTransactionException.java rename to framework/src/main/java/org/tron/core/exception/BadTransactionException.java diff --git a/src/main/java/org/tron/core/exception/BalanceInsufficientException.java b/framework/src/main/java/org/tron/core/exception/BalanceInsufficientException.java similarity index 100% rename from src/main/java/org/tron/core/exception/BalanceInsufficientException.java rename to framework/src/main/java/org/tron/core/exception/BalanceInsufficientException.java diff --git a/src/main/java/org/tron/core/exception/CancelException.java b/framework/src/main/java/org/tron/core/exception/CancelException.java similarity index 100% rename from src/main/java/org/tron/core/exception/CancelException.java rename to framework/src/main/java/org/tron/core/exception/CancelException.java diff --git a/src/main/java/org/tron/core/exception/ContractExeException.java b/framework/src/main/java/org/tron/core/exception/ContractExeException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ContractExeException.java rename to framework/src/main/java/org/tron/core/exception/ContractExeException.java diff --git a/src/main/java/org/tron/core/exception/ContractSizeNotEqualToOneException.java b/framework/src/main/java/org/tron/core/exception/ContractSizeNotEqualToOneException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ContractSizeNotEqualToOneException.java rename to framework/src/main/java/org/tron/core/exception/ContractSizeNotEqualToOneException.java diff --git a/src/main/java/org/tron/core/exception/ContractValidateException.java b/framework/src/main/java/org/tron/core/exception/ContractValidateException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ContractValidateException.java rename to framework/src/main/java/org/tron/core/exception/ContractValidateException.java diff --git a/src/main/java/org/tron/core/exception/DupTransactionException.java b/framework/src/main/java/org/tron/core/exception/DupTransactionException.java similarity index 100% rename from src/main/java/org/tron/core/exception/DupTransactionException.java rename to framework/src/main/java/org/tron/core/exception/DupTransactionException.java diff --git a/src/main/java/org/tron/core/exception/HeaderNotFound.java b/framework/src/main/java/org/tron/core/exception/HeaderNotFound.java similarity index 100% rename from src/main/java/org/tron/core/exception/HeaderNotFound.java rename to framework/src/main/java/org/tron/core/exception/HeaderNotFound.java diff --git a/src/main/java/org/tron/core/exception/HighFreqException.java b/framework/src/main/java/org/tron/core/exception/HighFreqException.java similarity index 100% rename from src/main/java/org/tron/core/exception/HighFreqException.java rename to framework/src/main/java/org/tron/core/exception/HighFreqException.java diff --git a/src/main/java/org/tron/core/exception/NonCommonBlockException.java b/framework/src/main/java/org/tron/core/exception/NonCommonBlockException.java similarity index 100% rename from src/main/java/org/tron/core/exception/NonCommonBlockException.java rename to framework/src/main/java/org/tron/core/exception/NonCommonBlockException.java diff --git a/src/main/java/org/tron/core/exception/NonUniqueObjectException.java b/framework/src/main/java/org/tron/core/exception/NonUniqueObjectException.java similarity index 100% rename from src/main/java/org/tron/core/exception/NonUniqueObjectException.java rename to framework/src/main/java/org/tron/core/exception/NonUniqueObjectException.java diff --git a/src/main/java/org/tron/core/exception/P2pException.java b/framework/src/main/java/org/tron/core/exception/P2pException.java similarity index 100% rename from src/main/java/org/tron/core/exception/P2pException.java rename to framework/src/main/java/org/tron/core/exception/P2pException.java diff --git a/src/main/java/org/tron/core/exception/PermissionException.java b/framework/src/main/java/org/tron/core/exception/PermissionException.java similarity index 100% rename from src/main/java/org/tron/core/exception/PermissionException.java rename to framework/src/main/java/org/tron/core/exception/PermissionException.java diff --git a/src/main/java/org/tron/core/exception/ReceiptCheckErrException.java b/framework/src/main/java/org/tron/core/exception/ReceiptCheckErrException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ReceiptCheckErrException.java rename to framework/src/main/java/org/tron/core/exception/ReceiptCheckErrException.java diff --git a/src/main/java/org/tron/core/exception/SignatureFormatException.java b/framework/src/main/java/org/tron/core/exception/SignatureFormatException.java similarity index 100% rename from src/main/java/org/tron/core/exception/SignatureFormatException.java rename to framework/src/main/java/org/tron/core/exception/SignatureFormatException.java diff --git a/src/main/java/org/tron/core/exception/TaposException.java b/framework/src/main/java/org/tron/core/exception/TaposException.java similarity index 100% rename from src/main/java/org/tron/core/exception/TaposException.java rename to framework/src/main/java/org/tron/core/exception/TaposException.java diff --git a/src/main/java/org/tron/core/exception/TooBigTransactionException.java b/framework/src/main/java/org/tron/core/exception/TooBigTransactionException.java similarity index 100% rename from src/main/java/org/tron/core/exception/TooBigTransactionException.java rename to framework/src/main/java/org/tron/core/exception/TooBigTransactionException.java diff --git a/src/main/java/org/tron/core/exception/TooBigTransactionResultException.java b/framework/src/main/java/org/tron/core/exception/TooBigTransactionResultException.java similarity index 100% rename from src/main/java/org/tron/core/exception/TooBigTransactionResultException.java rename to framework/src/main/java/org/tron/core/exception/TooBigTransactionResultException.java diff --git a/src/main/java/org/tron/core/exception/TraitorPeerException.java b/framework/src/main/java/org/tron/core/exception/TraitorPeerException.java similarity index 100% rename from src/main/java/org/tron/core/exception/TraitorPeerException.java rename to framework/src/main/java/org/tron/core/exception/TraitorPeerException.java diff --git a/src/main/java/org/tron/core/exception/TransactionExpirationException.java b/framework/src/main/java/org/tron/core/exception/TransactionExpirationException.java similarity index 100% rename from src/main/java/org/tron/core/exception/TransactionExpirationException.java rename to framework/src/main/java/org/tron/core/exception/TransactionExpirationException.java diff --git a/src/main/java/org/tron/core/exception/TronException.java b/framework/src/main/java/org/tron/core/exception/TronException.java similarity index 100% rename from src/main/java/org/tron/core/exception/TronException.java rename to framework/src/main/java/org/tron/core/exception/TronException.java diff --git a/src/main/java/org/tron/core/exception/TronRuntimeException.java b/framework/src/main/java/org/tron/core/exception/TronRuntimeException.java similarity index 100% rename from src/main/java/org/tron/core/exception/TronRuntimeException.java rename to framework/src/main/java/org/tron/core/exception/TronRuntimeException.java diff --git a/src/main/java/org/tron/core/exception/UnLinkedBlockException.java b/framework/src/main/java/org/tron/core/exception/UnLinkedBlockException.java similarity index 100% rename from src/main/java/org/tron/core/exception/UnLinkedBlockException.java rename to framework/src/main/java/org/tron/core/exception/UnLinkedBlockException.java diff --git a/src/main/java/org/tron/core/exception/UnReachBlockException.java b/framework/src/main/java/org/tron/core/exception/UnReachBlockException.java similarity index 100% rename from src/main/java/org/tron/core/exception/UnReachBlockException.java rename to framework/src/main/java/org/tron/core/exception/UnReachBlockException.java diff --git a/src/main/java/org/tron/core/exception/VMIllegalException.java b/framework/src/main/java/org/tron/core/exception/VMIllegalException.java similarity index 100% rename from src/main/java/org/tron/core/exception/VMIllegalException.java rename to framework/src/main/java/org/tron/core/exception/VMIllegalException.java diff --git a/src/main/java/org/tron/core/exception/VMMemoryOverflowException.java b/framework/src/main/java/org/tron/core/exception/VMMemoryOverflowException.java similarity index 100% rename from src/main/java/org/tron/core/exception/VMMemoryOverflowException.java rename to framework/src/main/java/org/tron/core/exception/VMMemoryOverflowException.java diff --git a/src/main/java/org/tron/core/exception/ValidateBandwidthException.java b/framework/src/main/java/org/tron/core/exception/ValidateBandwidthException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ValidateBandwidthException.java rename to framework/src/main/java/org/tron/core/exception/ValidateBandwidthException.java diff --git a/src/main/java/org/tron/core/exception/ValidateScheduleException.java b/framework/src/main/java/org/tron/core/exception/ValidateScheduleException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ValidateScheduleException.java rename to framework/src/main/java/org/tron/core/exception/ValidateScheduleException.java diff --git a/src/main/java/org/tron/core/exception/ValidateSignatureException.java b/framework/src/main/java/org/tron/core/exception/ValidateSignatureException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ValidateSignatureException.java rename to framework/src/main/java/org/tron/core/exception/ValidateSignatureException.java diff --git a/src/main/java/org/tron/core/exception/ZkProofValidateException.java b/framework/src/main/java/org/tron/core/exception/ZkProofValidateException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ZkProofValidateException.java rename to framework/src/main/java/org/tron/core/exception/ZkProofValidateException.java diff --git a/src/main/java/org/tron/core/exception/ZksnarkException.java b/framework/src/main/java/org/tron/core/exception/ZksnarkException.java similarity index 100% rename from src/main/java/org/tron/core/exception/ZksnarkException.java rename to framework/src/main/java/org/tron/core/exception/ZksnarkException.java diff --git a/src/main/java/org/tron/core/net/TronNetDelegate.java b/framework/src/main/java/org/tron/core/net/TronNetDelegate.java similarity index 100% rename from src/main/java/org/tron/core/net/TronNetDelegate.java rename to framework/src/main/java/org/tron/core/net/TronNetDelegate.java diff --git a/src/main/java/org/tron/core/net/TronNetHandler.java b/framework/src/main/java/org/tron/core/net/TronNetHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/TronNetHandler.java rename to framework/src/main/java/org/tron/core/net/TronNetHandler.java diff --git a/src/main/java/org/tron/core/net/TronNetService.java b/framework/src/main/java/org/tron/core/net/TronNetService.java similarity index 100% rename from src/main/java/org/tron/core/net/TronNetService.java rename to framework/src/main/java/org/tron/core/net/TronNetService.java diff --git a/src/main/java/org/tron/core/net/message/BlockInventoryMessage.java b/framework/src/main/java/org/tron/core/net/message/BlockInventoryMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/BlockInventoryMessage.java rename to framework/src/main/java/org/tron/core/net/message/BlockInventoryMessage.java diff --git a/src/main/java/org/tron/core/net/message/BlockMessage.java b/framework/src/main/java/org/tron/core/net/message/BlockMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/BlockMessage.java rename to framework/src/main/java/org/tron/core/net/message/BlockMessage.java diff --git a/src/main/java/org/tron/core/net/message/BlocksMessage.java b/framework/src/main/java/org/tron/core/net/message/BlocksMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/BlocksMessage.java rename to framework/src/main/java/org/tron/core/net/message/BlocksMessage.java diff --git a/src/main/java/org/tron/core/net/message/ChainInventoryMessage.java b/framework/src/main/java/org/tron/core/net/message/ChainInventoryMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/ChainInventoryMessage.java rename to framework/src/main/java/org/tron/core/net/message/ChainInventoryMessage.java diff --git a/src/main/java/org/tron/core/net/message/FetchBlockHeadersMessage.java b/framework/src/main/java/org/tron/core/net/message/FetchBlockHeadersMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/FetchBlockHeadersMessage.java rename to framework/src/main/java/org/tron/core/net/message/FetchBlockHeadersMessage.java diff --git a/src/main/java/org/tron/core/net/message/FetchInvDataMessage.java b/framework/src/main/java/org/tron/core/net/message/FetchInvDataMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/FetchInvDataMessage.java rename to framework/src/main/java/org/tron/core/net/message/FetchInvDataMessage.java diff --git a/src/main/java/org/tron/core/net/message/InventoryMessage.java b/framework/src/main/java/org/tron/core/net/message/InventoryMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/InventoryMessage.java rename to framework/src/main/java/org/tron/core/net/message/InventoryMessage.java diff --git a/src/main/java/org/tron/core/net/message/ItemNotFound.java b/framework/src/main/java/org/tron/core/net/message/ItemNotFound.java similarity index 100% rename from src/main/java/org/tron/core/net/message/ItemNotFound.java rename to framework/src/main/java/org/tron/core/net/message/ItemNotFound.java diff --git a/src/main/java/org/tron/core/net/message/MessageTypes.java b/framework/src/main/java/org/tron/core/net/message/MessageTypes.java similarity index 100% rename from src/main/java/org/tron/core/net/message/MessageTypes.java rename to framework/src/main/java/org/tron/core/net/message/MessageTypes.java diff --git a/src/main/java/org/tron/core/net/message/SyncBlockChainMessage.java b/framework/src/main/java/org/tron/core/net/message/SyncBlockChainMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/SyncBlockChainMessage.java rename to framework/src/main/java/org/tron/core/net/message/SyncBlockChainMessage.java diff --git a/src/main/java/org/tron/core/net/message/TransactionInventoryMessage.java b/framework/src/main/java/org/tron/core/net/message/TransactionInventoryMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/TransactionInventoryMessage.java rename to framework/src/main/java/org/tron/core/net/message/TransactionInventoryMessage.java diff --git a/src/main/java/org/tron/core/net/message/TransactionMessage.java b/framework/src/main/java/org/tron/core/net/message/TransactionMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/TransactionMessage.java rename to framework/src/main/java/org/tron/core/net/message/TransactionMessage.java diff --git a/src/main/java/org/tron/core/net/message/TransactionsMessage.java b/framework/src/main/java/org/tron/core/net/message/TransactionsMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/TransactionsMessage.java rename to framework/src/main/java/org/tron/core/net/message/TransactionsMessage.java diff --git a/src/main/java/org/tron/core/net/message/TronMessage.java b/framework/src/main/java/org/tron/core/net/message/TronMessage.java similarity index 100% rename from src/main/java/org/tron/core/net/message/TronMessage.java rename to framework/src/main/java/org/tron/core/net/message/TronMessage.java diff --git a/src/main/java/org/tron/core/net/message/TronMessageFactory.java b/framework/src/main/java/org/tron/core/net/message/TronMessageFactory.java similarity index 100% rename from src/main/java/org/tron/core/net/message/TronMessageFactory.java rename to framework/src/main/java/org/tron/core/net/message/TronMessageFactory.java diff --git a/src/main/java/org/tron/core/net/messagehandler/BlockMsgHandler.java b/framework/src/main/java/org/tron/core/net/messagehandler/BlockMsgHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/messagehandler/BlockMsgHandler.java rename to framework/src/main/java/org/tron/core/net/messagehandler/BlockMsgHandler.java diff --git a/src/main/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandler.java b/framework/src/main/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandler.java rename to framework/src/main/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandler.java diff --git a/src/main/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandler.java b/framework/src/main/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandler.java rename to framework/src/main/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandler.java diff --git a/src/main/java/org/tron/core/net/messagehandler/InventoryMsgHandler.java b/framework/src/main/java/org/tron/core/net/messagehandler/InventoryMsgHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/messagehandler/InventoryMsgHandler.java rename to framework/src/main/java/org/tron/core/net/messagehandler/InventoryMsgHandler.java diff --git a/src/main/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandler.java b/framework/src/main/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandler.java rename to framework/src/main/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandler.java diff --git a/src/main/java/org/tron/core/net/messagehandler/TransactionsMsgHandler.java b/framework/src/main/java/org/tron/core/net/messagehandler/TransactionsMsgHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/messagehandler/TransactionsMsgHandler.java rename to framework/src/main/java/org/tron/core/net/messagehandler/TransactionsMsgHandler.java diff --git a/src/main/java/org/tron/core/net/messagehandler/TronMsgHandler.java b/framework/src/main/java/org/tron/core/net/messagehandler/TronMsgHandler.java similarity index 100% rename from src/main/java/org/tron/core/net/messagehandler/TronMsgHandler.java rename to framework/src/main/java/org/tron/core/net/messagehandler/TronMsgHandler.java diff --git a/src/main/java/org/tron/core/net/peer/Item.java b/framework/src/main/java/org/tron/core/net/peer/Item.java similarity index 100% rename from src/main/java/org/tron/core/net/peer/Item.java rename to framework/src/main/java/org/tron/core/net/peer/Item.java diff --git a/src/main/java/org/tron/core/net/peer/PeerConnection.java b/framework/src/main/java/org/tron/core/net/peer/PeerConnection.java similarity index 100% rename from src/main/java/org/tron/core/net/peer/PeerConnection.java rename to framework/src/main/java/org/tron/core/net/peer/PeerConnection.java diff --git a/src/main/java/org/tron/core/net/peer/PeerStatusCheck.java b/framework/src/main/java/org/tron/core/net/peer/PeerStatusCheck.java similarity index 100% rename from src/main/java/org/tron/core/net/peer/PeerStatusCheck.java rename to framework/src/main/java/org/tron/core/net/peer/PeerStatusCheck.java diff --git a/src/main/java/org/tron/core/net/service/AdvService.java b/framework/src/main/java/org/tron/core/net/service/AdvService.java similarity index 100% rename from src/main/java/org/tron/core/net/service/AdvService.java rename to framework/src/main/java/org/tron/core/net/service/AdvService.java diff --git a/src/main/java/org/tron/core/net/service/SyncService.java b/framework/src/main/java/org/tron/core/net/service/SyncService.java similarity index 100% rename from src/main/java/org/tron/core/net/service/SyncService.java rename to framework/src/main/java/org/tron/core/net/service/SyncService.java diff --git a/src/main/java/org/tron/core/services/NodeInfoService.java b/framework/src/main/java/org/tron/core/services/NodeInfoService.java similarity index 100% rename from src/main/java/org/tron/core/services/NodeInfoService.java rename to framework/src/main/java/org/tron/core/services/NodeInfoService.java diff --git a/src/main/java/org/tron/core/services/RpcApiService.java b/framework/src/main/java/org/tron/core/services/RpcApiService.java similarity index 100% rename from src/main/java/org/tron/core/services/RpcApiService.java rename to framework/src/main/java/org/tron/core/services/RpcApiService.java diff --git a/src/main/java/org/tron/core/services/WitnessProductBlockService.java b/framework/src/main/java/org/tron/core/services/WitnessProductBlockService.java similarity index 100% rename from src/main/java/org/tron/core/services/WitnessProductBlockService.java rename to framework/src/main/java/org/tron/core/services/WitnessProductBlockService.java diff --git a/src/main/java/org/tron/core/services/WitnessService.java b/framework/src/main/java/org/tron/core/services/WitnessService.java similarity index 100% rename from src/main/java/org/tron/core/services/WitnessService.java rename to framework/src/main/java/org/tron/core/services/WitnessService.java diff --git a/src/main/java/org/tron/core/services/http/AccountPermissionUpdateServlet.java b/framework/src/main/java/org/tron/core/services/http/AccountPermissionUpdateServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/AccountPermissionUpdateServlet.java rename to framework/src/main/java/org/tron/core/services/http/AccountPermissionUpdateServlet.java diff --git a/src/main/java/org/tron/core/services/http/AddTransactionSignServlet.java b/framework/src/main/java/org/tron/core/services/http/AddTransactionSignServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/AddTransactionSignServlet.java rename to framework/src/main/java/org/tron/core/services/http/AddTransactionSignServlet.java diff --git a/src/main/java/org/tron/core/services/http/BroadcastHexServlet.java b/framework/src/main/java/org/tron/core/services/http/BroadcastHexServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/BroadcastHexServlet.java rename to framework/src/main/java/org/tron/core/services/http/BroadcastHexServlet.java diff --git a/src/main/java/org/tron/core/services/http/BroadcastServlet.java b/framework/src/main/java/org/tron/core/services/http/BroadcastServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/BroadcastServlet.java rename to framework/src/main/java/org/tron/core/services/http/BroadcastServlet.java diff --git a/src/main/java/org/tron/core/services/http/ClearABIServlet.java b/framework/src/main/java/org/tron/core/services/http/ClearABIServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ClearABIServlet.java rename to framework/src/main/java/org/tron/core/services/http/ClearABIServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateAccountServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateAccountServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateAccountServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateAccountServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateAddressServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateAddressServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateAddressServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateAddressServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateAssetIssueServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateAssetIssueServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateAssetIssueServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateAssetIssueServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateShieldNullifierServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateShieldNullifierServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateShieldNullifierServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateShieldNullifierServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateShieldedTransactionServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateShieldedTransactionServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateShieldedTransactionServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateShieldedTransactionServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateShieldedTransactionWithoutSpendAuthSigServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateShieldedTransactionWithoutSpendAuthSigServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateShieldedTransactionWithoutSpendAuthSigServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateShieldedTransactionWithoutSpendAuthSigServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateSpendAuthSigServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateSpendAuthSigServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateSpendAuthSigServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateSpendAuthSigServlet.java diff --git a/src/main/java/org/tron/core/services/http/CreateWitnessServlet.java b/framework/src/main/java/org/tron/core/services/http/CreateWitnessServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/CreateWitnessServlet.java rename to framework/src/main/java/org/tron/core/services/http/CreateWitnessServlet.java diff --git a/src/main/java/org/tron/core/services/http/DeployContractServlet.java b/framework/src/main/java/org/tron/core/services/http/DeployContractServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/DeployContractServlet.java rename to framework/src/main/java/org/tron/core/services/http/DeployContractServlet.java diff --git a/src/main/java/org/tron/core/services/http/EasyTransferAssetByPrivateServlet.java b/framework/src/main/java/org/tron/core/services/http/EasyTransferAssetByPrivateServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/EasyTransferAssetByPrivateServlet.java rename to framework/src/main/java/org/tron/core/services/http/EasyTransferAssetByPrivateServlet.java diff --git a/src/main/java/org/tron/core/services/http/EasyTransferAssetServlet.java b/framework/src/main/java/org/tron/core/services/http/EasyTransferAssetServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/EasyTransferAssetServlet.java rename to framework/src/main/java/org/tron/core/services/http/EasyTransferAssetServlet.java diff --git a/src/main/java/org/tron/core/services/http/EasyTransferByPrivateServlet.java b/framework/src/main/java/org/tron/core/services/http/EasyTransferByPrivateServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/EasyTransferByPrivateServlet.java rename to framework/src/main/java/org/tron/core/services/http/EasyTransferByPrivateServlet.java diff --git a/src/main/java/org/tron/core/services/http/EasyTransferServlet.java b/framework/src/main/java/org/tron/core/services/http/EasyTransferServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/EasyTransferServlet.java rename to framework/src/main/java/org/tron/core/services/http/EasyTransferServlet.java diff --git a/src/main/java/org/tron/core/services/http/ExchangeCreateServlet.java b/framework/src/main/java/org/tron/core/services/http/ExchangeCreateServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ExchangeCreateServlet.java rename to framework/src/main/java/org/tron/core/services/http/ExchangeCreateServlet.java diff --git a/src/main/java/org/tron/core/services/http/ExchangeInjectServlet.java b/framework/src/main/java/org/tron/core/services/http/ExchangeInjectServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ExchangeInjectServlet.java rename to framework/src/main/java/org/tron/core/services/http/ExchangeInjectServlet.java diff --git a/src/main/java/org/tron/core/services/http/ExchangeTransactionServlet.java b/framework/src/main/java/org/tron/core/services/http/ExchangeTransactionServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ExchangeTransactionServlet.java rename to framework/src/main/java/org/tron/core/services/http/ExchangeTransactionServlet.java diff --git a/src/main/java/org/tron/core/services/http/ExchangeWithdrawServlet.java b/framework/src/main/java/org/tron/core/services/http/ExchangeWithdrawServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ExchangeWithdrawServlet.java rename to framework/src/main/java/org/tron/core/services/http/ExchangeWithdrawServlet.java diff --git a/src/main/java/org/tron/core/services/http/FreezeBalanceServlet.java b/framework/src/main/java/org/tron/core/services/http/FreezeBalanceServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/FreezeBalanceServlet.java rename to framework/src/main/java/org/tron/core/services/http/FreezeBalanceServlet.java diff --git a/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java b/framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java similarity index 100% rename from src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java rename to framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java diff --git a/src/main/java/org/tron/core/services/http/GenerateAddressServlet.java b/framework/src/main/java/org/tron/core/services/http/GenerateAddressServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GenerateAddressServlet.java rename to framework/src/main/java/org/tron/core/services/http/GenerateAddressServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAccountByIdServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAccountByIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAccountByIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAccountByIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAccountNetServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAccountNetServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAccountNetServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAccountNetServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAccountResourceServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAccountResourceServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAccountResourceServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAccountResourceServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAccountServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAccountServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAccountServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAccountServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAkFromAskServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAkFromAskServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAkFromAskServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAkFromAskServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAssetIssueByAccountServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAssetIssueByAccountServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAssetIssueByAccountServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAssetIssueByAccountServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAssetIssueByIdServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAssetIssueByIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAssetIssueByIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAssetIssueByIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAssetIssueByNameServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAssetIssueByNameServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAssetIssueByNameServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAssetIssueByNameServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAssetIssueListByNameServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAssetIssueListByNameServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAssetIssueListByNameServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAssetIssueListByNameServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetAssetIssueListServlet.java b/framework/src/main/java/org/tron/core/services/http/GetAssetIssueListServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetAssetIssueListServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetAssetIssueListServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetBlockByIdServlet.java b/framework/src/main/java/org/tron/core/services/http/GetBlockByIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetBlockByIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetBlockByIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetBlockByLatestNumServlet.java b/framework/src/main/java/org/tron/core/services/http/GetBlockByLatestNumServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetBlockByLatestNumServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetBlockByLatestNumServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetBlockByLimitNextServlet.java b/framework/src/main/java/org/tron/core/services/http/GetBlockByLimitNextServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetBlockByLimitNextServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetBlockByLimitNextServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetBlockByNumServlet.java b/framework/src/main/java/org/tron/core/services/http/GetBlockByNumServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetBlockByNumServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetBlockByNumServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetChainParametersServlet.java b/framework/src/main/java/org/tron/core/services/http/GetChainParametersServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetChainParametersServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetChainParametersServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetContractServlet.java b/framework/src/main/java/org/tron/core/services/http/GetContractServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetContractServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetContractServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetDelegatedResourceAccountIndexServlet.java b/framework/src/main/java/org/tron/core/services/http/GetDelegatedResourceAccountIndexServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetDelegatedResourceAccountIndexServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetDelegatedResourceAccountIndexServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetDelegatedResourceServlet.java b/framework/src/main/java/org/tron/core/services/http/GetDelegatedResourceServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetDelegatedResourceServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetDelegatedResourceServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetDiversifierServlet.java b/framework/src/main/java/org/tron/core/services/http/GetDiversifierServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetDiversifierServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetDiversifierServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetExchangeByIdServlet.java b/framework/src/main/java/org/tron/core/services/http/GetExchangeByIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetExchangeByIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetExchangeByIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetExpandedSpendingKeyServlet.java b/framework/src/main/java/org/tron/core/services/http/GetExpandedSpendingKeyServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetExpandedSpendingKeyServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetExpandedSpendingKeyServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetIncomingViewingKeyServlet.java b/framework/src/main/java/org/tron/core/services/http/GetIncomingViewingKeyServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetIncomingViewingKeyServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetIncomingViewingKeyServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetMerkleTreeVoucherInfoServlet.java b/framework/src/main/java/org/tron/core/services/http/GetMerkleTreeVoucherInfoServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetMerkleTreeVoucherInfoServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetMerkleTreeVoucherInfoServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetNextMaintenanceTimeServlet.java b/framework/src/main/java/org/tron/core/services/http/GetNextMaintenanceTimeServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetNextMaintenanceTimeServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetNextMaintenanceTimeServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetNkFromNskServlet.java b/framework/src/main/java/org/tron/core/services/http/GetNkFromNskServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetNkFromNskServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetNkFromNskServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetNodeInfoServlet.java b/framework/src/main/java/org/tron/core/services/http/GetNodeInfoServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetNodeInfoServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetNodeInfoServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetNowBlockServlet.java b/framework/src/main/java/org/tron/core/services/http/GetNowBlockServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetNowBlockServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetNowBlockServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetPaginatedAssetIssueListServlet.java b/framework/src/main/java/org/tron/core/services/http/GetPaginatedAssetIssueListServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetPaginatedAssetIssueListServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetPaginatedAssetIssueListServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetPaginatedExchangeListServlet.java b/framework/src/main/java/org/tron/core/services/http/GetPaginatedExchangeListServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetPaginatedExchangeListServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetPaginatedExchangeListServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetPaginatedProposalListServlet.java b/framework/src/main/java/org/tron/core/services/http/GetPaginatedProposalListServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetPaginatedProposalListServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetPaginatedProposalListServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetProposalByIdServlet.java b/framework/src/main/java/org/tron/core/services/http/GetProposalByIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetProposalByIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetProposalByIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetRcmServlet.java b/framework/src/main/java/org/tron/core/services/http/GetRcmServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetRcmServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetRcmServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetShieldTransactionHashServlet.java b/framework/src/main/java/org/tron/core/services/http/GetShieldTransactionHashServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetShieldTransactionHashServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetShieldTransactionHashServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetSpendingKeyServlet.java b/framework/src/main/java/org/tron/core/services/http/GetSpendingKeyServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetSpendingKeyServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetSpendingKeyServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetTransactionApprovedListServlet.java b/framework/src/main/java/org/tron/core/services/http/GetTransactionApprovedListServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetTransactionApprovedListServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetTransactionApprovedListServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetTransactionByIdServlet.java b/framework/src/main/java/org/tron/core/services/http/GetTransactionByIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetTransactionByIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetTransactionByIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetTransactionCountByBlockNumServlet.java b/framework/src/main/java/org/tron/core/services/http/GetTransactionCountByBlockNumServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetTransactionCountByBlockNumServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetTransactionCountByBlockNumServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetTransactionInfoByIdServlet.java b/framework/src/main/java/org/tron/core/services/http/GetTransactionInfoByIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetTransactionInfoByIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetTransactionInfoByIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetTransactionSignWeightServlet.java b/framework/src/main/java/org/tron/core/services/http/GetTransactionSignWeightServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetTransactionSignWeightServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetTransactionSignWeightServlet.java diff --git a/src/main/java/org/tron/core/services/http/GetZenPaymentAddressServlet.java b/framework/src/main/java/org/tron/core/services/http/GetZenPaymentAddressServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/GetZenPaymentAddressServlet.java rename to framework/src/main/java/org/tron/core/services/http/GetZenPaymentAddressServlet.java diff --git a/src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java b/framework/src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java similarity index 100% rename from src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java rename to framework/src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java diff --git a/src/main/java/org/tron/core/services/http/IsSpendServlet.java b/framework/src/main/java/org/tron/core/services/http/IsSpendServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/IsSpendServlet.java rename to framework/src/main/java/org/tron/core/services/http/IsSpendServlet.java diff --git a/src/main/java/org/tron/core/services/http/JsonFormat.java b/framework/src/main/java/org/tron/core/services/http/JsonFormat.java similarity index 100% rename from src/main/java/org/tron/core/services/http/JsonFormat.java rename to framework/src/main/java/org/tron/core/services/http/JsonFormat.java diff --git a/src/main/java/org/tron/core/services/http/ListExchangesServlet.java b/framework/src/main/java/org/tron/core/services/http/ListExchangesServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ListExchangesServlet.java rename to framework/src/main/java/org/tron/core/services/http/ListExchangesServlet.java diff --git a/src/main/java/org/tron/core/services/http/ListNodesServlet.java b/framework/src/main/java/org/tron/core/services/http/ListNodesServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ListNodesServlet.java rename to framework/src/main/java/org/tron/core/services/http/ListNodesServlet.java diff --git a/src/main/java/org/tron/core/services/http/ListProposalsServlet.java b/framework/src/main/java/org/tron/core/services/http/ListProposalsServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ListProposalsServlet.java rename to framework/src/main/java/org/tron/core/services/http/ListProposalsServlet.java diff --git a/src/main/java/org/tron/core/services/http/ListWitnessesServlet.java b/framework/src/main/java/org/tron/core/services/http/ListWitnessesServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ListWitnessesServlet.java rename to framework/src/main/java/org/tron/core/services/http/ListWitnessesServlet.java diff --git a/src/main/java/org/tron/core/services/http/ParticipateAssetIssueServlet.java b/framework/src/main/java/org/tron/core/services/http/ParticipateAssetIssueServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ParticipateAssetIssueServlet.java rename to framework/src/main/java/org/tron/core/services/http/ParticipateAssetIssueServlet.java diff --git a/src/main/java/org/tron/core/services/http/ProposalApproveServlet.java b/framework/src/main/java/org/tron/core/services/http/ProposalApproveServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ProposalApproveServlet.java rename to framework/src/main/java/org/tron/core/services/http/ProposalApproveServlet.java diff --git a/src/main/java/org/tron/core/services/http/ProposalCreateServlet.java b/framework/src/main/java/org/tron/core/services/http/ProposalCreateServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ProposalCreateServlet.java rename to framework/src/main/java/org/tron/core/services/http/ProposalCreateServlet.java diff --git a/src/main/java/org/tron/core/services/http/ProposalDeleteServlet.java b/framework/src/main/java/org/tron/core/services/http/ProposalDeleteServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ProposalDeleteServlet.java rename to framework/src/main/java/org/tron/core/services/http/ProposalDeleteServlet.java diff --git a/src/main/java/org/tron/core/services/http/ScanAndMarkNoteByIvkServlet.java b/framework/src/main/java/org/tron/core/services/http/ScanAndMarkNoteByIvkServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ScanAndMarkNoteByIvkServlet.java rename to framework/src/main/java/org/tron/core/services/http/ScanAndMarkNoteByIvkServlet.java diff --git a/src/main/java/org/tron/core/services/http/ScanNoteByIvkServlet.java b/framework/src/main/java/org/tron/core/services/http/ScanNoteByIvkServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ScanNoteByIvkServlet.java rename to framework/src/main/java/org/tron/core/services/http/ScanNoteByIvkServlet.java diff --git a/src/main/java/org/tron/core/services/http/ScanNoteByOvkServlet.java b/framework/src/main/java/org/tron/core/services/http/ScanNoteByOvkServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ScanNoteByOvkServlet.java rename to framework/src/main/java/org/tron/core/services/http/ScanNoteByOvkServlet.java diff --git a/src/main/java/org/tron/core/services/http/SetAccountIdServlet.java b/framework/src/main/java/org/tron/core/services/http/SetAccountIdServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/SetAccountIdServlet.java rename to framework/src/main/java/org/tron/core/services/http/SetAccountIdServlet.java diff --git a/src/main/java/org/tron/core/services/http/TotalTransactionServlet.java b/framework/src/main/java/org/tron/core/services/http/TotalTransactionServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/TotalTransactionServlet.java rename to framework/src/main/java/org/tron/core/services/http/TotalTransactionServlet.java diff --git a/src/main/java/org/tron/core/services/http/TransactionSignServlet.java b/framework/src/main/java/org/tron/core/services/http/TransactionSignServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/TransactionSignServlet.java rename to framework/src/main/java/org/tron/core/services/http/TransactionSignServlet.java diff --git a/src/main/java/org/tron/core/services/http/TransferAssetServlet.java b/framework/src/main/java/org/tron/core/services/http/TransferAssetServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/TransferAssetServlet.java rename to framework/src/main/java/org/tron/core/services/http/TransferAssetServlet.java diff --git a/src/main/java/org/tron/core/services/http/TransferServlet.java b/framework/src/main/java/org/tron/core/services/http/TransferServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/TransferServlet.java rename to framework/src/main/java/org/tron/core/services/http/TransferServlet.java diff --git a/src/main/java/org/tron/core/services/http/TriggerConstantContractServlet.java b/framework/src/main/java/org/tron/core/services/http/TriggerConstantContractServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/TriggerConstantContractServlet.java rename to framework/src/main/java/org/tron/core/services/http/TriggerConstantContractServlet.java diff --git a/src/main/java/org/tron/core/services/http/TriggerSmartContractServlet.java b/framework/src/main/java/org/tron/core/services/http/TriggerSmartContractServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/TriggerSmartContractServlet.java rename to framework/src/main/java/org/tron/core/services/http/TriggerSmartContractServlet.java diff --git a/src/main/java/org/tron/core/services/http/UnFreezeAssetServlet.java b/framework/src/main/java/org/tron/core/services/http/UnFreezeAssetServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/UnFreezeAssetServlet.java rename to framework/src/main/java/org/tron/core/services/http/UnFreezeAssetServlet.java diff --git a/src/main/java/org/tron/core/services/http/UnFreezeBalanceServlet.java b/framework/src/main/java/org/tron/core/services/http/UnFreezeBalanceServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/UnFreezeBalanceServlet.java rename to framework/src/main/java/org/tron/core/services/http/UnFreezeBalanceServlet.java diff --git a/src/main/java/org/tron/core/services/http/UpdateAccountServlet.java b/framework/src/main/java/org/tron/core/services/http/UpdateAccountServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/UpdateAccountServlet.java rename to framework/src/main/java/org/tron/core/services/http/UpdateAccountServlet.java diff --git a/src/main/java/org/tron/core/services/http/UpdateAssetServlet.java b/framework/src/main/java/org/tron/core/services/http/UpdateAssetServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/UpdateAssetServlet.java rename to framework/src/main/java/org/tron/core/services/http/UpdateAssetServlet.java diff --git a/src/main/java/org/tron/core/services/http/UpdateEnergyLimitServlet.java b/framework/src/main/java/org/tron/core/services/http/UpdateEnergyLimitServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/UpdateEnergyLimitServlet.java rename to framework/src/main/java/org/tron/core/services/http/UpdateEnergyLimitServlet.java diff --git a/src/main/java/org/tron/core/services/http/UpdateSettingServlet.java b/framework/src/main/java/org/tron/core/services/http/UpdateSettingServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/UpdateSettingServlet.java rename to framework/src/main/java/org/tron/core/services/http/UpdateSettingServlet.java diff --git a/src/main/java/org/tron/core/services/http/UpdateWitnessServlet.java b/framework/src/main/java/org/tron/core/services/http/UpdateWitnessServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/UpdateWitnessServlet.java rename to framework/src/main/java/org/tron/core/services/http/UpdateWitnessServlet.java diff --git a/src/main/java/org/tron/core/services/http/Util.java b/framework/src/main/java/org/tron/core/services/http/Util.java similarity index 100% rename from src/main/java/org/tron/core/services/http/Util.java rename to framework/src/main/java/org/tron/core/services/http/Util.java diff --git a/src/main/java/org/tron/core/services/http/ValidateAddressServlet.java b/framework/src/main/java/org/tron/core/services/http/ValidateAddressServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/ValidateAddressServlet.java rename to framework/src/main/java/org/tron/core/services/http/ValidateAddressServlet.java diff --git a/src/main/java/org/tron/core/services/http/VoteWitnessAccountServlet.java b/framework/src/main/java/org/tron/core/services/http/VoteWitnessAccountServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/VoteWitnessAccountServlet.java rename to framework/src/main/java/org/tron/core/services/http/VoteWitnessAccountServlet.java diff --git a/src/main/java/org/tron/core/services/http/WithdrawBalanceServlet.java b/framework/src/main/java/org/tron/core/services/http/WithdrawBalanceServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/WithdrawBalanceServlet.java rename to framework/src/main/java/org/tron/core/services/http/WithdrawBalanceServlet.java diff --git a/src/main/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServlet.java b/framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionByIdSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/http/solidity/GetTransactionInfoByIdSolidityServlet.java b/framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionInfoByIdSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/solidity/GetTransactionInfoByIdSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionInfoByIdSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/http/solidity/GetTransactionsFromThisServlet.java b/framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionsFromThisServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/solidity/GetTransactionsFromThisServlet.java rename to framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionsFromThisServlet.java diff --git a/src/main/java/org/tron/core/services/http/solidity/GetTransactionsToThisServlet.java b/framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionsToThisServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/http/solidity/GetTransactionsToThisServlet.java rename to framework/src/main/java/org/tron/core/services/http/solidity/GetTransactionsToThisServlet.java diff --git a/src/main/java/org/tron/core/services/http/solidity/SolidityNodeHttpApiService.java b/framework/src/main/java/org/tron/core/services/http/solidity/SolidityNodeHttpApiService.java similarity index 100% rename from src/main/java/org/tron/core/services/http/solidity/SolidityNodeHttpApiService.java rename to framework/src/main/java/org/tron/core/services/http/solidity/SolidityNodeHttpApiService.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/NodeInfoOnSolidityService.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/NodeInfoOnSolidityService.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/NodeInfoOnSolidityService.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/NodeInfoOnSolidityService.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/RpcApiServiceOnSolidity.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/RpcApiServiceOnSolidity.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/RpcApiServiceOnSolidity.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/RpcApiServiceOnSolidity.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/WalletOnSolidity.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/WalletOnSolidity.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/WalletOnSolidity.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/WalletOnSolidity.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountByIdOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountByIdOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountByIdOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountByIdOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAccountOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByIdOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByIdOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByIdOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByIdOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByNameOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByNameOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByNameOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueByNameOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListByNameOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListByNameOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListByNameOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListByNameOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetAssetIssueListOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByIdOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByIdOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByIdOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByIdOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLatestNumOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLatestNumOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLatestNumOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLatestNumOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLimitNextOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLimitNextOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLimitNextOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByLimitNextOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByNumOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByNumOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByNumOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBlockByNumOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceAccountIndexOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceAccountIndexOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceAccountIndexOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceAccountIndexOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetDelegatedResourceOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetExchangeByIdOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetExchangeByIdOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetExchangeByIdOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetExchangeByIdOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetMerkleTreeVoucherInfoOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetMerkleTreeVoucherInfoOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetMerkleTreeVoucherInfoOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetMerkleTreeVoucherInfoOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNodeInfoOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNodeInfoOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNodeInfoOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNodeInfoOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNowBlockOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNowBlockOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNowBlockOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetNowBlockOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetPaginatedAssetIssueListOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetPaginatedAssetIssueListOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetPaginatedAssetIssueListOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetPaginatedAssetIssueListOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetTransactionCountByBlockNumOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetTransactionCountByBlockNumOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetTransactionCountByBlockNumOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetTransactionCountByBlockNumOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/IsSpendOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/IsSpendOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/IsSpendOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/IsSpendOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListExchangesOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListExchangesOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListExchangesOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListExchangesOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListWitnessesOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListWitnessesOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListWitnessesOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ListWitnessesOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanAndMarkNoteByIvkOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanAndMarkNoteByIvkOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanAndMarkNoteByIvkOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanAndMarkNoteByIvkOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByIvkOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByIvkOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByIvkOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByIvkOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByOvkOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByOvkOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByOvkOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ScanNoteByOvkOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionByIdOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionByIdOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionByIdOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionByIdOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionInfoByIdOnSolidityServlet.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionInfoByIdOnSolidityServlet.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionInfoByIdOnSolidityServlet.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/GetTransactionInfoByIdOnSolidityServlet.java diff --git a/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/HttpApiOnSolidityService.java b/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/HttpApiOnSolidityService.java similarity index 100% rename from src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/HttpApiOnSolidityService.java rename to framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/HttpApiOnSolidityService.java diff --git a/src/main/java/org/tron/core/trie/Trie.java b/framework/src/main/java/org/tron/core/trie/Trie.java similarity index 100% rename from src/main/java/org/tron/core/trie/Trie.java rename to framework/src/main/java/org/tron/core/trie/Trie.java diff --git a/src/main/java/org/tron/core/trie/TrieImpl.java b/framework/src/main/java/org/tron/core/trie/TrieImpl.java similarity index 100% rename from src/main/java/org/tron/core/trie/TrieImpl.java rename to framework/src/main/java/org/tron/core/trie/TrieImpl.java diff --git a/src/main/java/org/tron/core/trie/TrieKey.java b/framework/src/main/java/org/tron/core/trie/TrieKey.java similarity index 100% rename from src/main/java/org/tron/core/trie/TrieKey.java rename to framework/src/main/java/org/tron/core/trie/TrieKey.java diff --git a/src/main/java/org/tron/core/witness/BlockProductionCondition.java b/framework/src/main/java/org/tron/core/witness/BlockProductionCondition.java similarity index 100% rename from src/main/java/org/tron/core/witness/BlockProductionCondition.java rename to framework/src/main/java/org/tron/core/witness/BlockProductionCondition.java diff --git a/src/main/java/org/tron/core/witness/ProposalController.java b/framework/src/main/java/org/tron/core/witness/ProposalController.java similarity index 100% rename from src/main/java/org/tron/core/witness/ProposalController.java rename to framework/src/main/java/org/tron/core/witness/ProposalController.java diff --git a/src/main/java/org/tron/core/witness/WitnessController.java b/framework/src/main/java/org/tron/core/witness/WitnessController.java similarity index 100% rename from src/main/java/org/tron/core/witness/WitnessController.java rename to framework/src/main/java/org/tron/core/witness/WitnessController.java diff --git a/src/main/java/org/tron/core/zen/ZenTransactionBuilder.java b/framework/src/main/java/org/tron/core/zen/ZenTransactionBuilder.java similarity index 100% rename from src/main/java/org/tron/core/zen/ZenTransactionBuilder.java rename to framework/src/main/java/org/tron/core/zen/ZenTransactionBuilder.java diff --git a/src/main/java/org/tron/core/zen/address/DiversifierT.java b/framework/src/main/java/org/tron/core/zen/address/DiversifierT.java similarity index 100% rename from src/main/java/org/tron/core/zen/address/DiversifierT.java rename to framework/src/main/java/org/tron/core/zen/address/DiversifierT.java diff --git a/src/main/java/org/tron/core/zen/address/ExpandedSpendingKey.java b/framework/src/main/java/org/tron/core/zen/address/ExpandedSpendingKey.java similarity index 100% rename from src/main/java/org/tron/core/zen/address/ExpandedSpendingKey.java rename to framework/src/main/java/org/tron/core/zen/address/ExpandedSpendingKey.java diff --git a/src/main/java/org/tron/core/zen/address/FullViewingKey.java b/framework/src/main/java/org/tron/core/zen/address/FullViewingKey.java similarity index 100% rename from src/main/java/org/tron/core/zen/address/FullViewingKey.java rename to framework/src/main/java/org/tron/core/zen/address/FullViewingKey.java diff --git a/src/main/java/org/tron/core/zen/address/IncomingViewingKey.java b/framework/src/main/java/org/tron/core/zen/address/IncomingViewingKey.java similarity index 100% rename from src/main/java/org/tron/core/zen/address/IncomingViewingKey.java rename to framework/src/main/java/org/tron/core/zen/address/IncomingViewingKey.java diff --git a/src/main/java/org/tron/core/zen/address/KeyIo.java b/framework/src/main/java/org/tron/core/zen/address/KeyIo.java similarity index 100% rename from src/main/java/org/tron/core/zen/address/KeyIo.java rename to framework/src/main/java/org/tron/core/zen/address/KeyIo.java diff --git a/src/main/java/org/tron/core/zen/address/PaymentAddress.java b/framework/src/main/java/org/tron/core/zen/address/PaymentAddress.java similarity index 100% rename from src/main/java/org/tron/core/zen/address/PaymentAddress.java rename to framework/src/main/java/org/tron/core/zen/address/PaymentAddress.java diff --git a/src/main/java/org/tron/core/zen/address/SpendingKey.java b/framework/src/main/java/org/tron/core/zen/address/SpendingKey.java similarity index 100% rename from src/main/java/org/tron/core/zen/address/SpendingKey.java rename to framework/src/main/java/org/tron/core/zen/address/SpendingKey.java diff --git a/src/main/java/org/tron/core/zen/merkle/IncrementalMerkleTreeContainer.java b/framework/src/main/java/org/tron/core/zen/merkle/IncrementalMerkleTreeContainer.java similarity index 100% rename from src/main/java/org/tron/core/zen/merkle/IncrementalMerkleTreeContainer.java rename to framework/src/main/java/org/tron/core/zen/merkle/IncrementalMerkleTreeContainer.java diff --git a/src/main/java/org/tron/core/zen/merkle/IncrementalMerkleVoucherContainer.java b/framework/src/main/java/org/tron/core/zen/merkle/IncrementalMerkleVoucherContainer.java similarity index 100% rename from src/main/java/org/tron/core/zen/merkle/IncrementalMerkleVoucherContainer.java rename to framework/src/main/java/org/tron/core/zen/merkle/IncrementalMerkleVoucherContainer.java diff --git a/src/main/java/org/tron/core/zen/merkle/MerkleContainer.java b/framework/src/main/java/org/tron/core/zen/merkle/MerkleContainer.java similarity index 100% rename from src/main/java/org/tron/core/zen/merkle/MerkleContainer.java rename to framework/src/main/java/org/tron/core/zen/merkle/MerkleContainer.java diff --git a/src/main/java/org/tron/core/zen/merkle/MerklePath.java b/framework/src/main/java/org/tron/core/zen/merkle/MerklePath.java similarity index 100% rename from src/main/java/org/tron/core/zen/merkle/MerklePath.java rename to framework/src/main/java/org/tron/core/zen/merkle/MerklePath.java diff --git a/src/main/java/org/tron/core/zen/note/Note.java b/framework/src/main/java/org/tron/core/zen/note/Note.java similarity index 100% rename from src/main/java/org/tron/core/zen/note/Note.java rename to framework/src/main/java/org/tron/core/zen/note/Note.java diff --git a/src/main/java/org/tron/core/zen/note/NoteEncryption.java b/framework/src/main/java/org/tron/core/zen/note/NoteEncryption.java similarity index 100% rename from src/main/java/org/tron/core/zen/note/NoteEncryption.java rename to framework/src/main/java/org/tron/core/zen/note/NoteEncryption.java diff --git a/src/main/java/org/tron/core/zen/note/OutgoingPlaintext.java b/framework/src/main/java/org/tron/core/zen/note/OutgoingPlaintext.java similarity index 100% rename from src/main/java/org/tron/core/zen/note/OutgoingPlaintext.java rename to framework/src/main/java/org/tron/core/zen/note/OutgoingPlaintext.java diff --git a/src/main/java/org/tron/core/zen/note/ZenChainParams.java b/framework/src/main/java/org/tron/core/zen/note/ZenChainParams.java similarity index 100% rename from src/main/java/org/tron/core/zen/note/ZenChainParams.java rename to framework/src/main/java/org/tron/core/zen/note/ZenChainParams.java diff --git a/src/main/java/org/tron/keystore/CipherException.java b/framework/src/main/java/org/tron/keystore/CipherException.java similarity index 100% rename from src/main/java/org/tron/keystore/CipherException.java rename to framework/src/main/java/org/tron/keystore/CipherException.java diff --git a/src/main/java/org/tron/keystore/Credentials.java b/framework/src/main/java/org/tron/keystore/Credentials.java similarity index 100% rename from src/main/java/org/tron/keystore/Credentials.java rename to framework/src/main/java/org/tron/keystore/Credentials.java diff --git a/src/main/java/org/tron/keystore/Wallet.java b/framework/src/main/java/org/tron/keystore/Wallet.java similarity index 100% rename from src/main/java/org/tron/keystore/Wallet.java rename to framework/src/main/java/org/tron/keystore/Wallet.java diff --git a/src/main/java/org/tron/keystore/WalletFile.java b/framework/src/main/java/org/tron/keystore/WalletFile.java similarity index 100% rename from src/main/java/org/tron/keystore/WalletFile.java rename to framework/src/main/java/org/tron/keystore/WalletFile.java diff --git a/src/main/java/org/tron/keystore/WalletUtils.java b/framework/src/main/java/org/tron/keystore/WalletUtils.java similarity index 100% rename from src/main/java/org/tron/keystore/WalletUtils.java rename to framework/src/main/java/org/tron/keystore/WalletUtils.java diff --git a/src/main/java/org/tron/program/DBConvert.java b/framework/src/main/java/org/tron/program/DBConvert.java similarity index 100% rename from src/main/java/org/tron/program/DBConvert.java rename to framework/src/main/java/org/tron/program/DBConvert.java diff --git a/src/main/java/org/tron/program/FullNode.java b/framework/src/main/java/org/tron/program/FullNode.java similarity index 100% rename from src/main/java/org/tron/program/FullNode.java rename to framework/src/main/java/org/tron/program/FullNode.java diff --git a/src/main/java/org/tron/program/KeystoreFactory.java b/framework/src/main/java/org/tron/program/KeystoreFactory.java similarity index 100% rename from src/main/java/org/tron/program/KeystoreFactory.java rename to framework/src/main/java/org/tron/program/KeystoreFactory.java diff --git a/src/main/java/org/tron/program/SolidityNode.java b/framework/src/main/java/org/tron/program/SolidityNode.java similarity index 100% rename from src/main/java/org/tron/program/SolidityNode.java rename to framework/src/main/java/org/tron/program/SolidityNode.java diff --git a/src/main/java/org/tron/program/Version.java b/framework/src/main/java/org/tron/program/Version.java similarity index 100% rename from src/main/java/org/tron/program/Version.java rename to framework/src/main/java/org/tron/program/Version.java diff --git a/src/main/protos/.gitignore b/framework/src/main/protos/.gitignore similarity index 100% rename from src/main/protos/.gitignore rename to framework/src/main/protos/.gitignore diff --git a/src/main/protos/.travis.yml b/framework/src/main/protos/.travis.yml similarity index 100% rename from src/main/protos/.travis.yml rename to framework/src/main/protos/.travis.yml diff --git a/src/main/protos/Chinese version of TRON Protocol document.md b/framework/src/main/protos/Chinese version of TRON Protocol document.md similarity index 100% rename from src/main/protos/Chinese version of TRON Protocol document.md rename to framework/src/main/protos/Chinese version of TRON Protocol document.md diff --git a/src/main/protos/English version of TRON Protocol document.md b/framework/src/main/protos/English version of TRON Protocol document.md similarity index 100% rename from src/main/protos/English version of TRON Protocol document.md rename to framework/src/main/protos/English version of TRON Protocol document.md diff --git a/src/main/protos/LICENSE b/framework/src/main/protos/LICENSE similarity index 100% rename from src/main/protos/LICENSE rename to framework/src/main/protos/LICENSE diff --git a/src/main/protos/README.md b/framework/src/main/protos/README.md similarity index 100% rename from src/main/protos/README.md rename to framework/src/main/protos/README.md diff --git a/src/main/protos/api/api.proto b/framework/src/main/protos/api/api.proto similarity index 100% rename from src/main/protos/api/api.proto rename to framework/src/main/protos/api/api.proto diff --git a/src/main/protos/api/zksnark.proto b/framework/src/main/protos/api/zksnark.proto similarity index 100% rename from src/main/protos/api/zksnark.proto rename to framework/src/main/protos/api/zksnark.proto diff --git a/src/main/protos/core/Contract.proto b/framework/src/main/protos/core/Contract.proto similarity index 100% rename from src/main/protos/core/Contract.proto rename to framework/src/main/protos/core/Contract.proto diff --git a/src/main/protos/core/Discover.proto b/framework/src/main/protos/core/Discover.proto similarity index 100% rename from src/main/protos/core/Discover.proto rename to framework/src/main/protos/core/Discover.proto diff --git a/src/main/protos/core/Tron.proto b/framework/src/main/protos/core/Tron.proto similarity index 100% rename from src/main/protos/core/Tron.proto rename to framework/src/main/protos/core/Tron.proto diff --git a/src/main/protos/core/TronInventoryItems.proto b/framework/src/main/protos/core/TronInventoryItems.proto similarity index 100% rename from src/main/protos/core/TronInventoryItems.proto rename to framework/src/main/protos/core/TronInventoryItems.proto diff --git a/src/main/protos/install-googleapis.sh b/framework/src/main/protos/install-googleapis.sh similarity index 100% rename from src/main/protos/install-googleapis.sh rename to framework/src/main/protos/install-googleapis.sh diff --git a/src/main/protos/install-protobuf.sh b/framework/src/main/protos/install-protobuf.sh similarity index 100% rename from src/main/protos/install-protobuf.sh rename to framework/src/main/protos/install-protobuf.sh diff --git a/src/main/resources/config-backup.conf b/framework/src/main/resources/config-backup.conf similarity index 100% rename from src/main/resources/config-backup.conf rename to framework/src/main/resources/config-backup.conf diff --git a/src/main/resources/config-beta.conf b/framework/src/main/resources/config-beta.conf similarity index 100% rename from src/main/resources/config-beta.conf rename to framework/src/main/resources/config-beta.conf diff --git a/src/main/resources/config-localtest.conf b/framework/src/main/resources/config-localtest.conf similarity index 100% rename from src/main/resources/config-localtest.conf rename to framework/src/main/resources/config-localtest.conf diff --git a/src/main/resources/config-test-net.conf b/framework/src/main/resources/config-test-net.conf similarity index 100% rename from src/main/resources/config-test-net.conf rename to framework/src/main/resources/config-test-net.conf diff --git a/src/main/resources/config.conf b/framework/src/main/resources/config.conf similarity index 100% rename from src/main/resources/config.conf rename to framework/src/main/resources/config.conf diff --git a/src/main/resources/logback.xml b/framework/src/main/resources/logback.xml similarity index 100% rename from src/main/resources/logback.xml rename to framework/src/main/resources/logback.xml diff --git a/src/main/resources/native-package/linux/librustzcash.so b/framework/src/main/resources/native-package/linux/librustzcash.so similarity index 100% rename from src/main/resources/native-package/linux/librustzcash.so rename to framework/src/main/resources/native-package/linux/librustzcash.so diff --git a/src/main/resources/native-package/linux/libsodium.so b/framework/src/main/resources/native-package/linux/libsodium.so similarity index 100% rename from src/main/resources/native-package/linux/libsodium.so rename to framework/src/main/resources/native-package/linux/libsodium.so diff --git a/src/main/resources/native-package/macos/librustzcash.dylib b/framework/src/main/resources/native-package/macos/librustzcash.dylib similarity index 100% rename from src/main/resources/native-package/macos/librustzcash.dylib rename to framework/src/main/resources/native-package/macos/librustzcash.dylib diff --git a/src/main/resources/native-package/macos/libsodium.dylib b/framework/src/main/resources/native-package/macos/libsodium.dylib similarity index 100% rename from src/main/resources/native-package/macos/libsodium.dylib rename to framework/src/main/resources/native-package/macos/libsodium.dylib diff --git a/src/main/resources/params/README b/framework/src/main/resources/params/README similarity index 100% rename from src/main/resources/params/README rename to framework/src/main/resources/params/README diff --git a/src/main/resources/params/sapling-output.params b/framework/src/main/resources/params/sapling-output.params similarity index 100% rename from src/main/resources/params/sapling-output.params rename to framework/src/main/resources/params/sapling-output.params diff --git a/src/main/resources/params/sapling-spend.params b/framework/src/main/resources/params/sapling-spend.params similarity index 100% rename from src/main/resources/params/sapling-spend.params rename to framework/src/main/resources/params/sapling-spend.params diff --git a/src/test/java/org/tron/common/ComparatorTest.java b/framework/src/test/java/org/tron/common/ComparatorTest.java similarity index 100% rename from src/test/java/org/tron/common/ComparatorTest.java rename to framework/src/test/java/org/tron/common/ComparatorTest.java diff --git a/src/test/java/org/tron/common/command/CliTest.java b/framework/src/test/java/org/tron/common/command/CliTest.java similarity index 100% rename from src/test/java/org/tron/common/command/CliTest.java rename to framework/src/test/java/org/tron/common/command/CliTest.java diff --git a/src/test/java/org/tron/common/crypto/ECKeyTest.java b/framework/src/test/java/org/tron/common/crypto/ECKeyTest.java similarity index 100% rename from src/test/java/org/tron/common/crypto/ECKeyTest.java rename to framework/src/test/java/org/tron/common/crypto/ECKeyTest.java diff --git a/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java b/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java similarity index 100% rename from src/test/java/org/tron/common/logsfilter/EventLoaderTest.java rename to framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java diff --git a/src/test/java/org/tron/common/logsfilter/EventParserJsonTest.java b/framework/src/test/java/org/tron/common/logsfilter/EventParserJsonTest.java similarity index 100% rename from src/test/java/org/tron/common/logsfilter/EventParserJsonTest.java rename to framework/src/test/java/org/tron/common/logsfilter/EventParserJsonTest.java diff --git a/src/test/java/org/tron/common/logsfilter/EventParserTest.java b/framework/src/test/java/org/tron/common/logsfilter/EventParserTest.java similarity index 100% rename from src/test/java/org/tron/common/logsfilter/EventParserTest.java rename to framework/src/test/java/org/tron/common/logsfilter/EventParserTest.java diff --git a/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java b/framework/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java similarity index 100% rename from src/test/java/org/tron/common/logsfilter/FilterQueryTest.java rename to framework/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java diff --git a/src/test/java/org/tron/common/logsfilter/NativeMessageQueueTest.java b/framework/src/test/java/org/tron/common/logsfilter/NativeMessageQueueTest.java similarity index 100% rename from src/test/java/org/tron/common/logsfilter/NativeMessageQueueTest.java rename to framework/src/test/java/org/tron/common/logsfilter/NativeMessageQueueTest.java diff --git a/src/test/java/org/tron/common/runtime/InheritanceTest.java b/framework/src/test/java/org/tron/common/runtime/InheritanceTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/InheritanceTest.java rename to framework/src/test/java/org/tron/common/runtime/InheritanceTest.java diff --git a/src/test/java/org/tron/common/runtime/InternalTransactionComplexTest.java b/framework/src/test/java/org/tron/common/runtime/InternalTransactionComplexTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/InternalTransactionComplexTest.java rename to framework/src/test/java/org/tron/common/runtime/InternalTransactionComplexTest.java diff --git a/src/test/java/org/tron/common/runtime/ProgramResultTest.java b/framework/src/test/java/org/tron/common/runtime/ProgramResultTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/ProgramResultTest.java rename to framework/src/test/java/org/tron/common/runtime/ProgramResultTest.java diff --git a/src/test/java/org/tron/common/runtime/RuntimeImplTest.java b/framework/src/test/java/org/tron/common/runtime/RuntimeImplTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/RuntimeImplTest.java rename to framework/src/test/java/org/tron/common/runtime/RuntimeImplTest.java diff --git a/src/test/java/org/tron/common/runtime/RuntimeTransferComplexTest.java b/framework/src/test/java/org/tron/common/runtime/RuntimeTransferComplexTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/RuntimeTransferComplexTest.java rename to framework/src/test/java/org/tron/common/runtime/RuntimeTransferComplexTest.java diff --git a/src/test/java/org/tron/common/runtime/TVMTestResult.java b/framework/src/test/java/org/tron/common/runtime/TVMTestResult.java similarity index 100% rename from src/test/java/org/tron/common/runtime/TVMTestResult.java rename to framework/src/test/java/org/tron/common/runtime/TVMTestResult.java diff --git a/src/test/java/org/tron/common/runtime/TvmTestUtils.java b/framework/src/test/java/org/tron/common/runtime/TvmTestUtils.java similarity index 100% rename from src/test/java/org/tron/common/runtime/TvmTestUtils.java rename to framework/src/test/java/org/tron/common/runtime/TvmTestUtils.java diff --git a/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/ChargeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/ChargeTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/ChargeTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/ChargeTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/Create2Test.java b/framework/src/test/java/org/tron/common/runtime/vm/Create2Test.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/Create2Test.java rename to framework/src/test/java/org/tron/common/runtime/vm/Create2Test.java diff --git a/src/test/java/org/tron/common/runtime/vm/CreateContractSuicideTest.java b/framework/src/test/java/org/tron/common/runtime/vm/CreateContractSuicideTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/CreateContractSuicideTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/CreateContractSuicideTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/DataWordTest.java b/framework/src/test/java/org/tron/common/runtime/vm/DataWordTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/DataWordTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/DataWordTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/DepositTest.java b/framework/src/test/java/org/tron/common/runtime/vm/DepositTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/DepositTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/DepositTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/EnergyWhenAssertStyleTest.java b/framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenAssertStyleTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/EnergyWhenAssertStyleTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenAssertStyleTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/EnergyWhenRequireStyleTest.java b/framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenRequireStyleTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/EnergyWhenRequireStyleTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenRequireStyleTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/EnergyWhenSendAndTransferTest.java b/framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenSendAndTransferTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/EnergyWhenSendAndTransferTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenSendAndTransferTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/EnergyWhenTimeoutStyleTest.java b/framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenTimeoutStyleTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/EnergyWhenTimeoutStyleTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/EnergyWhenTimeoutStyleTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java b/framework/src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/ExtCodeHashTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/InternalTransactionCallTest.java b/framework/src/test/java/org/tron/common/runtime/vm/InternalTransactionCallTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/InternalTransactionCallTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/InternalTransactionCallTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/InterpreterTest.java b/framework/src/test/java/org/tron/common/runtime/vm/InterpreterTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/InterpreterTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/InterpreterTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/IsContractTest.java b/framework/src/test/java/org/tron/common/runtime/vm/IsContractTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/IsContractTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/IsContractTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/MemoryTest.java b/framework/src/test/java/org/tron/common/runtime/vm/MemoryTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/MemoryTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/MemoryTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/MultiValidateSignContractTest.java b/framework/src/test/java/org/tron/common/runtime/vm/MultiValidateSignContractTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/MultiValidateSignContractTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/MultiValidateSignContractTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java b/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/StorageTest.java b/framework/src/test/java/org/tron/common/runtime/vm/StorageTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/StorageTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/StorageTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/TimeBenchmarkTest.java b/framework/src/test/java/org/tron/common/runtime/vm/TimeBenchmarkTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/TimeBenchmarkTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/TimeBenchmarkTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java b/framework/src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/TransferFailedEnergyTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/TransferTokenTest.java b/framework/src/test/java/org/tron/common/runtime/vm/TransferTokenTest.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/TransferTokenTest.java rename to framework/src/test/java/org/tron/common/runtime/vm/TransferTokenTest.java diff --git a/src/test/java/org/tron/common/runtime/vm/VMTestBase.java b/framework/src/test/java/org/tron/common/runtime/vm/VMTestBase.java similarity index 100% rename from src/test/java/org/tron/common/runtime/vm/VMTestBase.java rename to framework/src/test/java/org/tron/common/runtime/vm/VMTestBase.java diff --git a/src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java b/framework/src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java similarity index 100% rename from src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java rename to framework/src/test/java/org/tron/common/storage/leveldb/LevelDbDataSourceImplTest.java diff --git a/src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java b/framework/src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java similarity index 100% rename from src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java rename to framework/src/test/java/org/tron/common/storage/leveldb/RocksDbDataSourceImplTest.java diff --git a/src/test/java/org/tron/common/utils/ByteArrayTest.java b/framework/src/test/java/org/tron/common/utils/ByteArrayTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/ByteArrayTest.java rename to framework/src/test/java/org/tron/common/utils/ByteArrayTest.java diff --git a/src/test/java/org/tron/common/utils/ByteString.java b/framework/src/test/java/org/tron/common/utils/ByteString.java similarity index 100% rename from src/test/java/org/tron/common/utils/ByteString.java rename to framework/src/test/java/org/tron/common/utils/ByteString.java diff --git a/src/test/java/org/tron/common/utils/FileUtilTest.java b/framework/src/test/java/org/tron/common/utils/FileUtilTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/FileUtilTest.java rename to framework/src/test/java/org/tron/common/utils/FileUtilTest.java diff --git a/src/test/java/org/tron/common/utils/LoggerTest.java b/framework/src/test/java/org/tron/common/utils/LoggerTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/LoggerTest.java rename to framework/src/test/java/org/tron/common/utils/LoggerTest.java diff --git a/src/test/java/org/tron/common/utils/ObjectSizeUtilTest.java b/framework/src/test/java/org/tron/common/utils/ObjectSizeUtilTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/ObjectSizeUtilTest.java rename to framework/src/test/java/org/tron/common/utils/ObjectSizeUtilTest.java diff --git a/src/test/java/org/tron/common/utils/PropUtilTest.java b/framework/src/test/java/org/tron/common/utils/PropUtilTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/PropUtilTest.java rename to framework/src/test/java/org/tron/common/utils/PropUtilTest.java diff --git a/src/test/java/org/tron/common/utils/RandomGeneratorTest.java b/framework/src/test/java/org/tron/common/utils/RandomGeneratorTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/RandomGeneratorTest.java rename to framework/src/test/java/org/tron/common/utils/RandomGeneratorTest.java diff --git a/src/test/java/org/tron/common/utils/ReflectUtils.java b/framework/src/test/java/org/tron/common/utils/ReflectUtils.java similarity index 100% rename from src/test/java/org/tron/common/utils/ReflectUtils.java rename to framework/src/test/java/org/tron/common/utils/ReflectUtils.java diff --git a/src/test/java/org/tron/common/utils/Sha256HashTest.java b/framework/src/test/java/org/tron/common/utils/Sha256HashTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/Sha256HashTest.java rename to framework/src/test/java/org/tron/common/utils/Sha256HashTest.java diff --git a/src/test/java/org/tron/common/utils/TypeConversionTest.java b/framework/src/test/java/org/tron/common/utils/TypeConversionTest.java similarity index 100% rename from src/test/java/org/tron/common/utils/TypeConversionTest.java rename to framework/src/test/java/org/tron/common/utils/TypeConversionTest.java diff --git a/src/test/java/org/tron/core/BandwidthProcessorTest.java b/framework/src/test/java/org/tron/core/BandwidthProcessorTest.java similarity index 100% rename from src/test/java/org/tron/core/BandwidthProcessorTest.java rename to framework/src/test/java/org/tron/core/BandwidthProcessorTest.java diff --git a/src/test/java/org/tron/core/BlockCapsuleTest.java b/framework/src/test/java/org/tron/core/BlockCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/BlockCapsuleTest.java rename to framework/src/test/java/org/tron/core/BlockCapsuleTest.java diff --git a/src/test/java/org/tron/core/BlockUtilTest.java b/framework/src/test/java/org/tron/core/BlockUtilTest.java similarity index 100% rename from src/test/java/org/tron/core/BlockUtilTest.java rename to framework/src/test/java/org/tron/core/BlockUtilTest.java diff --git a/src/test/java/org/tron/core/EnergyProcessorTest.java b/framework/src/test/java/org/tron/core/EnergyProcessorTest.java similarity index 100% rename from src/test/java/org/tron/core/EnergyProcessorTest.java rename to framework/src/test/java/org/tron/core/EnergyProcessorTest.java diff --git a/src/test/java/org/tron/core/StorageMarketTest.java b/framework/src/test/java/org/tron/core/StorageMarketTest.java similarity index 100% rename from src/test/java/org/tron/core/StorageMarketTest.java rename to framework/src/test/java/org/tron/core/StorageMarketTest.java diff --git a/src/test/java/org/tron/core/TransactionCapsuleTest.java b/framework/src/test/java/org/tron/core/TransactionCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/TransactionCapsuleTest.java rename to framework/src/test/java/org/tron/core/TransactionCapsuleTest.java diff --git a/src/test/java/org/tron/core/TxInputCapsuleTest.java b/framework/src/test/java/org/tron/core/TxInputCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/TxInputCapsuleTest.java rename to framework/src/test/java/org/tron/core/TxInputCapsuleTest.java diff --git a/src/test/java/org/tron/core/TxInputUtilTest.java b/framework/src/test/java/org/tron/core/TxInputUtilTest.java similarity index 100% rename from src/test/java/org/tron/core/TxInputUtilTest.java rename to framework/src/test/java/org/tron/core/TxInputUtilTest.java diff --git a/src/test/java/org/tron/core/TxOutputCapsuleTest.java b/framework/src/test/java/org/tron/core/TxOutputCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/TxOutputCapsuleTest.java rename to framework/src/test/java/org/tron/core/TxOutputCapsuleTest.java diff --git a/src/test/java/org/tron/core/TxOutputUtilTest.java b/framework/src/test/java/org/tron/core/TxOutputUtilTest.java similarity index 100% rename from src/test/java/org/tron/core/TxOutputUtilTest.java rename to framework/src/test/java/org/tron/core/TxOutputUtilTest.java diff --git a/src/test/java/org/tron/core/WalletTest.java b/framework/src/test/java/org/tron/core/WalletTest.java similarity index 100% rename from src/test/java/org/tron/core/WalletTest.java rename to framework/src/test/java/org/tron/core/WalletTest.java diff --git a/src/test/java/org/tron/core/actuator/AccountPermissionUpdateActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/AccountPermissionUpdateActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/AccountPermissionUpdateActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/AccountPermissionUpdateActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/AssetIssueActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/BuyStorageActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/BuyStorageActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/BuyStorageActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/BuyStorageActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/BuyStorageBytesActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/BuyStorageBytesActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/BuyStorageBytesActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/BuyStorageBytesActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ClearABIContractActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ClearABIContractActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ClearABIContractActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ClearABIContractActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/CreateAccountActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/CreateAccountActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/CreateAccountActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/CreateAccountActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ExchangeCreateActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ExchangeInjectActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ExchangeTransactionActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ExchangeWithdrawActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/FreezeBalanceActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/FreezeBalanceActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/FreezeBalanceActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/FreezeBalanceActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ParticipateAssetIssueActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ProposalApproveActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ProposalApproveActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ProposalApproveActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ProposalApproveActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ProposalCreateActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ProposalDeleteActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ProposalDeleteActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ProposalDeleteActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ProposalDeleteActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/SellStorageActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/SellStorageActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/SellStorageActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/SellStorageActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/SetAccountIdActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/SetAccountIdActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/SetAccountIdActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/SetAccountIdActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/ShieldedTransferActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/ShieldedTransferActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/ShieldedTransferActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/ShieldedTransferActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/TransferActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/TransferActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/TransferActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/TransferActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/TransferAssetActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/TransferAssetActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/TransferAssetActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/TransferAssetActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/UnfreezeAssetActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UnfreezeAssetActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/UnfreezeAssetActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/UnfreezeAssetActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/UnfreezeBalanceActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/UpdateAccountActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UpdateAccountActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/UpdateAccountActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/UpdateAccountActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/UpdateAssetActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UpdateAssetActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/UpdateAssetActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/UpdateAssetActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/UpdateEnergyLimitContractActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UpdateEnergyLimitContractActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/UpdateEnergyLimitContractActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/UpdateEnergyLimitContractActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/UpdateSettingContractActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/VoteWitnessActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/WithdrawBalanceActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/WithdrawBalanceActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/WithdrawBalanceActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/WithdrawBalanceActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/WitnessCreateActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/WitnessCreateActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/WitnessCreateActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/WitnessCreateActuatorTest.java diff --git a/src/test/java/org/tron/core/actuator/WitnessUpdateActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/WitnessUpdateActuatorTest.java similarity index 100% rename from src/test/java/org/tron/core/actuator/WitnessUpdateActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/WitnessUpdateActuatorTest.java diff --git a/src/test/java/org/tron/core/capsule/AccountCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/AccountCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/capsule/AccountCapsuleTest.java rename to framework/src/test/java/org/tron/core/capsule/AccountCapsuleTest.java diff --git a/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/capsule/BlockCapsuleTest.java rename to framework/src/test/java/org/tron/core/capsule/BlockCapsuleTest.java diff --git a/src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java rename to framework/src/test/java/org/tron/core/capsule/ExchangeCapsuleTest.java diff --git a/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java rename to framework/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java diff --git a/src/test/java/org/tron/core/capsule/VotesCapsuleTest.java b/framework/src/test/java/org/tron/core/capsule/VotesCapsuleTest.java similarity index 100% rename from src/test/java/org/tron/core/capsule/VotesCapsuleTest.java rename to framework/src/test/java/org/tron/core/capsule/VotesCapsuleTest.java diff --git a/src/test/java/org/tron/core/capsule/utils/BlockUtil.java b/framework/src/test/java/org/tron/core/capsule/utils/BlockUtil.java similarity index 100% rename from src/test/java/org/tron/core/capsule/utils/BlockUtil.java rename to framework/src/test/java/org/tron/core/capsule/utils/BlockUtil.java diff --git a/src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java b/framework/src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java similarity index 100% rename from src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java rename to framework/src/test/java/org/tron/core/capsule/utils/ExchangeProcessorTest.java diff --git a/src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java b/framework/src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java similarity index 100% rename from src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java rename to framework/src/test/java/org/tron/core/capsule/utils/MerkleTreeTest.java diff --git a/src/test/java/org/tron/core/config/ConfigurationTest.java b/framework/src/test/java/org/tron/core/config/ConfigurationTest.java similarity index 100% rename from src/test/java/org/tron/core/config/ConfigurationTest.java rename to framework/src/test/java/org/tron/core/config/ConfigurationTest.java diff --git a/src/test/java/org/tron/core/config/args/AccountTest.java b/framework/src/test/java/org/tron/core/config/args/AccountTest.java similarity index 100% rename from src/test/java/org/tron/core/config/args/AccountTest.java rename to framework/src/test/java/org/tron/core/config/args/AccountTest.java diff --git a/src/test/java/org/tron/core/config/args/ArgsTest.java b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java similarity index 100% rename from src/test/java/org/tron/core/config/args/ArgsTest.java rename to framework/src/test/java/org/tron/core/config/args/ArgsTest.java diff --git a/src/test/java/org/tron/core/config/args/GenesisBlockTest.java b/framework/src/test/java/org/tron/core/config/args/GenesisBlockTest.java similarity index 100% rename from src/test/java/org/tron/core/config/args/GenesisBlockTest.java rename to framework/src/test/java/org/tron/core/config/args/GenesisBlockTest.java diff --git a/src/test/java/org/tron/core/config/args/LocalWitnessTest.java b/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java similarity index 100% rename from src/test/java/org/tron/core/config/args/LocalWitnessTest.java rename to framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java diff --git a/src/test/java/org/tron/core/config/args/OverlayTest.java b/framework/src/test/java/org/tron/core/config/args/OverlayTest.java similarity index 100% rename from src/test/java/org/tron/core/config/args/OverlayTest.java rename to framework/src/test/java/org/tron/core/config/args/OverlayTest.java diff --git a/src/test/java/org/tron/core/config/args/StorageTest.java b/framework/src/test/java/org/tron/core/config/args/StorageTest.java similarity index 100% rename from src/test/java/org/tron/core/config/args/StorageTest.java rename to framework/src/test/java/org/tron/core/config/args/StorageTest.java diff --git a/src/test/java/org/tron/core/config/args/WitnessTest.java b/framework/src/test/java/org/tron/core/config/args/WitnessTest.java similarity index 100% rename from src/test/java/org/tron/core/config/args/WitnessTest.java rename to framework/src/test/java/org/tron/core/config/args/WitnessTest.java diff --git a/src/test/java/org/tron/core/consensus/client/ReadIp.java b/framework/src/test/java/org/tron/core/consensus/client/ReadIp.java similarity index 100% rename from src/test/java/org/tron/core/consensus/client/ReadIp.java rename to framework/src/test/java/org/tron/core/consensus/client/ReadIp.java diff --git a/src/test/java/org/tron/core/consensus/server/TronTest.java b/framework/src/test/java/org/tron/core/consensus/server/TronTest.java similarity index 100% rename from src/test/java/org/tron/core/consensus/server/TronTest.java rename to framework/src/test/java/org/tron/core/consensus/server/TronTest.java diff --git a/src/test/java/org/tron/core/db/AccountIdIndexStoreTest.java b/framework/src/test/java/org/tron/core/db/AccountIdIndexStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/AccountIdIndexStoreTest.java rename to framework/src/test/java/org/tron/core/db/AccountIdIndexStoreTest.java diff --git a/src/test/java/org/tron/core/db/AccountStoreTest.java b/framework/src/test/java/org/tron/core/db/AccountStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/AccountStoreTest.java rename to framework/src/test/java/org/tron/core/db/AccountStoreTest.java diff --git a/src/test/java/org/tron/core/db/BlockFilledSlotsTest.java b/framework/src/test/java/org/tron/core/db/BlockFilledSlotsTest.java similarity index 100% rename from src/test/java/org/tron/core/db/BlockFilledSlotsTest.java rename to framework/src/test/java/org/tron/core/db/BlockFilledSlotsTest.java diff --git a/src/test/java/org/tron/core/db/BlockStoreTest.java b/framework/src/test/java/org/tron/core/db/BlockStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/BlockStoreTest.java rename to framework/src/test/java/org/tron/core/db/BlockStoreTest.java diff --git a/src/test/java/org/tron/core/db/KhaosDatabaseTest.java b/framework/src/test/java/org/tron/core/db/KhaosDatabaseTest.java similarity index 100% rename from src/test/java/org/tron/core/db/KhaosDatabaseTest.java rename to framework/src/test/java/org/tron/core/db/KhaosDatabaseTest.java diff --git a/src/test/java/org/tron/core/db/ManagerForTest.java b/framework/src/test/java/org/tron/core/db/ManagerForTest.java similarity index 100% rename from src/test/java/org/tron/core/db/ManagerForTest.java rename to framework/src/test/java/org/tron/core/db/ManagerForTest.java diff --git a/src/test/java/org/tron/core/db/ManagerTest.java b/framework/src/test/java/org/tron/core/db/ManagerTest.java similarity index 100% rename from src/test/java/org/tron/core/db/ManagerTest.java rename to framework/src/test/java/org/tron/core/db/ManagerTest.java diff --git a/src/test/java/org/tron/core/db/NullifierStoreTest.java b/framework/src/test/java/org/tron/core/db/NullifierStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/NullifierStoreTest.java rename to framework/src/test/java/org/tron/core/db/NullifierStoreTest.java diff --git a/src/test/java/org/tron/core/db/TransactionHistoryTest.java b/framework/src/test/java/org/tron/core/db/TransactionHistoryTest.java similarity index 100% rename from src/test/java/org/tron/core/db/TransactionHistoryTest.java rename to framework/src/test/java/org/tron/core/db/TransactionHistoryTest.java diff --git a/src/test/java/org/tron/core/db/TransactionRetStoreTest.java b/framework/src/test/java/org/tron/core/db/TransactionRetStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/TransactionRetStoreTest.java rename to framework/src/test/java/org/tron/core/db/TransactionRetStoreTest.java diff --git a/src/test/java/org/tron/core/db/TransactionStoreTest.java b/framework/src/test/java/org/tron/core/db/TransactionStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/TransactionStoreTest.java rename to framework/src/test/java/org/tron/core/db/TransactionStoreTest.java diff --git a/src/test/java/org/tron/core/db/TransactionTraceTest.java b/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java similarity index 100% rename from src/test/java/org/tron/core/db/TransactionTraceTest.java rename to framework/src/test/java/org/tron/core/db/TransactionTraceTest.java diff --git a/src/test/java/org/tron/core/db/VotesStoreTest.java b/framework/src/test/java/org/tron/core/db/VotesStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/VotesStoreTest.java rename to framework/src/test/java/org/tron/core/db/VotesStoreTest.java diff --git a/src/test/java/org/tron/core/db/WitnessStoreTest.java b/framework/src/test/java/org/tron/core/db/WitnessStoreTest.java similarity index 100% rename from src/test/java/org/tron/core/db/WitnessStoreTest.java rename to framework/src/test/java/org/tron/core/db/WitnessStoreTest.java diff --git a/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java b/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java similarity index 100% rename from src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java rename to framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java diff --git a/src/test/java/org/tron/core/db/api/IndexHelperTest.java b/framework/src/test/java/org/tron/core/db/api/IndexHelperTest.java similarity index 100% rename from src/test/java/org/tron/core/db/api/IndexHelperTest.java rename to framework/src/test/java/org/tron/core/db/api/IndexHelperTest.java diff --git a/src/test/java/org/tron/core/db/api/StoreAPITest.java b/framework/src/test/java/org/tron/core/db/api/StoreAPITest.java similarity index 100% rename from src/test/java/org/tron/core/db/api/StoreAPITest.java rename to framework/src/test/java/org/tron/core/db/api/StoreAPITest.java diff --git a/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java b/framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java similarity index 100% rename from src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java rename to framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java diff --git a/src/test/java/org/tron/core/db2/RevokingDbWithCacheNewValueTest.java b/framework/src/test/java/org/tron/core/db2/RevokingDbWithCacheNewValueTest.java similarity index 100% rename from src/test/java/org/tron/core/db2/RevokingDbWithCacheNewValueTest.java rename to framework/src/test/java/org/tron/core/db2/RevokingDbWithCacheNewValueTest.java diff --git a/src/test/java/org/tron/core/db2/RevokingDbWithCacheOldValueTest.java b/framework/src/test/java/org/tron/core/db2/RevokingDbWithCacheOldValueTest.java similarity index 100% rename from src/test/java/org/tron/core/db2/RevokingDbWithCacheOldValueTest.java rename to framework/src/test/java/org/tron/core/db2/RevokingDbWithCacheOldValueTest.java diff --git a/src/test/java/org/tron/core/db2/SnapshotManagerTest.java b/framework/src/test/java/org/tron/core/db2/SnapshotManagerTest.java similarity index 100% rename from src/test/java/org/tron/core/db2/SnapshotManagerTest.java rename to framework/src/test/java/org/tron/core/db2/SnapshotManagerTest.java diff --git a/src/test/java/org/tron/core/db2/SnapshotRootTest.java b/framework/src/test/java/org/tron/core/db2/SnapshotRootTest.java similarity index 100% rename from src/test/java/org/tron/core/db2/SnapshotRootTest.java rename to framework/src/test/java/org/tron/core/db2/SnapshotRootTest.java diff --git a/src/test/java/org/tron/core/net/BaseNet.java b/framework/src/test/java/org/tron/core/net/BaseNet.java similarity index 100% rename from src/test/java/org/tron/core/net/BaseNet.java rename to framework/src/test/java/org/tron/core/net/BaseNet.java diff --git a/src/test/java/org/tron/core/net/BaseNetTest.java b/framework/src/test/java/org/tron/core/net/BaseNetTest.java similarity index 100% rename from src/test/java/org/tron/core/net/BaseNetTest.java rename to framework/src/test/java/org/tron/core/net/BaseNetTest.java diff --git a/src/test/java/org/tron/core/net/DisconnectMessageTest.java b/framework/src/test/java/org/tron/core/net/DisconnectMessageTest.java similarity index 100% rename from src/test/java/org/tron/core/net/DisconnectMessageTest.java rename to framework/src/test/java/org/tron/core/net/DisconnectMessageTest.java diff --git a/src/test/java/org/tron/core/net/MessageTest.java b/framework/src/test/java/org/tron/core/net/MessageTest.java similarity index 100% rename from src/test/java/org/tron/core/net/MessageTest.java rename to framework/src/test/java/org/tron/core/net/MessageTest.java diff --git a/src/test/java/org/tron/core/net/TcpTest.java b/framework/src/test/java/org/tron/core/net/TcpTest.java similarity index 100% rename from src/test/java/org/tron/core/net/TcpTest.java rename to framework/src/test/java/org/tron/core/net/TcpTest.java diff --git a/src/test/java/org/tron/core/net/UdpTest.java b/framework/src/test/java/org/tron/core/net/UdpTest.java similarity index 100% rename from src/test/java/org/tron/core/net/UdpTest.java rename to framework/src/test/java/org/tron/core/net/UdpTest.java diff --git a/src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java similarity index 100% rename from src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java rename to framework/src/test/java/org/tron/core/net/messagehandler/BlockMsgHandlerTest.java diff --git a/src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java similarity index 100% rename from src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java rename to framework/src/test/java/org/tron/core/net/messagehandler/ChainInventoryMsgHandlerTest.java diff --git a/src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java similarity index 100% rename from src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java rename to framework/src/test/java/org/tron/core/net/messagehandler/FetchInvDataMsgHandlerTest.java diff --git a/src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java similarity index 100% rename from src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java rename to framework/src/test/java/org/tron/core/net/messagehandler/InventoryMsgHandlerTest.java diff --git a/src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java b/framework/src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java similarity index 100% rename from src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java rename to framework/src/test/java/org/tron/core/net/messagehandler/SyncBlockChainMsgHandlerTest.java diff --git a/src/test/java/org/tron/core/net/services/AdvServiceTest.java b/framework/src/test/java/org/tron/core/net/services/AdvServiceTest.java similarity index 100% rename from src/test/java/org/tron/core/net/services/AdvServiceTest.java rename to framework/src/test/java/org/tron/core/net/services/AdvServiceTest.java diff --git a/src/test/java/org/tron/core/services/NodeInfoServiceTest.java b/framework/src/test/java/org/tron/core/services/NodeInfoServiceTest.java similarity index 100% rename from src/test/java/org/tron/core/services/NodeInfoServiceTest.java rename to framework/src/test/java/org/tron/core/services/NodeInfoServiceTest.java diff --git a/src/test/java/org/tron/core/tire/TrieTest.java b/framework/src/test/java/org/tron/core/tire/TrieTest.java similarity index 100% rename from src/test/java/org/tron/core/tire/TrieTest.java rename to framework/src/test/java/org/tron/core/tire/TrieTest.java diff --git a/src/test/java/org/tron/core/witness/ProposalControllerTest.java b/framework/src/test/java/org/tron/core/witness/ProposalControllerTest.java similarity index 100% rename from src/test/java/org/tron/core/witness/ProposalControllerTest.java rename to framework/src/test/java/org/tron/core/witness/ProposalControllerTest.java diff --git a/src/test/java/org/tron/core/witness/WitnessControllerTest.java b/framework/src/test/java/org/tron/core/witness/WitnessControllerTest.java similarity index 100% rename from src/test/java/org/tron/core/witness/WitnessControllerTest.java rename to framework/src/test/java/org/tron/core/witness/WitnessControllerTest.java diff --git a/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java b/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java similarity index 100% rename from src/test/java/org/tron/core/zksnark/LibrustzcashTest.java rename to framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java diff --git a/src/test/java/org/tron/core/zksnark/MerkleContainerTest.java b/framework/src/test/java/org/tron/core/zksnark/MerkleContainerTest.java similarity index 100% rename from src/test/java/org/tron/core/zksnark/MerkleContainerTest.java rename to framework/src/test/java/org/tron/core/zksnark/MerkleContainerTest.java diff --git a/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java b/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java similarity index 100% rename from src/test/java/org/tron/core/zksnark/MerkleTreeTest.java rename to framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java diff --git a/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java b/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java similarity index 100% rename from src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java rename to framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java diff --git a/src/test/java/org/tron/core/zksnark/SaplingNoteTest.java b/framework/src/test/java/org/tron/core/zksnark/SaplingNoteTest.java similarity index 100% rename from src/test/java/org/tron/core/zksnark/SaplingNoteTest.java rename to framework/src/test/java/org/tron/core/zksnark/SaplingNoteTest.java diff --git a/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java b/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java similarity index 100% rename from src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java rename to framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java diff --git a/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java b/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java similarity index 100% rename from src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java rename to framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java diff --git a/src/test/java/org/tron/program/AccountVoteWitnessTest.java b/framework/src/test/java/org/tron/program/AccountVoteWitnessTest.java similarity index 100% rename from src/test/java/org/tron/program/AccountVoteWitnessTest.java rename to framework/src/test/java/org/tron/program/AccountVoteWitnessTest.java diff --git a/src/test/java/org/tron/program/SolidityNodeTest.java b/framework/src/test/java/org/tron/program/SolidityNodeTest.java similarity index 100% rename from src/test/java/org/tron/program/SolidityNodeTest.java rename to framework/src/test/java/org/tron/program/SolidityNodeTest.java diff --git a/src/test/resources/config-test-dbbackup.conf b/framework/src/test/resources/config-test-dbbackup.conf similarity index 100% rename from src/test/resources/config-test-dbbackup.conf rename to framework/src/test/resources/config-test-dbbackup.conf diff --git a/src/test/resources/config-test-index.conf b/framework/src/test/resources/config-test-index.conf similarity index 100% rename from src/test/resources/config-test-index.conf rename to framework/src/test/resources/config-test-index.conf diff --git a/src/test/resources/config-test-mainnet.conf b/framework/src/test/resources/config-test-mainnet.conf similarity index 100% rename from src/test/resources/config-test-mainnet.conf rename to framework/src/test/resources/config-test-mainnet.conf diff --git a/src/test/resources/config-test-storagetest.conf b/framework/src/test/resources/config-test-storagetest.conf similarity index 100% rename from src/test/resources/config-test-storagetest.conf rename to framework/src/test/resources/config-test-storagetest.conf diff --git a/src/test/resources/config-test.conf b/framework/src/test/resources/config-test.conf similarity index 100% rename from src/test/resources/config-test.conf rename to framework/src/test/resources/config-test.conf diff --git a/src/test/resources/daily-build.xml b/framework/src/test/resources/daily-build.xml similarity index 100% rename from src/test/resources/daily-build.xml rename to framework/src/test/resources/daily-build.xml diff --git a/src/test/resources/json/merkle_commitments_sapling.json b/framework/src/test/resources/json/merkle_commitments_sapling.json similarity index 100% rename from src/test/resources/json/merkle_commitments_sapling.json rename to framework/src/test/resources/json/merkle_commitments_sapling.json diff --git a/src/test/resources/json/merkle_path_sapling.json b/framework/src/test/resources/json/merkle_path_sapling.json similarity index 100% rename from src/test/resources/json/merkle_path_sapling.json rename to framework/src/test/resources/json/merkle_path_sapling.json diff --git a/src/test/resources/json/merkle_roots_empty_sapling.json b/framework/src/test/resources/json/merkle_roots_empty_sapling.json similarity index 100% rename from src/test/resources/json/merkle_roots_empty_sapling.json rename to framework/src/test/resources/json/merkle_roots_empty_sapling.json diff --git a/src/test/resources/json/merkle_roots_sapling.json b/framework/src/test/resources/json/merkle_roots_sapling.json similarity index 100% rename from src/test/resources/json/merkle_roots_sapling.json rename to framework/src/test/resources/json/merkle_roots_sapling.json diff --git a/src/test/resources/logback-test.xml b/framework/src/test/resources/logback-test.xml similarity index 100% rename from src/test/resources/logback-test.xml rename to framework/src/test/resources/logback-test.xml diff --git a/src/test/resources/solcDir/README.txt b/framework/src/test/resources/solcDir/README.txt similarity index 100% rename from src/test/resources/solcDir/README.txt rename to framework/src/test/resources/solcDir/README.txt diff --git a/src/test/resources/solidityFile.xml b/framework/src/test/resources/solidityFile.xml similarity index 100% rename from src/test/resources/solidityFile.xml rename to framework/src/test/resources/solidityFile.xml diff --git a/src/test/resources/soliditycode/AssertException002.sol b/framework/src/test/resources/soliditycode/AssertException002.sol similarity index 100% rename from src/test/resources/soliditycode/AssertException002.sol rename to framework/src/test/resources/soliditycode/AssertException002.sol diff --git a/src/test/resources/soliditycode/ClearAbi001.sol b/framework/src/test/resources/soliditycode/ClearAbi001.sol similarity index 100% rename from src/test/resources/soliditycode/ClearAbi001.sol rename to framework/src/test/resources/soliditycode/ClearAbi001.sol diff --git a/src/test/resources/soliditycode/ClearAbi005.sol b/framework/src/test/resources/soliditycode/ClearAbi005.sol similarity index 100% rename from src/test/resources/soliditycode/ClearAbi005.sol rename to framework/src/test/resources/soliditycode/ClearAbi005.sol diff --git a/src/test/resources/soliditycode/Create2Test023.sol b/framework/src/test/resources/soliditycode/Create2Test023.sol similarity index 100% rename from src/test/resources/soliditycode/Create2Test023.sol rename to framework/src/test/resources/soliditycode/Create2Test023.sol diff --git a/src/test/resources/soliditycode/Create2Test024.sol b/framework/src/test/resources/soliditycode/Create2Test024.sol similarity index 100% rename from src/test/resources/soliditycode/Create2Test024.sol rename to framework/src/test/resources/soliditycode/Create2Test024.sol diff --git a/src/test/resources/soliditycode/Create2Test025.sol b/framework/src/test/resources/soliditycode/Create2Test025.sol similarity index 100% rename from src/test/resources/soliditycode/Create2Test025.sol rename to framework/src/test/resources/soliditycode/Create2Test025.sol diff --git a/src/test/resources/soliditycode/ExtCodeHashTest010.sol b/framework/src/test/resources/soliditycode/ExtCodeHashTest010.sol similarity index 100% rename from src/test/resources/soliditycode/ExtCodeHashTest010.sol rename to framework/src/test/resources/soliditycode/ExtCodeHashTest010.sol diff --git a/src/test/resources/soliditycode/ShiftCommand001.sol b/framework/src/test/resources/soliditycode/ShiftCommand001.sol similarity index 100% rename from src/test/resources/soliditycode/ShiftCommand001.sol rename to framework/src/test/resources/soliditycode/ShiftCommand001.sol diff --git a/src/test/resources/soliditycode/TransferFailed001.sol b/framework/src/test/resources/soliditycode/TransferFailed001.sol similarity index 100% rename from src/test/resources/soliditycode/TransferFailed001.sol rename to framework/src/test/resources/soliditycode/TransferFailed001.sol diff --git a/src/test/resources/soliditycode/TransferFailed005.sol b/framework/src/test/resources/soliditycode/TransferFailed005.sol similarity index 100% rename from src/test/resources/soliditycode/TransferFailed005.sol rename to framework/src/test/resources/soliditycode/TransferFailed005.sol diff --git a/src/test/resources/soliditycode/TransferFailed006.sol b/framework/src/test/resources/soliditycode/TransferFailed006.sol similarity index 100% rename from src/test/resources/soliditycode/TransferFailed006.sol rename to framework/src/test/resources/soliditycode/TransferFailed006.sol diff --git a/src/test/resources/soliditycode/TransferFailed007.sol b/framework/src/test/resources/soliditycode/TransferFailed007.sol similarity index 100% rename from src/test/resources/soliditycode/TransferFailed007.sol rename to framework/src/test/resources/soliditycode/TransferFailed007.sol diff --git a/src/test/resources/soliditycode/TriggerConstant001.sol b/framework/src/test/resources/soliditycode/TriggerConstant001.sol similarity index 100% rename from src/test/resources/soliditycode/TriggerConstant001.sol rename to framework/src/test/resources/soliditycode/TriggerConstant001.sol diff --git a/src/test/resources/soliditycode/TriggerConstant002.sol b/framework/src/test/resources/soliditycode/TriggerConstant002.sol similarity index 100% rename from src/test/resources/soliditycode/TriggerConstant002.sol rename to framework/src/test/resources/soliditycode/TriggerConstant002.sol diff --git a/src/test/resources/soliditycode/TriggerConstant003.sol b/framework/src/test/resources/soliditycode/TriggerConstant003.sol similarity index 100% rename from src/test/resources/soliditycode/TriggerConstant003.sol rename to framework/src/test/resources/soliditycode/TriggerConstant003.sol diff --git a/src/test/resources/soliditycode/TriggerConstant004.sol b/framework/src/test/resources/soliditycode/TriggerConstant004.sol similarity index 100% rename from src/test/resources/soliditycode/TriggerConstant004.sol rename to framework/src/test/resources/soliditycode/TriggerConstant004.sol diff --git a/src/test/resources/soliditycode/TriggerConstant015.sol b/framework/src/test/resources/soliditycode/TriggerConstant015.sol similarity index 100% rename from src/test/resources/soliditycode/TriggerConstant015.sol rename to framework/src/test/resources/soliditycode/TriggerConstant015.sol diff --git a/src/test/resources/soliditycode/TriggerConstant024.sol b/framework/src/test/resources/soliditycode/TriggerConstant024.sol similarity index 100% rename from src/test/resources/soliditycode/TriggerConstant024.sol rename to framework/src/test/resources/soliditycode/TriggerConstant024.sol diff --git a/src/test/resources/soliditycode/TvmNewCommand043.sol b/framework/src/test/resources/soliditycode/TvmNewCommand043.sol similarity index 100% rename from src/test/resources/soliditycode/TvmNewCommand043.sol rename to framework/src/test/resources/soliditycode/TvmNewCommand043.sol diff --git a/src/test/resources/soliditycode/TvmNewCommand103.sol b/framework/src/test/resources/soliditycode/TvmNewCommand103.sol similarity index 100% rename from src/test/resources/soliditycode/TvmNewCommand103.sol rename to framework/src/test/resources/soliditycode/TvmNewCommand103.sol diff --git a/src/test/resources/soliditycode/TvmNewCommand107.sol b/framework/src/test/resources/soliditycode/TvmNewCommand107.sol similarity index 100% rename from src/test/resources/soliditycode/TvmNewCommand107.sol rename to framework/src/test/resources/soliditycode/TvmNewCommand107.sol diff --git a/src/test/resources/soliditycode/TvmNewCommand108.sol b/framework/src/test/resources/soliditycode/TvmNewCommand108.sol similarity index 100% rename from src/test/resources/soliditycode/TvmNewCommand108.sol rename to framework/src/test/resources/soliditycode/TvmNewCommand108.sol diff --git a/src/test/resources/soliditycode/TvmNewCommand109.sol b/framework/src/test/resources/soliditycode/TvmNewCommand109.sol similarity index 100% rename from src/test/resources/soliditycode/TvmNewCommand109.sol rename to framework/src/test/resources/soliditycode/TvmNewCommand109.sol diff --git a/src/test/resources/soliditycode/TvmOldCommand001.sol b/framework/src/test/resources/soliditycode/TvmOldCommand001.sol similarity index 100% rename from src/test/resources/soliditycode/TvmOldCommand001.sol rename to framework/src/test/resources/soliditycode/TvmOldCommand001.sol diff --git a/src/test/resources/soliditycode/addMsg001Nonpayable.sol b/framework/src/test/resources/soliditycode/addMsg001Nonpayable.sol similarity index 100% rename from src/test/resources/soliditycode/addMsg001Nonpayable.sol rename to framework/src/test/resources/soliditycode/addMsg001Nonpayable.sol diff --git a/src/test/resources/soliditycode/addMsg002View.sol b/framework/src/test/resources/soliditycode/addMsg002View.sol similarity index 100% rename from src/test/resources/soliditycode/addMsg002View.sol rename to framework/src/test/resources/soliditycode/addMsg002View.sol diff --git a/src/test/resources/soliditycode/addMsg003Constant.sol b/framework/src/test/resources/soliditycode/addMsg003Constant.sol similarity index 100% rename from src/test/resources/soliditycode/addMsg003Constant.sol rename to framework/src/test/resources/soliditycode/addMsg003Constant.sol diff --git a/src/test/resources/soliditycode/addMsg004Pure.sol b/framework/src/test/resources/soliditycode/addMsg004Pure.sol similarity index 100% rename from src/test/resources/soliditycode/addMsg004Pure.sol rename to framework/src/test/resources/soliditycode/addMsg004Pure.sol diff --git a/src/test/resources/soliditycode/addTransferToken001Nonpayable.sol b/framework/src/test/resources/soliditycode/addTransferToken001Nonpayable.sol similarity index 100% rename from src/test/resources/soliditycode/addTransferToken001Nonpayable.sol rename to framework/src/test/resources/soliditycode/addTransferToken001Nonpayable.sol diff --git a/src/test/resources/soliditycode/addTransferToken001payable.sol b/framework/src/test/resources/soliditycode/addTransferToken001payable.sol similarity index 100% rename from src/test/resources/soliditycode/addTransferToken001payable.sol rename to framework/src/test/resources/soliditycode/addTransferToken001payable.sol diff --git a/src/test/resources/soliditycode/addTransferToken002View.sol b/framework/src/test/resources/soliditycode/addTransferToken002View.sol similarity index 100% rename from src/test/resources/soliditycode/addTransferToken002View.sol rename to framework/src/test/resources/soliditycode/addTransferToken002View.sol diff --git a/src/test/resources/soliditycode/addTransferToken003Constant.sol b/framework/src/test/resources/soliditycode/addTransferToken003Constant.sol similarity index 100% rename from src/test/resources/soliditycode/addTransferToken003Constant.sol rename to framework/src/test/resources/soliditycode/addTransferToken003Constant.sol diff --git a/src/test/resources/soliditycode/addTransferToken004Pure.sol b/framework/src/test/resources/soliditycode/addTransferToken004Pure.sol similarity index 100% rename from src/test/resources/soliditycode/addTransferToken004Pure.sol rename to framework/src/test/resources/soliditycode/addTransferToken004Pure.sol diff --git a/src/test/resources/soliditycode/addTrcToken001Assemble.sol b/framework/src/test/resources/soliditycode/addTrcToken001Assemble.sol similarity index 100% rename from src/test/resources/soliditycode/addTrcToken001Assemble.sol rename to framework/src/test/resources/soliditycode/addTrcToken001Assemble.sol diff --git a/src/test/resources/soliditycode/addTrcToken002Cat.sol b/framework/src/test/resources/soliditycode/addTrcToken002Cat.sol similarity index 100% rename from src/test/resources/soliditycode/addTrcToken002Cat.sol rename to framework/src/test/resources/soliditycode/addTrcToken002Cat.sol diff --git a/src/test/resources/soliditycode/addTrcToken002Cat_withFinny.sol b/framework/src/test/resources/soliditycode/addTrcToken002Cat_withFinny.sol similarity index 100% rename from src/test/resources/soliditycode/addTrcToken002Cat_withFinny.sol rename to framework/src/test/resources/soliditycode/addTrcToken002Cat_withFinny.sol diff --git a/src/test/resources/soliditycode/assertExceptiontest1DivideInt.sol b/framework/src/test/resources/soliditycode/assertExceptiontest1DivideInt.sol similarity index 100% rename from src/test/resources/soliditycode/assertExceptiontest1DivideInt.sol rename to framework/src/test/resources/soliditycode/assertExceptiontest1DivideInt.sol diff --git a/src/test/resources/soliditycode/assertExceptiontest2FindArgsContractMinTest.sol b/framework/src/test/resources/soliditycode/assertExceptiontest2FindArgsContractMinTest.sol similarity index 100% rename from src/test/resources/soliditycode/assertExceptiontest2FindArgsContractMinTest.sol rename to framework/src/test/resources/soliditycode/assertExceptiontest2FindArgsContractMinTest.sol diff --git a/src/test/resources/soliditycode/assertExceptiontest3ByteMinContract.sol b/framework/src/test/resources/soliditycode/assertExceptiontest3ByteMinContract.sol similarity index 100% rename from src/test/resources/soliditycode/assertExceptiontest3ByteMinContract.sol rename to framework/src/test/resources/soliditycode/assertExceptiontest3ByteMinContract.sol diff --git a/src/test/resources/soliditycode/assertExceptiontest4Enum.sol b/framework/src/test/resources/soliditycode/assertExceptiontest4Enum.sol similarity index 100% rename from src/test/resources/soliditycode/assertExceptiontest4Enum.sol rename to framework/src/test/resources/soliditycode/assertExceptiontest4Enum.sol diff --git a/src/test/resources/soliditycode/assertExceptiontest5MoveRight.sol b/framework/src/test/resources/soliditycode/assertExceptiontest5MoveRight.sol similarity index 100% rename from src/test/resources/soliditycode/assertExceptiontest5MoveRight.sol rename to framework/src/test/resources/soliditycode/assertExceptiontest5MoveRight.sol diff --git a/src/test/resources/soliditycode/assertExceptiontest6UninitializedContract.sol b/framework/src/test/resources/soliditycode/assertExceptiontest6UninitializedContract.sol similarity index 100% rename from src/test/resources/soliditycode/assertExceptiontest6UninitializedContract.sol rename to framework/src/test/resources/soliditycode/assertExceptiontest6UninitializedContract.sol diff --git a/src/test/resources/soliditycode/assertExceptiontest7TestAssertContract.sol b/framework/src/test/resources/soliditycode/assertExceptiontest7TestAssertContract.sol similarity index 100% rename from src/test/resources/soliditycode/assertExceptiontest7TestAssertContract.sol rename to framework/src/test/resources/soliditycode/assertExceptiontest7TestAssertContract.sol diff --git a/src/test/resources/soliditycode/codeSaftySupport.sol b/framework/src/test/resources/soliditycode/codeSaftySupport.sol similarity index 100% rename from src/test/resources/soliditycode/codeSaftySupport.sol rename to framework/src/test/resources/soliditycode/codeSaftySupport.sol diff --git a/src/test/resources/soliditycode/codeSaftyUnsupport.sol b/framework/src/test/resources/soliditycode/codeSaftyUnsupport.sol similarity index 100% rename from src/test/resources/soliditycode/codeSaftyUnsupport.sol rename to framework/src/test/resources/soliditycode/codeSaftyUnsupport.sol diff --git a/src/test/resources/soliditycode/constantContract001.sol b/framework/src/test/resources/soliditycode/constantContract001.sol similarity index 100% rename from src/test/resources/soliditycode/constantContract001.sol rename to framework/src/test/resources/soliditycode/constantContract001.sol diff --git a/src/test/resources/soliditycode/contractGetterContract.sol b/framework/src/test/resources/soliditycode/contractGetterContract.sol similarity index 100% rename from src/test/resources/soliditycode/contractGetterContract.sol rename to framework/src/test/resources/soliditycode/contractGetterContract.sol diff --git a/src/test/resources/soliditycode/contractGrammar001test1Grammar001.sol b/framework/src/test/resources/soliditycode/contractGrammar001test1Grammar001.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar001test1Grammar001.sol rename to framework/src/test/resources/soliditycode/contractGrammar001test1Grammar001.sol diff --git a/src/test/resources/soliditycode/contractGrammar001test2Grammar002.sol b/framework/src/test/resources/soliditycode/contractGrammar001test2Grammar002.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar001test2Grammar002.sol rename to framework/src/test/resources/soliditycode/contractGrammar001test2Grammar002.sol diff --git a/src/test/resources/soliditycode/contractGrammar001test3Grammar003.sol b/framework/src/test/resources/soliditycode/contractGrammar001test3Grammar003.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar001test3Grammar003.sol rename to framework/src/test/resources/soliditycode/contractGrammar001test3Grammar003.sol diff --git a/src/test/resources/soliditycode/contractGrammar001test4Grammar004.sol b/framework/src/test/resources/soliditycode/contractGrammar001test4Grammar004.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar001test4Grammar004.sol rename to framework/src/test/resources/soliditycode/contractGrammar001test4Grammar004.sol diff --git a/src/test/resources/soliditycode/contractGrammar001test5Grammar006.sol b/framework/src/test/resources/soliditycode/contractGrammar001test5Grammar006.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar001test5Grammar006.sol rename to framework/src/test/resources/soliditycode/contractGrammar001test5Grammar006.sol diff --git a/src/test/resources/soliditycode/contractGrammar002test1Grammar007_1.sol b/framework/src/test/resources/soliditycode/contractGrammar002test1Grammar007_1.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar002test1Grammar007_1.sol rename to framework/src/test/resources/soliditycode/contractGrammar002test1Grammar007_1.sol diff --git a/src/test/resources/soliditycode/contractGrammar002test1Grammar007_2.sol b/framework/src/test/resources/soliditycode/contractGrammar002test1Grammar007_2.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar002test1Grammar007_2.sol rename to framework/src/test/resources/soliditycode/contractGrammar002test1Grammar007_2.sol diff --git a/src/test/resources/soliditycode/contractGrammar002test2Grammar008.sol b/framework/src/test/resources/soliditycode/contractGrammar002test2Grammar008.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar002test2Grammar008.sol rename to framework/src/test/resources/soliditycode/contractGrammar002test2Grammar008.sol diff --git a/src/test/resources/soliditycode/contractGrammar002test3Grammar010.sol b/framework/src/test/resources/soliditycode/contractGrammar002test3Grammar010.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar002test3Grammar010.sol rename to framework/src/test/resources/soliditycode/contractGrammar002test3Grammar010.sol diff --git a/src/test/resources/soliditycode/contractGrammar002test4Grammar011.sol b/framework/src/test/resources/soliditycode/contractGrammar002test4Grammar011.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar002test4Grammar011.sol rename to framework/src/test/resources/soliditycode/contractGrammar002test4Grammar011.sol diff --git a/src/test/resources/soliditycode/contractGrammar002test4Grammar012.sol b/framework/src/test/resources/soliditycode/contractGrammar002test4Grammar012.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar002test4Grammar012.sol rename to framework/src/test/resources/soliditycode/contractGrammar002test4Grammar012.sol diff --git a/src/test/resources/soliditycode/contractGrammar002test6Grammar013.sol b/framework/src/test/resources/soliditycode/contractGrammar002test6Grammar013.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar002test6Grammar013.sol rename to framework/src/test/resources/soliditycode/contractGrammar002test6Grammar013.sol diff --git a/src/test/resources/soliditycode/contractGrammar003test1Grammar014.sol b/framework/src/test/resources/soliditycode/contractGrammar003test1Grammar014.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar003test1Grammar014.sol rename to framework/src/test/resources/soliditycode/contractGrammar003test1Grammar014.sol diff --git a/src/test/resources/soliditycode/contractGrammar003test2Grammar015.sol b/framework/src/test/resources/soliditycode/contractGrammar003test2Grammar015.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar003test2Grammar015.sol rename to framework/src/test/resources/soliditycode/contractGrammar003test2Grammar015.sol diff --git a/src/test/resources/soliditycode/contractGrammar003test3Grammar016.sol b/framework/src/test/resources/soliditycode/contractGrammar003test3Grammar016.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar003test3Grammar016.sol rename to framework/src/test/resources/soliditycode/contractGrammar003test3Grammar016.sol diff --git a/src/test/resources/soliditycode/contractGrammar003test4Grammar017.sol b/framework/src/test/resources/soliditycode/contractGrammar003test4Grammar017.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar003test4Grammar017.sol rename to framework/src/test/resources/soliditycode/contractGrammar003test4Grammar017.sol diff --git a/src/test/resources/soliditycode/contractGrammar003test5Grammar018.sol b/framework/src/test/resources/soliditycode/contractGrammar003test5Grammar018.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar003test5Grammar018.sol rename to framework/src/test/resources/soliditycode/contractGrammar003test5Grammar018.sol diff --git a/src/test/resources/soliditycode/contractGrammar003test6Grammar019.sol b/framework/src/test/resources/soliditycode/contractGrammar003test6Grammar019.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar003test6Grammar019.sol rename to framework/src/test/resources/soliditycode/contractGrammar003test6Grammar019.sol diff --git a/src/test/resources/soliditycode/contractGrammar003test7Grammar020.sol b/framework/src/test/resources/soliditycode/contractGrammar003test7Grammar020.sol similarity index 100% rename from src/test/resources/soliditycode/contractGrammar003test7Grammar020.sol rename to framework/src/test/resources/soliditycode/contractGrammar003test7Grammar020.sol diff --git a/src/test/resources/soliditycode/contractInnerContract.sol b/framework/src/test/resources/soliditycode/contractInnerContract.sol similarity index 100% rename from src/test/resources/soliditycode/contractInnerContract.sol rename to framework/src/test/resources/soliditycode/contractInnerContract.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction001.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction001.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction001.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction001.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction002.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction002.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction002.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction002.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction003.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction003.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction003.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction003.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction004.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction004.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction004.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction004.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction005.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction005.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction005.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction005.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction006.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction006.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction006.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction001testInternalTransaction006.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction002test1InternalTransaction007.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction002test1InternalTransaction007.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction002test1InternalTransaction007.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction002test1InternalTransaction007.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction002test2InternalTransaction008.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction002test2InternalTransaction008.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction002test2InternalTransaction008.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction002test2InternalTransaction008.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction002test3InternalTransaction009.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction002test3InternalTransaction009.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction002test3InternalTransaction009.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction002test3InternalTransaction009.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010_1.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010_1.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010_1.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction002test4InternalTransaction010_1.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction002test5InternalTransaction012.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction002test5InternalTransaction012.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction002test5InternalTransaction012.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction002test5InternalTransaction012.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction013.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction013.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction013.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction013.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction014.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction014.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction014.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction014.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction015.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction015.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction015.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction015.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction016.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction016.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction016.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction016.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction017.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction017.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction017.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction017.sol diff --git a/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction018.sol b/framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction018.sol similarity index 100% rename from src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction018.sol rename to framework/src/test/resources/soliditycode/contractInternalTransaction003testInternalTransaction018.sol diff --git a/src/test/resources/soliditycode/contractLinkage001.sol b/framework/src/test/resources/soliditycode/contractLinkage001.sol similarity index 100% rename from src/test/resources/soliditycode/contractLinkage001.sol rename to framework/src/test/resources/soliditycode/contractLinkage001.sol diff --git a/src/test/resources/soliditycode/contractLinkage002.sol b/framework/src/test/resources/soliditycode/contractLinkage002.sol similarity index 100% rename from src/test/resources/soliditycode/contractLinkage002.sol rename to framework/src/test/resources/soliditycode/contractLinkage002.sol diff --git a/src/test/resources/soliditycode/contractLinkage003.sol b/framework/src/test/resources/soliditycode/contractLinkage003.sol similarity index 100% rename from src/test/resources/soliditycode/contractLinkage003.sol rename to framework/src/test/resources/soliditycode/contractLinkage003.sol diff --git a/src/test/resources/soliditycode/contractLinkage004.sol b/framework/src/test/resources/soliditycode/contractLinkage004.sol similarity index 100% rename from src/test/resources/soliditycode/contractLinkage004.sol rename to framework/src/test/resources/soliditycode/contractLinkage004.sol diff --git a/src/test/resources/soliditycode/contractLinkage005.sol b/framework/src/test/resources/soliditycode/contractLinkage005.sol similarity index 100% rename from src/test/resources/soliditycode/contractLinkage005.sol rename to framework/src/test/resources/soliditycode/contractLinkage005.sol diff --git a/src/test/resources/soliditycode/contractLinkage006.sol b/framework/src/test/resources/soliditycode/contractLinkage006.sol similarity index 100% rename from src/test/resources/soliditycode/contractLinkage006.sol rename to framework/src/test/resources/soliditycode/contractLinkage006.sol diff --git a/src/test/resources/soliditycode/contractOriginEnergyLimit001.sol b/framework/src/test/resources/soliditycode/contractOriginEnergyLimit001.sol similarity index 100% rename from src/test/resources/soliditycode/contractOriginEnergyLimit001.sol rename to framework/src/test/resources/soliditycode/contractOriginEnergyLimit001.sol diff --git a/src/test/resources/soliditycode/contractOriginEnergyLimit004.sol b/framework/src/test/resources/soliditycode/contractOriginEnergyLimit004.sol similarity index 100% rename from src/test/resources/soliditycode/contractOriginEnergyLimit004.sol rename to framework/src/test/resources/soliditycode/contractOriginEnergyLimit004.sol diff --git a/src/test/resources/soliditycode/contractOtherToTrcToken.sol b/framework/src/test/resources/soliditycode/contractOtherToTrcToken.sol similarity index 100% rename from src/test/resources/soliditycode/contractOtherToTrcToken.sol rename to framework/src/test/resources/soliditycode/contractOtherToTrcToken.sol diff --git a/src/test/resources/soliditycode/contractScenario001.sol b/framework/src/test/resources/soliditycode/contractScenario001.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario001.sol rename to framework/src/test/resources/soliditycode/contractScenario001.sol diff --git a/src/test/resources/soliditycode/contractScenario002.sol b/framework/src/test/resources/soliditycode/contractScenario002.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario002.sol rename to framework/src/test/resources/soliditycode/contractScenario002.sol diff --git a/src/test/resources/soliditycode/contractScenario003.sol b/framework/src/test/resources/soliditycode/contractScenario003.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario003.sol rename to framework/src/test/resources/soliditycode/contractScenario003.sol diff --git a/src/test/resources/soliditycode/contractScenario004.sol b/framework/src/test/resources/soliditycode/contractScenario004.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario004.sol rename to framework/src/test/resources/soliditycode/contractScenario004.sol diff --git a/src/test/resources/soliditycode/contractScenario005.sol b/framework/src/test/resources/soliditycode/contractScenario005.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario005.sol rename to framework/src/test/resources/soliditycode/contractScenario005.sol diff --git a/src/test/resources/soliditycode/contractScenario006.sol b/framework/src/test/resources/soliditycode/contractScenario006.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario006.sol rename to framework/src/test/resources/soliditycode/contractScenario006.sol diff --git a/src/test/resources/soliditycode/contractScenario007.sol b/framework/src/test/resources/soliditycode/contractScenario007.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario007.sol rename to framework/src/test/resources/soliditycode/contractScenario007.sol diff --git a/src/test/resources/soliditycode/contractScenario008.sol b/framework/src/test/resources/soliditycode/contractScenario008.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario008.sol rename to framework/src/test/resources/soliditycode/contractScenario008.sol diff --git a/src/test/resources/soliditycode/contractScenario009.sol b/framework/src/test/resources/soliditycode/contractScenario009.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario009.sol rename to framework/src/test/resources/soliditycode/contractScenario009.sol diff --git a/src/test/resources/soliditycode/contractScenario010.sol b/framework/src/test/resources/soliditycode/contractScenario010.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario010.sol rename to framework/src/test/resources/soliditycode/contractScenario010.sol diff --git a/src/test/resources/soliditycode/contractScenario011.sol b/framework/src/test/resources/soliditycode/contractScenario011.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario011.sol rename to framework/src/test/resources/soliditycode/contractScenario011.sol diff --git a/src/test/resources/soliditycode/contractScenario012.sol b/framework/src/test/resources/soliditycode/contractScenario012.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario012.sol rename to framework/src/test/resources/soliditycode/contractScenario012.sol diff --git a/src/test/resources/soliditycode/contractScenario013.sol b/framework/src/test/resources/soliditycode/contractScenario013.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario013.sol rename to framework/src/test/resources/soliditycode/contractScenario013.sol diff --git a/src/test/resources/soliditycode/contractScenario014.sol b/framework/src/test/resources/soliditycode/contractScenario014.sol similarity index 100% rename from src/test/resources/soliditycode/contractScenario014.sol rename to framework/src/test/resources/soliditycode/contractScenario014.sol diff --git a/src/test/resources/soliditycode/contractTest.sol b/framework/src/test/resources/soliditycode/contractTest.sol similarity index 100% rename from src/test/resources/soliditycode/contractTest.sol rename to framework/src/test/resources/soliditycode/contractTest.sol diff --git a/src/test/resources/soliditycode/contractToMathedFeed.sol b/framework/src/test/resources/soliditycode/contractToMathedFeed.sol similarity index 100% rename from src/test/resources/soliditycode/contractToMathedFeed.sol rename to framework/src/test/resources/soliditycode/contractToMathedFeed.sol diff --git a/src/test/resources/soliditycode/contractTrcToken001.sol b/framework/src/test/resources/soliditycode/contractTrcToken001.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken001.sol rename to framework/src/test/resources/soliditycode/contractTrcToken001.sol diff --git a/src/test/resources/soliditycode/contractTrcToken002.sol b/framework/src/test/resources/soliditycode/contractTrcToken002.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken002.sol rename to framework/src/test/resources/soliditycode/contractTrcToken002.sol diff --git a/src/test/resources/soliditycode/contractTrcToken003.sol b/framework/src/test/resources/soliditycode/contractTrcToken003.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken003.sol rename to framework/src/test/resources/soliditycode/contractTrcToken003.sol diff --git a/src/test/resources/soliditycode/contractTrcToken005.sol b/framework/src/test/resources/soliditycode/contractTrcToken005.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken005.sol rename to framework/src/test/resources/soliditycode/contractTrcToken005.sol diff --git a/src/test/resources/soliditycode/contractTrcToken011.sol b/framework/src/test/resources/soliditycode/contractTrcToken011.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken011.sol rename to framework/src/test/resources/soliditycode/contractTrcToken011.sol diff --git a/src/test/resources/soliditycode/contractTrcToken012.sol b/framework/src/test/resources/soliditycode/contractTrcToken012.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken012.sol rename to framework/src/test/resources/soliditycode/contractTrcToken012.sol diff --git a/src/test/resources/soliditycode/contractTrcToken014.sol b/framework/src/test/resources/soliditycode/contractTrcToken014.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken014.sol rename to framework/src/test/resources/soliditycode/contractTrcToken014.sol diff --git a/src/test/resources/soliditycode/contractTrcToken018.sol b/framework/src/test/resources/soliditycode/contractTrcToken018.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken018.sol rename to framework/src/test/resources/soliditycode/contractTrcToken018.sol diff --git a/src/test/resources/soliditycode/contractTrcToken023.sol b/framework/src/test/resources/soliditycode/contractTrcToken023.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken023.sol rename to framework/src/test/resources/soliditycode/contractTrcToken023.sol diff --git a/src/test/resources/soliditycode/contractTrcToken026.sol b/framework/src/test/resources/soliditycode/contractTrcToken026.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken026.sol rename to framework/src/test/resources/soliditycode/contractTrcToken026.sol diff --git a/src/test/resources/soliditycode/contractTrcToken027.sol b/framework/src/test/resources/soliditycode/contractTrcToken027.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken027.sol rename to framework/src/test/resources/soliditycode/contractTrcToken027.sol diff --git a/src/test/resources/soliditycode/contractTrcToken028.sol b/framework/src/test/resources/soliditycode/contractTrcToken028.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken028.sol rename to framework/src/test/resources/soliditycode/contractTrcToken028.sol diff --git a/src/test/resources/soliditycode/contractTrcToken029.sol b/framework/src/test/resources/soliditycode/contractTrcToken029.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken029.sol rename to framework/src/test/resources/soliditycode/contractTrcToken029.sol diff --git a/src/test/resources/soliditycode/contractTrcToken030.sol b/framework/src/test/resources/soliditycode/contractTrcToken030.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken030.sol rename to framework/src/test/resources/soliditycode/contractTrcToken030.sol diff --git a/src/test/resources/soliditycode/contractTrcToken031.sol b/framework/src/test/resources/soliditycode/contractTrcToken031.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken031.sol rename to framework/src/test/resources/soliditycode/contractTrcToken031.sol diff --git a/src/test/resources/soliditycode/contractTrcToken034.sol b/framework/src/test/resources/soliditycode/contractTrcToken034.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken034.sol rename to framework/src/test/resources/soliditycode/contractTrcToken034.sol diff --git a/src/test/resources/soliditycode/contractTrcToken035.sol b/framework/src/test/resources/soliditycode/contractTrcToken035.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken035.sol rename to framework/src/test/resources/soliditycode/contractTrcToken035.sol diff --git a/src/test/resources/soliditycode/contractTrcToken036.sol b/framework/src/test/resources/soliditycode/contractTrcToken036.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken036.sol rename to framework/src/test/resources/soliditycode/contractTrcToken036.sol diff --git a/src/test/resources/soliditycode/contractTrcToken036_1.sol b/framework/src/test/resources/soliditycode/contractTrcToken036_1.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken036_1.sol rename to framework/src/test/resources/soliditycode/contractTrcToken036_1.sol diff --git a/src/test/resources/soliditycode/contractTrcToken036_2.sol b/framework/src/test/resources/soliditycode/contractTrcToken036_2.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken036_2.sol rename to framework/src/test/resources/soliditycode/contractTrcToken036_2.sol diff --git a/src/test/resources/soliditycode/contractTrcToken036_3.sol b/framework/src/test/resources/soliditycode/contractTrcToken036_3.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken036_3.sol rename to framework/src/test/resources/soliditycode/contractTrcToken036_3.sol diff --git a/src/test/resources/soliditycode/contractTrcToken036_4.sol b/framework/src/test/resources/soliditycode/contractTrcToken036_4.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken036_4.sol rename to framework/src/test/resources/soliditycode/contractTrcToken036_4.sol diff --git a/src/test/resources/soliditycode/contractTrcToken036_old.sol b/framework/src/test/resources/soliditycode/contractTrcToken036_old.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken036_old.sol rename to framework/src/test/resources/soliditycode/contractTrcToken036_old.sol diff --git a/src/test/resources/soliditycode/contractTrcToken037.sol b/framework/src/test/resources/soliditycode/contractTrcToken037.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken037.sol rename to framework/src/test/resources/soliditycode/contractTrcToken037.sol diff --git a/src/test/resources/soliditycode/contractTrcToken038.sol b/framework/src/test/resources/soliditycode/contractTrcToken038.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken038.sol rename to framework/src/test/resources/soliditycode/contractTrcToken038.sol diff --git a/src/test/resources/soliditycode/contractTrcToken039.sol b/framework/src/test/resources/soliditycode/contractTrcToken039.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken039.sol rename to framework/src/test/resources/soliditycode/contractTrcToken039.sol diff --git a/src/test/resources/soliditycode/contractTrcToken041.sol b/framework/src/test/resources/soliditycode/contractTrcToken041.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken041.sol rename to framework/src/test/resources/soliditycode/contractTrcToken041.sol diff --git a/src/test/resources/soliditycode/contractTrcToken043.sol b/framework/src/test/resources/soliditycode/contractTrcToken043.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken043.sol rename to framework/src/test/resources/soliditycode/contractTrcToken043.sol diff --git a/src/test/resources/soliditycode/contractTrcToken048.sol b/framework/src/test/resources/soliditycode/contractTrcToken048.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken048.sol rename to framework/src/test/resources/soliditycode/contractTrcToken048.sol diff --git a/src/test/resources/soliditycode/contractTrcToken049.sol b/framework/src/test/resources/soliditycode/contractTrcToken049.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken049.sol rename to framework/src/test/resources/soliditycode/contractTrcToken049.sol diff --git a/src/test/resources/soliditycode/contractTrcToken050.sol b/framework/src/test/resources/soliditycode/contractTrcToken050.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken050.sol rename to framework/src/test/resources/soliditycode/contractTrcToken050.sol diff --git a/src/test/resources/soliditycode/contractTrcToken051.sol b/framework/src/test/resources/soliditycode/contractTrcToken051.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken051.sol rename to framework/src/test/resources/soliditycode/contractTrcToken051.sol diff --git a/src/test/resources/soliditycode/contractTrcToken052.sol b/framework/src/test/resources/soliditycode/contractTrcToken052.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken052.sol rename to framework/src/test/resources/soliditycode/contractTrcToken052.sol diff --git a/src/test/resources/soliditycode/contractTrcToken054.sol b/framework/src/test/resources/soliditycode/contractTrcToken054.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken054.sol rename to framework/src/test/resources/soliditycode/contractTrcToken054.sol diff --git a/src/test/resources/soliditycode/contractTrcToken055.sol b/framework/src/test/resources/soliditycode/contractTrcToken055.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken055.sol rename to framework/src/test/resources/soliditycode/contractTrcToken055.sol diff --git a/src/test/resources/soliditycode/contractTrcToken060.sol b/framework/src/test/resources/soliditycode/contractTrcToken060.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken060.sol rename to framework/src/test/resources/soliditycode/contractTrcToken060.sol diff --git a/src/test/resources/soliditycode/contractTrcToken061.sol b/framework/src/test/resources/soliditycode/contractTrcToken061.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken061.sol rename to framework/src/test/resources/soliditycode/contractTrcToken061.sol diff --git a/src/test/resources/soliditycode/contractTrcToken064.sol b/framework/src/test/resources/soliditycode/contractTrcToken064.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken064.sol rename to framework/src/test/resources/soliditycode/contractTrcToken064.sol diff --git a/src/test/resources/soliditycode/contractTrcToken066.sol b/framework/src/test/resources/soliditycode/contractTrcToken066.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken066.sol rename to framework/src/test/resources/soliditycode/contractTrcToken066.sol diff --git a/src/test/resources/soliditycode/contractTrcToken067.sol b/framework/src/test/resources/soliditycode/contractTrcToken067.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken067.sol rename to framework/src/test/resources/soliditycode/contractTrcToken067.sol diff --git a/src/test/resources/soliditycode/contractTrcToken073.sol b/framework/src/test/resources/soliditycode/contractTrcToken073.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken073.sol rename to framework/src/test/resources/soliditycode/contractTrcToken073.sol diff --git a/src/test/resources/soliditycode/contractTrcToken075.sol b/framework/src/test/resources/soliditycode/contractTrcToken075.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken075.sol rename to framework/src/test/resources/soliditycode/contractTrcToken075.sol diff --git a/src/test/resources/soliditycode/contractTrcToken076.sol b/framework/src/test/resources/soliditycode/contractTrcToken076.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken076.sol rename to framework/src/test/resources/soliditycode/contractTrcToken076.sol diff --git a/src/test/resources/soliditycode/contractTrcToken077.sol b/framework/src/test/resources/soliditycode/contractTrcToken077.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken077.sol rename to framework/src/test/resources/soliditycode/contractTrcToken077.sol diff --git a/src/test/resources/soliditycode/contractTrcToken078.sol b/framework/src/test/resources/soliditycode/contractTrcToken078.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken078.sol rename to framework/src/test/resources/soliditycode/contractTrcToken078.sol diff --git a/src/test/resources/soliditycode/contractTrcToken079.sol b/framework/src/test/resources/soliditycode/contractTrcToken079.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken079.sol rename to framework/src/test/resources/soliditycode/contractTrcToken079.sol diff --git a/src/test/resources/soliditycode/contractTrcToken080.sol b/framework/src/test/resources/soliditycode/contractTrcToken080.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcToken080.sol rename to framework/src/test/resources/soliditycode/contractTrcToken080.sol diff --git a/src/test/resources/soliditycode/contractTrcTokenToOther.sol b/framework/src/test/resources/soliditycode/contractTrcTokenToOther.sol similarity index 100% rename from src/test/resources/soliditycode/contractTrcTokenToOther.sol rename to framework/src/test/resources/soliditycode/contractTrcTokenToOther.sol diff --git a/src/test/resources/soliditycode/contractUnknownException.sol b/framework/src/test/resources/soliditycode/contractUnknownException.sol similarity index 100% rename from src/test/resources/soliditycode/contractUnknownException.sol rename to framework/src/test/resources/soliditycode/contractUnknownException.sol diff --git a/src/test/resources/soliditycode/create2CallContract.sol b/framework/src/test/resources/soliditycode/create2CallContract.sol similarity index 100% rename from src/test/resources/soliditycode/create2CallContract.sol rename to framework/src/test/resources/soliditycode/create2CallContract.sol diff --git a/src/test/resources/soliditycode/create2contract.sol b/framework/src/test/resources/soliditycode/create2contract.sol similarity index 100% rename from src/test/resources/soliditycode/create2contract.sol rename to framework/src/test/resources/soliditycode/create2contract.sol diff --git a/src/test/resources/soliditycode/create2contract22.sol b/framework/src/test/resources/soliditycode/create2contract22.sol similarity index 100% rename from src/test/resources/soliditycode/create2contract22.sol rename to framework/src/test/resources/soliditycode/create2contract22.sol diff --git a/src/test/resources/soliditycode/create2contractn.sol b/framework/src/test/resources/soliditycode/create2contractn.sol similarity index 100% rename from src/test/resources/soliditycode/create2contractn.sol rename to framework/src/test/resources/soliditycode/create2contractn.sol diff --git a/src/test/resources/soliditycode/create2contractn2.sol b/framework/src/test/resources/soliditycode/create2contractn2.sol similarity index 100% rename from src/test/resources/soliditycode/create2contractn2.sol rename to framework/src/test/resources/soliditycode/create2contractn2.sol diff --git a/src/test/resources/soliditycode/demo.sol b/framework/src/test/resources/soliditycode/demo.sol similarity index 100% rename from src/test/resources/soliditycode/demo.sol rename to framework/src/test/resources/soliditycode/demo.sol diff --git a/src/test/resources/soliditycode/event001.sol b/framework/src/test/resources/soliditycode/event001.sol similarity index 100% rename from src/test/resources/soliditycode/event001.sol rename to framework/src/test/resources/soliditycode/event001.sol diff --git a/src/test/resources/soliditycode/event002.sol b/framework/src/test/resources/soliditycode/event002.sol similarity index 100% rename from src/test/resources/soliditycode/event002.sol rename to framework/src/test/resources/soliditycode/event002.sol diff --git a/src/test/resources/soliditycode/extCodeHash.sol b/framework/src/test/resources/soliditycode/extCodeHash.sol similarity index 100% rename from src/test/resources/soliditycode/extCodeHash.sol rename to framework/src/test/resources/soliditycode/extCodeHash.sol diff --git a/src/test/resources/soliditycode/extCodeHash11.sol b/framework/src/test/resources/soliditycode/extCodeHash11.sol similarity index 100% rename from src/test/resources/soliditycode/extCodeHash11.sol rename to framework/src/test/resources/soliditycode/extCodeHash11.sol diff --git a/src/test/resources/soliditycode/extCodeHashConstruct.sol b/framework/src/test/resources/soliditycode/extCodeHashConstruct.sol similarity index 100% rename from src/test/resources/soliditycode/extCodeHashConstruct.sol rename to framework/src/test/resources/soliditycode/extCodeHashConstruct.sol diff --git a/src/test/resources/soliditycode/extCodeHashStress.sol b/framework/src/test/resources/soliditycode/extCodeHashStress.sol similarity index 100% rename from src/test/resources/soliditycode/extCodeHashStress.sol rename to framework/src/test/resources/soliditycode/extCodeHashStress.sol diff --git a/src/test/resources/soliditycode/extCodeHashTestNoPayable.sol b/framework/src/test/resources/soliditycode/extCodeHashTestNoPayable.sol similarity index 100% rename from src/test/resources/soliditycode/extCodeHashTestNoPayable.sol rename to framework/src/test/resources/soliditycode/extCodeHashTestNoPayable.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest1TestRequireContract.sol b/framework/src/test/resources/soliditycode/requireExceptiontest1TestRequireContract.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest1TestRequireContract.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest1TestRequireContract.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest2TestThrowsContract.sol b/framework/src/test/resources/soliditycode/requireExceptiontest2TestThrowsContract.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest2TestThrowsContract.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest2TestThrowsContract.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest3TestRevertContract.sol b/framework/src/test/resources/soliditycode/requireExceptiontest3TestRevertContract.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest3TestRevertContract.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest3TestRevertContract.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest4noPayableContract.sol b/framework/src/test/resources/soliditycode/requireExceptiontest4noPayableContract.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest4noPayableContract.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest4noPayableContract.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest4noPayableContract_1.sol b/framework/src/test/resources/soliditycode/requireExceptiontest4noPayableContract_1.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest4noPayableContract_1.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest4noPayableContract_1.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor.sol b/framework/src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor_1.sol b/framework/src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor_1.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor_1.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor_1.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest6transferTestContract.sol b/framework/src/test/resources/soliditycode/requireExceptiontest6transferTestContract.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest6transferTestContract.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest6transferTestContract.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest7payableFallbakContract.sol b/framework/src/test/resources/soliditycode/requireExceptiontest7payableFallbakContract.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest7payableFallbakContract.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest7payableFallbakContract.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest8newContractGasNoenough.sol b/framework/src/test/resources/soliditycode/requireExceptiontest8newContractGasNoenough.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest8newContractGasNoenough.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest8newContractGasNoenough.sol diff --git a/src/test/resources/soliditycode/requireExceptiontest9MessageUsedErrorFeed.sol b/framework/src/test/resources/soliditycode/requireExceptiontest9MessageUsedErrorFeed.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontest9MessageUsedErrorFeed.sol rename to framework/src/test/resources/soliditycode/requireExceptiontest9MessageUsedErrorFeed.sol diff --git a/src/test/resources/soliditycode/requireExceptiontestFunctionUsedErrorFeed.sol b/framework/src/test/resources/soliditycode/requireExceptiontestFunctionUsedErrorFeed.sol similarity index 100% rename from src/test/resources/soliditycode/requireExceptiontestFunctionUsedErrorFeed.sol rename to framework/src/test/resources/soliditycode/requireExceptiontestFunctionUsedErrorFeed.sol diff --git a/src/test/resources/soliditycode/suicide001.sol b/framework/src/test/resources/soliditycode/suicide001.sol similarity index 100% rename from src/test/resources/soliditycode/suicide001.sol rename to framework/src/test/resources/soliditycode/suicide001.sol diff --git a/src/test/resources/soliditycode/suicide002.sol b/framework/src/test/resources/soliditycode/suicide002.sol similarity index 100% rename from src/test/resources/soliditycode/suicide002.sol rename to framework/src/test/resources/soliditycode/suicide002.sol diff --git a/src/test/resources/soliditycode/testOutOfMem.sol b/framework/src/test/resources/soliditycode/testOutOfMem.sol similarity index 100% rename from src/test/resources/soliditycode/testOutOfMem.sol rename to framework/src/test/resources/soliditycode/testOutOfMem.sol diff --git a/src/test/resources/soliditycode/walletTestMutiSign004.sol b/framework/src/test/resources/soliditycode/walletTestMutiSign004.sol similarity index 100% rename from src/test/resources/soliditycode/walletTestMutiSign004.sol rename to framework/src/test/resources/soliditycode/walletTestMutiSign004.sol diff --git a/src/test/resources/soliditycode_v0.4.25/TransferFailed001.sol b/framework/src/test/resources/soliditycode_v0.4.25/TransferFailed001.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/TransferFailed001.sol rename to framework/src/test/resources/soliditycode_v0.4.25/TransferFailed001.sol diff --git a/src/test/resources/soliditycode_v0.4.25/TransferFailed005.sol b/framework/src/test/resources/soliditycode_v0.4.25/TransferFailed005.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/TransferFailed005.sol rename to framework/src/test/resources/soliditycode_v0.4.25/TransferFailed005.sol diff --git a/src/test/resources/soliditycode_v0.4.25/TransferFailed007.sol b/framework/src/test/resources/soliditycode_v0.4.25/TransferFailed007.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/TransferFailed007.sol rename to framework/src/test/resources/soliditycode_v0.4.25/TransferFailed007.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addMsg001Nonpayable.sol b/framework/src/test/resources/soliditycode_v0.4.25/addMsg001Nonpayable.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addMsg001Nonpayable.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addMsg001Nonpayable.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addMsg002View.sol b/framework/src/test/resources/soliditycode_v0.4.25/addMsg002View.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addMsg002View.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addMsg002View.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addMsg003Constant.sol b/framework/src/test/resources/soliditycode_v0.4.25/addMsg003Constant.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addMsg003Constant.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addMsg003Constant.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addMsg004Pure.sol b/framework/src/test/resources/soliditycode_v0.4.25/addMsg004Pure.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addMsg004Pure.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addMsg004Pure.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addTransferToken001Nonpayable.sol b/framework/src/test/resources/soliditycode_v0.4.25/addTransferToken001Nonpayable.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addTransferToken001Nonpayable.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addTransferToken001Nonpayable.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addTransferToken002View.sol b/framework/src/test/resources/soliditycode_v0.4.25/addTransferToken002View.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addTransferToken002View.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addTransferToken002View.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addTransferToken003Constant.sol b/framework/src/test/resources/soliditycode_v0.4.25/addTransferToken003Constant.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addTransferToken003Constant.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addTransferToken003Constant.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addTransferToken004Pure.sol b/framework/src/test/resources/soliditycode_v0.4.25/addTransferToken004Pure.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addTransferToken004Pure.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addTransferToken004Pure.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addTrcToken001Assemble.sol b/framework/src/test/resources/soliditycode_v0.4.25/addTrcToken001Assemble.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addTrcToken001Assemble.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addTrcToken001Assemble.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat.sol b/framework/src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat.sol diff --git a/src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat_withFinny.sol b/framework/src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat_withFinny.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat_withFinny.sol rename to framework/src/test/resources/soliditycode_v0.4.25/addTrcToken002Cat_withFinny.sol diff --git a/src/test/resources/soliditycode_v0.4.25/assertExceptiontest1DivideInt.sol b/framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest1DivideInt.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/assertExceptiontest1DivideInt.sol rename to framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest1DivideInt.sol diff --git a/src/test/resources/soliditycode_v0.4.25/assertExceptiontest2FindArgsContractMinTest.sol b/framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest2FindArgsContractMinTest.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/assertExceptiontest2FindArgsContractMinTest.sol rename to framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest2FindArgsContractMinTest.sol diff --git a/src/test/resources/soliditycode_v0.4.25/assertExceptiontest3ByteMinContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest3ByteMinContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/assertExceptiontest3ByteMinContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest3ByteMinContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/assertExceptiontest4Enum.sol b/framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest4Enum.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/assertExceptiontest4Enum.sol rename to framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest4Enum.sol diff --git a/src/test/resources/soliditycode_v0.4.25/assertExceptiontest5MoveRight.sol b/framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest5MoveRight.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/assertExceptiontest5MoveRight.sol rename to framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest5MoveRight.sol diff --git a/src/test/resources/soliditycode_v0.4.25/assertExceptiontest6UninitializedContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest6UninitializedContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/assertExceptiontest6UninitializedContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest6UninitializedContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/assertExceptiontest7TestAssertContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest7TestAssertContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/assertExceptiontest7TestAssertContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/assertExceptiontest7TestAssertContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/codeSaftySupport.sol b/framework/src/test/resources/soliditycode_v0.4.25/codeSaftySupport.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/codeSaftySupport.sol rename to framework/src/test/resources/soliditycode_v0.4.25/codeSaftySupport.sol diff --git a/src/test/resources/soliditycode_v0.4.25/codeSaftyUnsupport.sol b/framework/src/test/resources/soliditycode_v0.4.25/codeSaftyUnsupport.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/codeSaftyUnsupport.sol rename to framework/src/test/resources/soliditycode_v0.4.25/codeSaftyUnsupport.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGetterContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGetterContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGetterContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGetterContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar001test1Grammar001.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test1Grammar001.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar001test1Grammar001.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test1Grammar001.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar001test2Grammar002.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test2Grammar002.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar001test2Grammar002.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test2Grammar002.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar001test3Grammar003.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test3Grammar003.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar001test3Grammar003.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test3Grammar003.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar001test4Grammar004.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test4Grammar004.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar001test4Grammar004.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test4Grammar004.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar001test5Grammar006.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test5Grammar006.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar001test5Grammar006.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar001test5Grammar006.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_1.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_1.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_1.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_1.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_2.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_2.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_2.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test1Grammar007_2.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar002test2Grammar008.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test2Grammar008.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar002test2Grammar008.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test2Grammar008.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar002test3Grammar010.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test3Grammar010.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar002test3Grammar010.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test3Grammar010.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar011.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar011.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar011.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar011.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar012.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar012.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar012.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test4Grammar012.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar002test6Grammar013.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test6Grammar013.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar002test6Grammar013.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar002test6Grammar013.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar003test1Grammar014.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test1Grammar014.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar003test1Grammar014.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test1Grammar014.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar003test2Grammar015.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test2Grammar015.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar003test2Grammar015.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test2Grammar015.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar003test3Grammar016.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test3Grammar016.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar003test3Grammar016.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test3Grammar016.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar003test4Grammar017.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test4Grammar017.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar003test4Grammar017.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test4Grammar017.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar003test5Grammar018.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test5Grammar018.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar003test5Grammar018.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test5Grammar018.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar003test6Grammar019.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test6Grammar019.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar003test6Grammar019.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test6Grammar019.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractGrammar003test7Grammar020.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test7Grammar020.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractGrammar003test7Grammar020.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractGrammar003test7Grammar020.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInnerContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInnerContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInnerContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInnerContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction001.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction001.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction001.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction001.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction002.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction002.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction002.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction002.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction003.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction003.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction003.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction003.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction004.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction004.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction004.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction004.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction005.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction005.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction005.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction005.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction006.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction006.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction006.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction001testInternalTransaction006.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test1InternalTransaction007.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test1InternalTransaction007.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test1InternalTransaction007.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test1InternalTransaction007.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test2InternalTransaction008.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test2InternalTransaction008.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test2InternalTransaction008.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test2InternalTransaction008.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test3InternalTransaction009.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test3InternalTransaction009.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test3InternalTransaction009.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test3InternalTransaction009.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test4InternalTransaction010.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test4InternalTransaction010.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test4InternalTransaction010.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test4InternalTransaction010.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test5InternalTransaction012.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test5InternalTransaction012.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test5InternalTransaction012.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction002test5InternalTransaction012.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction013.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction013.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction013.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction013.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction014.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction014.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction014.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction014.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction015.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction015.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction015.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction015.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction016.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction016.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction016.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction016.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction017.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction017.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction017.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction017.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction018.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction018.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction018.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractInternalTransaction003testInternalTransaction018.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractLinkage001.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractLinkage001.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractLinkage001.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractLinkage001.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractLinkage002.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractLinkage002.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractLinkage002.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractLinkage002.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractLinkage003.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractLinkage003.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractLinkage003.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractLinkage003.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractLinkage004.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractLinkage004.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractLinkage004.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractLinkage004.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractLinkage005.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractLinkage005.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractLinkage005.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractLinkage005.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractLinkage006.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractLinkage006.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractLinkage006.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractLinkage006.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit001.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit001.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit001.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit001.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit004.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit004.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit004.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractOriginEnergyLimit004.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractOtherToTrcToken.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractOtherToTrcToken.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractOtherToTrcToken.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractOtherToTrcToken.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario001.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario001.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario001.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario001.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario002.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario002.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario002.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario002.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario003.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario003.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario003.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario003.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario004.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario004.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario004.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario004.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario005.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario005.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario005.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario005.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario006.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario006.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario006.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario006.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario007.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario007.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario007.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario007.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario008.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario008.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario008.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario008.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario009.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario009.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario009.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario009.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario010.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario010.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario010.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario010.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario011.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario011.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario011.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario011.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario012.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario012.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario012.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario012.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario013.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario013.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario013.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario013.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractScenario014.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractScenario014.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractScenario014.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractScenario014.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTest.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTest.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTest.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTest.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractToMathedFeed.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractToMathedFeed.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractToMathedFeed.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractToMathedFeed.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken001.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken001.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken001.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken001.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken002.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken002.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken002.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken002.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken003.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken003.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken003.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken003.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken005.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken005.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken005.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken005.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken011.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken011.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken011.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken011.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken012.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken012.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken012.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken012.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken014.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken014.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken014.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken014.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken018.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken018.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken018.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken018.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken023.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken023.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken023.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken023.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken026.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken026.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken026.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken026.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken027.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken027.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken027.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken027.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken028.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken028.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken028.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken028.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken029.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken029.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken029.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken029.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken030.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken030.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken030.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken030.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken031.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken031.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken031.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken031.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken034.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken034.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken034.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken034.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken035.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken035.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken035.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken035.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken036.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken036.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken036.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken036.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken037.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken037.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken037.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken037.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken038.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken038.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken038.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken038.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken039.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken039.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken039.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken039.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken041.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken041.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken041.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken041.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken043.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken043.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken043.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken043.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken048.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken048.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken048.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken048.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken049.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken049.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken049.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken049.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken050.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken050.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken050.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken050.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken051.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken051.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken051.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken051.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken052.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken052.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken052.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken052.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken054.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken054.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken054.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken054.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken055.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken055.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken055.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken055.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken060.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken060.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken060.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken060.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken061.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken061.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken061.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken061.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken064.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken064.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken064.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken064.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken066.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken066.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken066.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken066.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken067.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken067.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken067.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken067.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken073.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken073.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken073.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken073.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken075.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken075.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken075.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken075.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken076.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken076.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken076.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken076.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken077.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken077.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken077.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken077.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken078.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken078.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken078.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken078.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken079.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken079.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken079.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken079.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcToken080.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken080.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcToken080.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcToken080.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractTrcTokenToOther.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractTrcTokenToOther.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractTrcTokenToOther.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractTrcTokenToOther.sol diff --git a/src/test/resources/soliditycode_v0.4.25/contractUnknownException.sol b/framework/src/test/resources/soliditycode_v0.4.25/contractUnknownException.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/contractUnknownException.sol rename to framework/src/test/resources/soliditycode_v0.4.25/contractUnknownException.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest1TestRequireContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest1TestRequireContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest1TestRequireContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest1TestRequireContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest2TestThrowsContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest2TestThrowsContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest2TestThrowsContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest2TestThrowsContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest3TestRevertContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest3TestRevertContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest3TestRevertContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest3TestRevertContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest4noPayableContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest4noPayableContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest4noPayableContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest4noPayableContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest5noPayableConstructor.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest5noPayableConstructor.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest5noPayableConstructor.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest5noPayableConstructor.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest6transferTestContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest6transferTestContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest6transferTestContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest6transferTestContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest7payableFallbakContract.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest7payableFallbakContract.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest7payableFallbakContract.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest7payableFallbakContract.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest8newContractGasNoenough.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest8newContractGasNoenough.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest8newContractGasNoenough.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest8newContractGasNoenough.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontest9MessageUsedErrorFeed.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest9MessageUsedErrorFeed.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontest9MessageUsedErrorFeed.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontest9MessageUsedErrorFeed.sol diff --git a/src/test/resources/soliditycode_v0.4.25/requireExceptiontestFunctionUsedErrorFeed.sol b/framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontestFunctionUsedErrorFeed.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/requireExceptiontestFunctionUsedErrorFeed.sol rename to framework/src/test/resources/soliditycode_v0.4.25/requireExceptiontestFunctionUsedErrorFeed.sol diff --git a/src/test/resources/soliditycode_v0.4.25/walletTestMutiSign004.sol b/framework/src/test/resources/soliditycode_v0.4.25/walletTestMutiSign004.sol similarity index 100% rename from src/test/resources/soliditycode_v0.4.25/walletTestMutiSign004.sol rename to framework/src/test/resources/soliditycode_v0.4.25/walletTestMutiSign004.sol diff --git a/src/test/resources/testng.conf b/framework/src/test/resources/testng.conf similarity index 100% rename from src/test/resources/testng.conf rename to framework/src/test/resources/testng.conf diff --git a/src/test/resources/testng.xml b/framework/src/test/resources/testng.xml similarity index 100% rename from src/test/resources/testng.xml rename to framework/src/test/resources/testng.xml diff --git a/start.sh b/framework/start.sh similarity index 100% rename from start.sh rename to framework/start.sh diff --git a/tron.enc b/framework/tron.enc similarity index 100% rename from tron.enc rename to framework/tron.enc diff --git a/tron.sh b/framework/tron.sh similarity index 100% rename from tron.sh rename to framework/tron.sh diff --git a/ver.sh b/framework/ver.sh similarity index 100% rename from ver.sh rename to framework/ver.sh diff --git a/work.sh b/framework/work.sh similarity index 100% rename from work.sh rename to framework/work.sh diff --git "a/\346\263\242\345\234\272Protobuf\345\215\217\350\256\256\346\226\207\346\241\243.md" "b/framework/\346\263\242\345\234\272Protobuf\345\215\217\350\256\256\346\226\207\346\241\243.md" similarity index 100% rename from "\346\263\242\345\234\272Protobuf\345\215\217\350\256\256\346\226\207\346\241\243.md" rename to "framework/\346\263\242\345\234\272Protobuf\345\215\217\350\256\256\346\226\207\346\241\243.md" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 27768f1bbac..28861d273a5 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 244f55d0b14..1b0ff046d00 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Feb 14 20:55:40 CET 2018 +#Thu Aug 01 15:17:43 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip diff --git a/gradlew b/gradlew index bda416feaa4..cccdd3d517f 100755 --- a/gradlew +++ b/gradlew @@ -169,4 +169,4 @@ if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi -exec "$JAVACMD" "$@" --no-daemon +exec "$JAVACMD" "$@" diff --git a/protocol/build.gradle b/protocol/build.gradle new file mode 100644 index 00000000000..445bd979d12 --- /dev/null +++ b/protocol/build.gradle @@ -0,0 +1,16 @@ +plugins { + id 'java' +} + +group 'tronprotocol' +version '1.0-SNAPSHOT' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' +} diff --git a/settings.gradle b/settings.gradle index 977dac6036e..1cdb9f691ca 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,5 @@ -rootProject.name = 'java-tron' - +rootProject.name = 'javatron' +include 'framework' +include 'chainbase' +include 'protocol' + diff --git a/src/main/java/org/tron/common/overlay/client/DatabaseGrpcClient.java b/src/main/java/org/tron/common/overlay/client/DatabaseGrpcClient.java deleted file mode 100644 index 7a2da659275..00000000000 --- a/src/main/java/org/tron/common/overlay/client/DatabaseGrpcClient.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.tron.common.overlay.client; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import org.tron.api.DatabaseGrpc; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.DynamicProperties; - -public class DatabaseGrpcClient { - - private final ManagedChannel channel; - private final DatabaseGrpc.DatabaseBlockingStub databaseBlockingStub; - - public DatabaseGrpcClient(String host, int port) { - channel = ManagedChannelBuilder.forAddress(host, port) - .usePlaintext(true) - .build(); - databaseBlockingStub = DatabaseGrpc.newBlockingStub(channel); - } - - public DatabaseGrpcClient(String host) { - channel = ManagedChannelBuilder.forTarget(host) - .usePlaintext(true) - .build(); - databaseBlockingStub = DatabaseGrpc.newBlockingStub(channel); - } - - - public Block getBlock(long blockNum) { - if (blockNum < 0) { - return databaseBlockingStub.getNowBlock(EmptyMessage.newBuilder().build()); - } - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return databaseBlockingStub.getBlockByNum(builder.build()); - } - - public void shutdown() { - channel.shutdown(); - } - - public DynamicProperties getDynamicProperties() { - return databaseBlockingStub.getDynamicProperties(EmptyMessage.newBuilder().build()); - } -} diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount001.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount001.java deleted file mode 100644 index 315e0123543..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount001.java +++ /dev/null @@ -1,243 +0,0 @@ -package stest.tron.wallet.account; - -import com.google.protobuf.ByteString; -import com.googlecode.cqengine.query.simple.In; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class WalletTestAccount001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String invalidTestKey = - "592BB6C9BB255409A6A45EFD18E9A74FECDDCCE93A40D96B70FBE334E6361E36"; - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test - public void testqueryaccountfromfullnode() { - //Query success, get the right balance,bandwidth and the account name. - Account queryResult = queryAccount(testKey002, blockingStubFull); - /* Account queryResult = PublicMethed.queryAccountByAddress(fromAddress,blockingStubFull); - logger.info(ByteArray.toStr(queryResult.getAccountName().toByteArray())); - logger.info(Long.toString(queryResult.getBalance())); - logger.info(ByteArray.toStr(queryResult.getAddress().toByteArray()));*/ - Assert.assertTrue(queryResult.getBalance() > 0); - //Assert.assertTrue(queryResult.getBandwidth() >= 0); - Assert.assertTrue(queryResult.getAccountName().toByteArray().length > 0); - Assert.assertFalse(queryResult.getAddress().isEmpty()); - - //Query failed - Account invalidQueryResult = queryAccount(invalidTestKey, blockingStubFull); - Assert.assertTrue(invalidQueryResult.getAccountName().isEmpty()); - Assert.assertTrue(invalidQueryResult.getAddress().isEmpty()); - - //Improve coverage. - queryResult.hashCode(); - queryResult.getSerializedSize(); - queryResult.equals(queryResult); - queryResult.equals(invalidQueryResult); - } - - @Test - public void testqueryaccountfromsoliditynode() { - //Query success, get the right balance,bandwidth and the account name. - Account queryResult = solidityqueryAccount(testKey002, blockingStubSolidity); - Assert.assertTrue(queryResult.getBalance() > 0); - //Assert.assertTrue(queryResult.getBandwidth() >= 0); - Assert.assertTrue(queryResult.getAccountName().toByteArray().length > 0); - Assert.assertFalse(queryResult.getAddress().isEmpty()); - - //Query failed - Account invalidQueryResult = solidityqueryAccount(invalidTestKey, blockingStubSolidity); - Assert.assertTrue(invalidQueryResult.getAccountName().isEmpty()); - Assert.assertTrue(invalidQueryResult.getAddress().isEmpty()); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - logger.info(Integer.toString(ecKey.getAddress().length)); - - //PublicMethed.AddPreFix(); - logger.info(Integer.toString(ecKey.getAddress().length)); - System.out.println("address ====== " + ByteArray.toHexString(ecKey.getAddress())); - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - //return grpcQueryAccount(address,blockingStubFull); - } - - /** - * constructor. - */ - - public Account solidityqueryAccount(String priKey, - WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - //byte[] address = PublicMethed.AddPreFix(ecKey.getAddress()); - return grpcQueryAccountSolidity(ecKey.getAddress(), blockingStubSolidity); - //return grpcQueryAccountSolidity(address,blockingStubSolidity); - } - - /** - * constructor. - */ - - public String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, - WalletGrpc.WalletBlockingStub blockingStubFull) { - //address = PublicMethed.AddPreFix(address); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Account grpcQueryAccountSolidity(byte[] address, - WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity) { - //address = PublicMethed.AddPreFix(address); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubSolidity.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount003.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount003.java deleted file mode 100644 index 5c27bb462ac..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount003.java +++ /dev/null @@ -1,491 +0,0 @@ -package stest.tron.wallet.account; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class WalletTestAccount003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static final String name = "testAssetIssue_" + Long.toString(now); - private static final long TotalSupply = now; - String mostLongNamePlusOneChar = "1abcdeabcdefabcdefg1abcdefg10o0og1abcdefg10o0oabcd" - + "efabcdefg1abcdefg10o0og1abcdefg10o0oabcdefabcdefg1abcdefg10o0og1abcdefg10o0oab" - + "cdefabcdefg1abcdefg10o0og1abcdefg10o0ofabcdefg1abcdefg10o0og1abcdefg10o0o"; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] noBandwitchAddress = ecKey1.getAddress(); - String noBandwitch = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - PublicMethed.printAddress(lowBalTest); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test - public void test1CreateAccount() { - Account noCreateAccount = PublicMethed.queryAccount(lowBalTest, blockingStubFull); - while (noCreateAccount.getBalance() != 0) { - ecKey = new ECKey(Utils.getRandom()); - lowBalAddress = ecKey.getAddress(); - lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - noCreateAccount = PublicMethed.queryAccount(lowBalTest, blockingStubFull); - } - Assert.assertTrue(sendCoin(lowBalAddress, 1L, fromAddress, testKey002)); - noCreateAccount = PublicMethed.queryAccount(lowBalTest, blockingStubFull); - logger.info(Long.toString(noCreateAccount.getBalance())); - Assert.assertTrue(noCreateAccount.getBalance() == 1); - } - - @Test(enabled = true) - public void test2UpdateAccount() { - Assert.assertFalse(PublicMethed.updateAccount(lowBalAddress, - mostLongNamePlusOneChar.getBytes(), lowBalTest, blockingStubFull)); - Assert.assertFalse(PublicMethed.updateAccount(lowBalAddress, "".getBytes(), lowBalTest, - blockingStubFull)); - String mostLongName = getRandomStr(33); - Assert.assertTrue(PublicMethed.updateAccount(lowBalAddress, mostLongName.getBytes(), lowBalTest, - blockingStubFull)); - String firstUpdateName = getRandomStr(32); - Assert.assertFalse(PublicMethed.updateAccount(lowBalAddress, firstUpdateName.getBytes(), - lowBalTest, blockingStubFull)); - String secondUpdateName = getRandomStr(15); - Assert.assertFalse(PublicMethed.updateAccount(lowBalAddress, secondUpdateName.getBytes(), - lowBalTest, blockingStubFull)); - } - - @Test(enabled = true) - public void test3NoBalanceCreateAssetIssue() { - Account lowaccount = PublicMethed.queryAccount(lowBalTest, blockingStubFull); - if (lowaccount.getBalance() > 0) { - Assert.assertTrue(sendCoin(toAddress, lowaccount.getBalance(), lowBalAddress, lowBalTest)); - } - //Create AssetIssue failed when there is no enough balance. - Assert.assertFalse(PublicMethed.createAssetIssue(lowBalAddress, name, TotalSupply, 1, 1, - now + 100000000L, now + 10000000000L, 2, description, url, 10000L, - 10000L, 1L, 1L, lowBalTest, blockingStubFull)); - logger.info("nobalancecreateassetissue"); - } - - @Test(enabled = true) - public void test4NoBalanceTransferTrx() { - //Send Coin failed when there is no enough balance. - Assert.assertFalse(sendCoin(toAddress, 100000000000000000L, lowBalAddress, lowBalTest)); - } - - @Test(enabled = true) - public void test5NoBalanceCreateWitness() { - //Apply to be super witness failed when no enough balance. - Assert.assertFalse(createWitness(lowBalAddress, fromAddress, lowBalTest)); - } - - @Test(enabled = true) - public void test6NoFreezeBalanceToUnfreezeBalance() { - //Unfreeze account failed when no freeze balance - Account noFreezeAccount = PublicMethed.queryAccount(lowBalTest, blockingStubFull); - if (noFreezeAccount.getFrozenCount() == 0) { - Assert.assertFalse(unFreezeBalance(lowBalAddress, lowBalTest)); - } else { - logger.info("This account has freeze balance, please test this case for manual"); - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createWitness(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Boolean sendCoin(byte[] to, long amount, byte[] owner, String priKey) { - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(TotalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - - Protocol.Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info("Please check!!! response.getresult==false"); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - class AccountComparator implements Comparator { - - public int compare(Object o1, Object o2) { - return Long.compare(((Account) o2).getBalance(), ((Account) o1).getBalance()); - } - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Protocol.Transaction signTransaction(ECKey ecKey, Protocol.Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] address, String priKey) { - //byte[] address = address; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UnfreezeBalanceContract.Builder builder = Contract.UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeBalanceContract contract = builder.build(); - - Protocol.Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] address, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] addRess = WalletClient.decodeFromBase58Check(addressBase58); - if (addRess == null) { - return false; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(addRess)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Protocol.Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info("response.getresult() == false"); - return false; - } - return true; - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - return true; - - - } - - /** - * constructor. - */ - - public static String getRandomStr(int length) { - String base = "abcdefghijklmnopqrstuvwxyz0123456789"; - int randomNum; - char randomChar; - Random random = new Random(); - StringBuffer str = new StringBuffer(); - - for (int i = 0; i < length; i++) { - randomNum = random.nextInt(base.length()); - randomChar = base.charAt(randomNum); - str.append(randomChar); - } - return str.toString(); - } - -} - - - diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount004.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount004.java deleted file mode 100644 index b0e6724cf48..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount004.java +++ /dev/null @@ -1,348 +0,0 @@ -package stest.tron.wallet.account; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAccount004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final String noFrozenBalanceTestKey = - "8CB4480194192F30907E14B52498F594BD046E21D7C4D8FE866563A6760AC891"; - - - private final byte[] noFrozenAddress = PublicMethed.getFinalAddress(noFrozenBalanceTestKey); - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - - Long freezeAmount = 2000000L; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - - - } - - - @Test(enabled = true) - public void testFreezeBalance() { - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] account004AddressForFreeze = ecKey2.getAddress(); - String account004KeyForFreeze = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(account004AddressForFreeze, 10000000, - fromAddress, testKey002, blockingStubFull)); - //Freeze failed when freeze amount is large than currently balance. - Assert.assertFalse(freezeBalance(account004AddressForFreeze, 9000000000000000000L, - 3L, account004KeyForFreeze)); - //Freeze failed when freeze amount less than 1Trx - Assert.assertFalse(freezeBalance(account004AddressForFreeze, 999999L, 3L, - account004KeyForFreeze)); - //Freeze failed when freeze duration isn't 3 days. - //Assert.assertFalse(freezeBalance(fromAddress, 1000000L, 2L, testKey002)); - //Unfreeze balance failed when 3 days hasn't come. - Assert.assertFalse(PublicMethed.unFreezeBalance(account004AddressForFreeze, - account004KeyForFreeze, 0, null, blockingStubFull)); - //Freeze failed when freeze amount is 0. - Assert.assertFalse(freezeBalance(account004AddressForFreeze, 0L, 3L, - account004KeyForFreeze)); - //Freeze failed when freeze amount is -1. - Assert.assertFalse(freezeBalance(account004AddressForFreeze, -1L, 3L, - account004KeyForFreeze)); - //Freeze failed when freeze duration is -1. - //Assert.assertFalse(freezeBalance(fromAddress, 1000000L, -1L, testKey002)); - //Freeze failed when freeze duration is 0. - //Assert.assertFalse(freezeBalance(fromAddress, 1000000L, 0L, testKey002)); - - } - - @Test(enabled = true) - public void testUnFreezeBalance() { - //Unfreeze failed when there is no freeze balance. - //Wait to be create account - - Assert.assertFalse(PublicMethed.unFreezeBalance(noFrozenAddress, noFrozenBalanceTestKey, 1, - null, blockingStubFull)); - logger.info("Test unfreezebalance"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] account004Address = ecKey1.getAddress(); - String account004Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert - .assertTrue(PublicMethed.sendcoin(account004Address, freezeAmount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalance(account004Address, freezeAmount, 0, - account004Key, blockingStubFull)); - Account account004; - account004 = PublicMethed.queryAccount(account004Address, blockingStubFull); - Assert.assertTrue(account004.getBalance() == 0); - Assert.assertTrue(PublicMethed.unFreezeBalance(account004Address, account004Key, 0, - null, blockingStubFull)); - account004 = PublicMethed.queryAccount(account004Address, blockingStubFull); - Assert.assertTrue(account004.getBalance() == freezeAmount); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(account004Address, freezeAmount, 0, - 1, account004Key, blockingStubFull)); - account004 = PublicMethed.queryAccount(account004Address, blockingStubFull); - Assert.assertTrue(account004.getBalance() == 0); - - Assert.assertFalse(PublicMethed.unFreezeBalance(account004Address, account004Key, 0, - null, blockingStubFull)); - Assert.assertTrue(PublicMethed.unFreezeBalance(account004Address, account004Key, 1, - null, blockingStubFull)); - account004 = PublicMethed.queryAccount(account004Address, blockingStubFull); - Assert.assertTrue(account004.getBalance() == freezeAmount); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Block currentBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - - Long afterBlockNum = 0L; - Integer wait = 0; - PublicMethed.waitProduceNextBlock(searchBlockingStubFull); - /* while (afterBlockNum < beforeBlockNum + 1 && wait < 10) { - Block currentBlock1 = searchBlockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - wait++; - try { - Thread.sleep(2000); - logger.info("wait 2 second"); - } catch (InterruptedException e) { - e.printStackTrace(); - } - }*/ - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "beforefronen" + beforeFrozenBalance.toString() + " afterfronzen" + afterFrozenBalance - .toString()); - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(afterBandwidth - beforeBandwidth == freezeBalance * frozen_duration); - return true; - - - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount005.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount005.java deleted file mode 100644 index 39c738c59ba..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount005.java +++ /dev/null @@ -1,269 +0,0 @@ -package stest.tron.wallet.account; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAccount005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final String notWitnessTestKey = - "8CB4480194192F30907E14B52498F594BD046E21D7C4D8FE866563A6760AC891"; - - private final byte[] notWitness = PublicMethed.getFinalAddress(notWitnessTestKey); - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - - - } - - @Test - public void testWithdrawBalance() { - //Withdraw failed when you are not witness - Assert.assertFalse(withdrawBalance(notWitness, notWitnessTestKey)); - //Due to it's hard to automation, withdraw balance success case is not automation, - // please test by manual - //Assert.assertTrue(WithdrawBalance(fromAddress,testKey002)); - //Withdraw failed when the latest time to withdraw within 1 day. - - if (withdrawBalance(fromAddress, testKey002)) { - Assert.assertFalse(withdrawBalance(fromAddress, testKey002)); - } else { - logger.info("This account has withdraw within 1 day, please confirm"); - } - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public boolean withdrawBalance(byte[] address, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.WithdrawBalanceContract.Builder builder = Contract.WithdrawBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - Contract.WithdrawBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.withdrawBalance(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } - logger.info("test withdraw" + priKey); - return true; - - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] address, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] addRess = WalletClient.decodeFromBase58Check(addressBase58); - if (addRess == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - Account afterVote = queryAccount(ecKey, searchBlockingStubFull); - //Long afterVoteNum = afterVote.getVotes(0).getVoteCount(); - for (String key : witness.keySet()) { - for (int j = 0; j < afterVote.getVotesCount(); j++) { - if (key.equals(afterVote.getVotes(j).getVoteAddress())) { - Long afterVoteNum = Long.parseLong(witness.get(key)); - Assert.assertTrue(afterVoteNum == afterVote.getVotes(j).getVoteCount()); - logger.info("test equal vote"); - } - } - } - return true; - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount006.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount006.java deleted file mode 100644 index d24ddee2c18..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount006.java +++ /dev/null @@ -1,196 +0,0 @@ -package stest.tron.wallet.account; - -import com.google.protobuf.ByteString; -import com.googlecode.cqengine.query.simple.In; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue012_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 20000000000L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - private static final long FREENETLIMIT = 5000L; - private static final long BASELINE = 4800L; - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] account006Address = ecKey.getAddress(); - String account006Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(account006Key); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void test1GetAccountNet() { - ecKey = new ECKey(Utils.getRandom()); - account006Address = ecKey.getAddress(); - account006Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - //Sendcoin to this account - ByteString addressBS1 = ByteString.copyFrom(account006Address); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - Assert.assertTrue(PublicMethed.freezeBalance(fromAddress, 100000000, 3, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .sendcoin(account006Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - - //Get new account net information. - ByteString addressBs = ByteString.copyFrom(account006Address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - AccountNetMessage accountNetMessage = blockingStubFull.getAccountNet(request); - logger.info(Long.toString(accountNetMessage.getNetLimit())); - logger.info(Long.toString(accountNetMessage.getNetUsed())); - logger.info(Long.toString(accountNetMessage.getFreeNetLimit())); - logger.info(Long.toString(accountNetMessage.getFreeNetUsed())); - logger.info(Long.toString(accountNetMessage.getTotalNetLimit())); - logger.info(Long.toString(accountNetMessage.getTotalNetWeight())); - Assert.assertTrue(accountNetMessage.getNetLimit() == 0); - Assert.assertTrue(accountNetMessage.getNetUsed() == 0); - Assert.assertTrue(accountNetMessage.getFreeNetLimit() == FREENETLIMIT); - Assert.assertTrue(accountNetMessage.getFreeNetUsed() == 0); - Assert.assertTrue(accountNetMessage.getTotalNetLimit() > 0); - Assert.assertTrue(accountNetMessage.getTotalNetWeight() > 0); - logger.info("testGetAccountNet"); - - } - - @Test(enabled = true) - public void test2UseFreeNet() { - - //Transfer some TRX to other to test free net cost. - Assert.assertTrue(PublicMethed.sendcoin(fromAddress, 1L, account006Address, - account006Key, blockingStubFull)); - ByteString addressBs = ByteString.copyFrom(account006Address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - AccountNetMessage accountNetMessage = blockingStubFull.getAccountNet(request); - //Every transaction may cost 200 net. - Assert.assertTrue(accountNetMessage.getFreeNetUsed() > 0 && accountNetMessage - .getFreeNetUsed() < 300); - logger.info("testUseFreeNet"); - } - - @Test(enabled = true) - public void test3UseMoneyToDoTransaction() { - Assert.assertTrue(PublicMethed.sendcoin(account006Address, 1000000L, fromAddress, - testKey002, blockingStubFull)); - ByteString addressBs = ByteString.copyFrom(account006Address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - AccountNetMessage accountNetMessage = blockingStubFull.getAccountNet(request); - //Use out the free net - Integer times = 0; - while (accountNetMessage.getFreeNetUsed() < BASELINE && times++ < 30) { - PublicMethed.sendcoin(fromAddress, 1L, account006Address, account006Key, - blockingStubFull); - accountNetMessage = blockingStubFull.getAccountNet(request); - } - - Account queryAccount = PublicMethed.queryAccount(account006Key, blockingStubFull); - Long beforeSendBalance = queryAccount.getBalance(); - Assert.assertTrue(PublicMethed.sendcoin(fromAddress, 1L, account006Address, account006Key, - blockingStubFull)); - queryAccount = PublicMethed.queryAccount(account006Key, blockingStubFull); - Long afterSendBalance = queryAccount.getBalance(); - //when the free net is not enough and no balance freeze, use money to do the transaction. - Assert.assertTrue(beforeSendBalance - afterSendBalance > 1); - logger.info("testUseMoneyToDoTransaction"); - } - - @Test(enabled = true) - public void test4UseNet() { - //Freeze balance to own net. - Assert.assertTrue(PublicMethed.freezeBalance(account006Address, 10000000L, - 3, account006Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1L, account006Address, - account006Key, blockingStubFull)); - ByteString addressBs = ByteString.copyFrom(account006Address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - AccountNetMessage accountNetMessage = blockingStubFull.getAccountNet(request); - Assert.assertTrue(accountNetMessage.getNetLimit() > 0); - Assert.assertTrue(accountNetMessage.getNetUsed() > 150); - - Account queryAccount = PublicMethed.queryAccount(account006Key, blockingStubFull); - Long beforeSendBalance = queryAccount.getBalance(); - Assert.assertTrue(PublicMethed.sendcoin(fromAddress, 1L, account006Address, - account006Key, blockingStubFull)); - queryAccount = PublicMethed.queryAccount(account006Key, blockingStubFull); - Long afterSendBalance = queryAccount.getBalance(); - //when you freeze balance and has net,you didn't cost money. - logger.info("before is " + Long.toString(beforeSendBalance) + " and after is " - + Long.toString(afterSendBalance)); - Assert.assertTrue(beforeSendBalance - afterSendBalance == 1); - addressBs = ByteString.copyFrom(account006Address); - request = Account.newBuilder().setAddress(addressBs).build(); - accountNetMessage = blockingStubFull.getAccountNet(request); - //when you freeze balance and has net,you cost net. - logger.info(Long.toString(accountNetMessage.getNetUsed())); - Assert.assertTrue(accountNetMessage.getNetUsed() > 350); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount007.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount007.java deleted file mode 100644 index 33a43ae1140..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount007.java +++ /dev/null @@ -1,142 +0,0 @@ -package stest.tron.wallet.account; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue012_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - private static final long FREENETLIMIT = 5000L; - private static final long BASELINE = 4800L; - - //owner account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] account007Address = ecKey1.getAddress(); - String account007Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - //Wait to be create account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] newAccountAddress = ecKey2.getAddress(); - String newAccountKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(account007Key); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - @Test(enabled = true) - public void testCreateAccount() { - Assert.assertTrue(PublicMethed.sendcoin(account007Address, 10000000, - fromAddress, testKey002, blockingStubFull)); - Account accountInfo = PublicMethed.queryAccount(account007Key, blockingStubFull); - final Long beforeBalance = accountInfo.getBalance(); - - AccountNetMessage accountNetInfo = PublicMethed.getAccountNet(account007Address, - blockingStubFull); - final Long beforeFreeNet = accountNetInfo.getFreeNetUsed(); - - Assert.assertTrue(PublicMethed.createAccount(account007Address, newAccountAddress, - account007Key, blockingStubFull)); - - accountInfo = PublicMethed.queryAccount(account007Key, blockingStubFull); - Long afterBalance = accountInfo.getBalance(); - - accountNetInfo = PublicMethed.getAccountNet(account007Address, - blockingStubFull); - Long afterFreeNet = accountNetInfo.getFreeNetUsed(); - - logger.info(Long.toString(beforeBalance)); - logger.info(Long.toString(afterBalance)); - - //When creator has no bandwidth, he can't use the free net. - Assert.assertTrue(afterFreeNet == beforeFreeNet); - - //When the creator has no bandwidth, create a new account should spend 0.1TRX. - Assert.assertTrue(beforeBalance - afterBalance == 100000); - } - - @Test(enabled = true) - public void testExceptionCreateAccount() { - //Try to create an exist account - Assert - .assertFalse(PublicMethed.createAccount(account007Address, account007Address, account007Key, - blockingStubFull)); - - //Try to create an invalid account - byte[] wrongAddress = "wrongAddress".getBytes(); - Assert.assertFalse(PublicMethed.createAccount(account007Address, wrongAddress, account007Key, - blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount009.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount009.java deleted file mode 100644 index 491581dd344..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount009.java +++ /dev/null @@ -1,134 +0,0 @@ -package stest.tron.wallet.account; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue012_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - private static final long FREENETLIMIT = 5000L; - private static final long BASELINE = 4800L; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] account009Address = ecKey1.getAddress(); - String account009Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] account009SecondAddress = ecKey2.getAddress(); - String account009SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] account009InvalidAddress = ecKey3.getAddress(); - String account009InvalidKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(account009Key); - PublicMethed.printAddress(account009SecondKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - @Test(enabled = true) - public void testGetEnergy() { - Assert.assertTrue(PublicMethed.sendcoin(account009Address, 10000000, - fromAddress, testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(account009SecondAddress, 10000000, - fromAddress, testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(account009InvalidAddress, 10000000, - fromAddress, testKey002, blockingStubFull)); - - Account account009Info = PublicMethed.queryAccount(account009Key, blockingStubFull); - logger.info(Long.toString( - account009Info.getAccountResource().getFrozenBalanceForEnergy().getExpireTime())); - Assert.assertTrue(account009Info.getAccountResource().getEnergyUsage() == 0); - Assert.assertTrue(account009Info.getAccountResource().getFrozenBalanceForEnergy() - .getExpireTime() == 0); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(account009Address, 1000000L, - 3, 1, account009Key, blockingStubFull)); - account009Info = PublicMethed.queryAccount(account009Key, blockingStubFull); - Assert.assertTrue(account009Info.getAccountResource().getEnergyUsage() == 0); - Assert.assertTrue(account009Info.getAccountResource().getFrozenBalanceForEnergy() - .getFrozenBalance() == 1000000L); - - AccountResourceMessage account009Resource = PublicMethed.getAccountResource(account009Address, - blockingStubFull); - Assert.assertTrue(account009Resource.getTotalEnergyLimit() >= 50000000000L); - Assert.assertTrue(account009Resource.getEnergyLimit() > 0); - Assert.assertTrue(account009Resource.getTotalEnergyWeight() >= 1); - } - - @Test(enabled = true) - public void testGetEnergyInvalid() { - //The resourceCode can only be 0 or 1 - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(account009InvalidAddress, - 1000000L, 3, 0, account009InvalidKey, blockingStubFull)); - Assert.assertFalse(PublicMethed.freezeBalanceGetEnergy(account009InvalidAddress, 1000000L, - 3, -1, account009InvalidKey, blockingStubFull)); - Assert.assertFalse(PublicMethed.freezeBalanceGetEnergy(account009InvalidAddress, 1000000L, - 3, 2, account009InvalidKey, blockingStubFull)); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount011.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount011.java deleted file mode 100644 index 0688f6ff30c..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount011.java +++ /dev/null @@ -1,93 +0,0 @@ -package stest.tron.wallet.account; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] account011Address = ecKey1.getAddress(); - String account011Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(account011Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - } - - @Test(enabled = true) - public void testgenerateAddress() { - EmptyMessage.Builder builder = EmptyMessage.newBuilder(); - blockingStubFull.generateAddress(builder.build()); - blockingStubSolidity.generateAddress(builder.build()); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - - } - - } -} diff --git a/src/test/java/stest/tron/wallet/account/WalletTestAccount013.java b/src/test/java/stest/tron/wallet/account/WalletTestAccount013.java deleted file mode 100644 index 39129298c5f..00000000000 --- a/src/test/java/stest/tron/wallet/account/WalletTestAccount013.java +++ /dev/null @@ -1,482 +0,0 @@ -package stest.tron.wallet.account; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount013 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - Optional infoById = null; - long account013BeforeBalance; - long freezeAmount = 10000000L; - long freezeDuration = 0; - - byte[] account013Address; - String testKeyForAccount013; - byte[] receiverDelegateAddress; - String receiverDelegateKey; - byte[] emptyAddress; - String emptyKey; - byte[] account4DelegatedResourceAddress; - String account4DelegatedResourceKey; - byte[] account5DelegatedResourceAddress; - String account5DelegatedResourceKey; - byte[] accountForDeployAddress; - String accountForDeployKey; - byte[] accountForAssetIssueAddress; - String accountForAssetIssueKey; - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKey002); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void test1DelegateResourceForBandwidthAndEnergy() { - //Create account013 - ECKey ecKey1 = new ECKey(Utils.getRandom()); - account013Address = ecKey1.getAddress(); - testKeyForAccount013 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - //Create receiver - ECKey ecKey2 = new ECKey(Utils.getRandom()); - receiverDelegateAddress = ecKey2.getAddress(); - receiverDelegateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - //Create Empty account - ECKey ecKey3 = new ECKey(Utils.getRandom()); - emptyAddress = ecKey3.getAddress(); - emptyKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - //sendcoin to Account013 - Assert.assertTrue(PublicMethed.sendcoin(account013Address, - 10000000000L, fromAddress, testKey002, blockingStubFull)); - //sendcoin to receiver - Assert.assertTrue(PublicMethed.sendcoin(receiverDelegateAddress, - 10000000000L, toAddress, testKey003, blockingStubFull)); - - //getAccountResource account013 - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage account013Resource = PublicMethed - .getAccountResource(account013Address, blockingStubFull); - logger.info("013 energy limit is " + account013Resource.getEnergyLimit()); - logger.info("013 net limit is " + account013Resource.getNetLimit()); - //getAccountResource receiver - AccountResourceMessage receiverResource = PublicMethed - .getAccountResource(receiverDelegateAddress, blockingStubFull); - logger.info("receiver energy limit is " + receiverResource.getEnergyLimit()); - logger.info("receiver net limit is " + receiverResource.getNetLimit()); - Protocol.Account account013infoBefore = - PublicMethed.queryAccount(account013Address, blockingStubFull); - //get resources of account013 before DelegateResource - account013BeforeBalance = account013infoBefore.getBalance(); - AccountResourceMessage account013ResBefore = PublicMethed - .getAccountResource(account013Address, blockingStubFull); - final long account013BeforeBandWidth = account013ResBefore.getNetLimit(); - AccountResourceMessage receiverResourceBefore = PublicMethed - .getAccountResource(receiverDelegateAddress, blockingStubFull); - long receiverBeforeBandWidth = receiverResourceBefore.getNetLimit(); - //Account013 DelegateResource for BandWidth to receiver - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver( - account013Address, freezeAmount, freezeDuration, 0, - ByteString.copyFrom(receiverDelegateAddress), testKeyForAccount013, blockingStubFull)); - Protocol.Account account013infoAfter = - PublicMethed.queryAccount(account013Address, blockingStubFull); - //get balance of account013 after DelegateResource - long account013AfterBalance = account013infoAfter.getBalance(); - AccountResourceMessage account013ResAfter = PublicMethed - .getAccountResource(account013Address, blockingStubFull); - //get BandWidth of account013 after DelegateResource - long account013AfterBandWidth = account013ResAfter.getNetLimit(); - AccountResourceMessage receiverResourceAfter = PublicMethed - .getAccountResource(receiverDelegateAddress, blockingStubFull); - //Bandwidth of receiver after DelegateResource - long receiverAfterBandWidth = receiverResourceAfter.getNetLimit(); - //Balance of Account013 reduced amount same as DelegateResource - Assert.assertTrue(account013BeforeBalance == account013AfterBalance + freezeAmount); - //Bandwidth of account013 is equally before and after DelegateResource - Assert.assertTrue(account013AfterBandWidth == account013BeforeBandWidth); - //Bandwidth of receiver after DelegateResource is greater than before - Assert.assertTrue(receiverAfterBandWidth > receiverBeforeBandWidth); - Protocol.Account account013Before1 = - PublicMethed.queryAccount(account013Address, blockingStubFull); - //balance of account013 before DelegateResource - long account013BeforeBalance1 = account013Before1.getBalance(); - AccountResourceMessage account013ResBefore1 = PublicMethed - .getAccountResource(account013Address, blockingStubFull); - //Energy of account013 before DelegateResource - long account013BeforeEnergy = account013ResBefore1.getEnergyLimit(); - AccountResourceMessage receiverResourceBefore1 = PublicMethed - .getAccountResource(receiverDelegateAddress, blockingStubFull); - //Energy of receiver before DelegateResource - long receiverBeforeEnergy = receiverResourceBefore1.getEnergyLimit(); - //Account013 DelegateResource Energy to receiver - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver( - account013Address, freezeAmount, freezeDuration, 1, - ByteString.copyFrom(receiverDelegateAddress), testKeyForAccount013, blockingStubFull)); - Protocol.Account account013infoAfter1 = - PublicMethed.queryAccount(account013Address, blockingStubFull); - //balance of account013 after DelegateResource - long account013AfterBalance1 = account013infoAfter1.getBalance(); - AccountResourceMessage account013ResAfter1 = PublicMethed - .getAccountResource(account013Address, blockingStubFull); - long account013AfterEnergy = account013ResAfter1.getEnergyLimit(); - //Energy of account013 after DelegateResource - AccountResourceMessage receiverResourceAfter1 = PublicMethed - .getAccountResource(receiverDelegateAddress, blockingStubFull); - //Energy of receiver after DelegateResource - long receiverAfterEnergy = receiverResourceAfter1.getEnergyLimit(); - //Balance of Account013 reduced amount same as DelegateResource - Assert.assertTrue(account013BeforeBalance1 == account013AfterBalance1 + freezeAmount); - //Bandwidth of account013 is equally before and after DelegateResource - Assert.assertTrue(account013AfterEnergy == account013BeforeEnergy); - //Bandwidth of receiver after DelegateResource is greater than before - Assert.assertTrue(receiverAfterEnergy > receiverBeforeEnergy); - //account013 DelegateResource to Empty failed - Assert.assertFalse(PublicMethed.freezeBalanceForReceiver( - account013Address, freezeAmount, freezeDuration, 0, - ByteString.copyFrom(emptyAddress), testKeyForAccount013, blockingStubFull)); - //account013 DelegateResource to account013 failed - Assert.assertFalse(PublicMethed.freezeBalanceForReceiver( - account013Address, freezeAmount, freezeDuration, 0, - ByteString.copyFrom(account013Address), testKeyForAccount013, blockingStubFull)); - account013Resource = PublicMethed.getAccountResource(account013Address, blockingStubFull); - logger.info("After 013 energy limit is " + account013Resource.getEnergyLimit()); - logger.info("After 013 net limit is " + account013Resource.getNetLimit()); - - receiverResource = PublicMethed.getAccountResource(receiverDelegateAddress, blockingStubFull); - logger.info("After receiver energy limit is " + receiverResource.getEnergyLimit()); - logger.info("After receiver net limit is " + receiverResource.getNetLimit()); - } - - @Test(enabled = true) - public void test2getDelegatedResourceAndDelegateResourceAccountIndex() { - //Create Account4 - ECKey ecKey4 = new ECKey(Utils.getRandom()); - account4DelegatedResourceAddress = ecKey4.getAddress(); - account4DelegatedResourceKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - //Create Account5 - ECKey ecKey5 = new ECKey(Utils.getRandom()); - account5DelegatedResourceAddress = ecKey5.getAddress(); - account5DelegatedResourceKey = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - - //sendcoin to Account4 - Assert.assertTrue(PublicMethed.sendcoin(account4DelegatedResourceAddress, - 10000000000L, fromAddress, testKey002, blockingStubFull)); - - //sendcoin to Account5 - Assert.assertTrue(PublicMethed.sendcoin(account5DelegatedResourceAddress, - 20000000000L, toAddress, testKey003, blockingStubFull)); - - Protocol.Account account4infoBefore = - PublicMethed.queryAccount(account4DelegatedResourceAddress, blockingStubFull); - //Balance of Account4 before DelegateResource - long account4BeforeBalance = account4infoBefore.getBalance(); - //account013 DelegateResource of bandwidth to Account4 - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver( - account013Address, freezeAmount, freezeDuration, 0, ByteString.copyFrom( - account4DelegatedResourceAddress), testKeyForAccount013, - blockingStubFull)); - //Account4 DelegateResource of energy to Account5 - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver( - account4DelegatedResourceAddress, freezeAmount, freezeDuration, 1, ByteString.copyFrom( - account5DelegatedResourceAddress), account4DelegatedResourceKey, - blockingStubFull)); - //check DelegatedResourceList,from:account013 to:Account4 - Optional delegatedResourceResult1 = - PublicMethed.getDelegatedResource( - account013Address, account4DelegatedResourceAddress, blockingStubFull); - long afterFreezeBandwidth = - delegatedResourceResult1.get().getDelegatedResource(0).getFrozenBalanceForBandwidth(); - //check DelegatedResourceList,from:Account4 to:Account5 - Optional delegatedResourceResult2 = - PublicMethed.getDelegatedResource(account4DelegatedResourceAddress, - account5DelegatedResourceAddress, blockingStubFull); - long afterFreezeEnergy = - delegatedResourceResult2.get().getDelegatedResource(0).getFrozenBalanceForEnergy(); - //FrozenBalanceForBandwidth > 0 - Assert.assertTrue(afterFreezeBandwidth > 0); - //FrozenBalanceForEnergy > 0 - Assert.assertTrue(afterFreezeEnergy > 0); - - //check DelegatedResourceAccountIndex for Account4 - Optional delegatedResourceIndexResult1 = - PublicMethed.getDelegatedResourceAccountIndex( - account4DelegatedResourceAddress, blockingStubFull); - //result of From list, first Address is same as account013 address - Assert.assertTrue(new String(account013Address).equals(new String( - delegatedResourceIndexResult1.get().getFromAccounts(0).toByteArray()))); - //result of To list, first Address is same as Account5 address - Assert.assertTrue(new String(account5DelegatedResourceAddress).equals( - new String(delegatedResourceIndexResult1.get().getToAccounts(0).toByteArray()))); - - //unfreezebalance of bandwidth from Account013 to Account4 - Assert.assertTrue(PublicMethed.unFreezeBalance(account013Address, testKeyForAccount013, - 0, account4DelegatedResourceAddress, blockingStubFull)); - //check DelegatedResourceAccountIndex of Account4 - Optional delegatedResourceIndexResult1AfterUnfreeze = - PublicMethed.getDelegatedResourceAccountIndex( - account4DelegatedResourceAddress, blockingStubFull); - //result of From list is empty - Assert.assertTrue(delegatedResourceIndexResult1AfterUnfreeze.get() - .getFromAccountsList().isEmpty()); - Assert.assertFalse(delegatedResourceIndexResult1AfterUnfreeze.get() - .getToAccountsList().isEmpty()); - //Balance of Account013 after unfreezeBalance - // (013 -> receiver(bandwidth), 013 -> receiver(Energy), 013 -> Account4(bandwidth)) - Assert.assertTrue(PublicMethed.queryAccount(account013Address, blockingStubFull) - .getBalance() == account013BeforeBalance - 2 * freezeAmount); - //bandwidth from Account013 to Account4 gone - Assert.assertTrue(PublicMethed.getAccountResource(account4DelegatedResourceAddress, - blockingStubFull).getNetLimit() == 0); - - //unfreezebalance of Energy from Account4 to Account5 - Assert.assertTrue(PublicMethed.unFreezeBalance( - account4DelegatedResourceAddress, account4DelegatedResourceKey, - 1, account5DelegatedResourceAddress, blockingStubFull)); - Protocol.Account account4infoAfterUnfreezeEnergy = - PublicMethed.queryAccount(account4DelegatedResourceAddress, blockingStubFull); - //balance of Account4 after unfreezebalance - long account4BalanceAfterUnfreezeEnergy = account4infoAfterUnfreezeEnergy.getBalance(); - //balance of Account4 is same as before - Assert.assertTrue(account4BeforeBalance == account4BalanceAfterUnfreezeEnergy); - //Energy from Account4 to Account5 gone - Assert.assertTrue(PublicMethed.getAccountResource( - account5DelegatedResourceAddress, blockingStubFull).getEnergyLimit() == 0); - - //Unfreezebalance of Bandwidth from Account4 to Account5 fail - Assert.assertFalse(PublicMethed.unFreezeBalance(account4DelegatedResourceAddress, - account4DelegatedResourceKey, 0, account5DelegatedResourceAddress, blockingStubFull)); - } - - @Test(enabled = true) - public void test3PrepareToken() { - //Create Account7 - ECKey ecKey7 = new ECKey(Utils.getRandom()); - accountForAssetIssueAddress = ecKey7.getAddress(); - accountForAssetIssueKey = ByteArray.toHexString(ecKey7.getPrivKeyBytes()); - //sendcoin to Account7 - Assert.assertTrue(PublicMethed.sendcoin(accountForAssetIssueAddress, - 10000000000L, toAddress, testKey003, blockingStubFull)); - //account013 DelegateResource of bandwidth to accountForAssetIssue - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver( - account013Address, 1000000000L, freezeDuration, 0, - ByteString.copyFrom(accountForAssetIssueAddress), - testKeyForAccount013, blockingStubFull)); - //accountForAssetIssue AssetIssue - long now = System.currentTimeMillis(); - String name = "testAccount013_" + Long.toString(now); - long totalSupply = 100000000000L; - String description = "zfbnb"; - String url = "aaa.com"; - Assert.assertTrue(PublicMethed.createAssetIssue(accountForAssetIssueAddress, - name, totalSupply, 1, 1, System.currentTimeMillis() + 2000, - System.currentTimeMillis() + 1000000000, 1, description, url, - 2000L, 2000L, 500L, 1L, - accountForAssetIssueKey, blockingStubFull)); - - } - - @Test(enabled = true) - public void test4DelegateResourceAboutTransferAsset() { - //Wait for 3s - PublicMethed.waitProduceNextBlock(blockingStubFull); - //get AssetIssue Id - Protocol.Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount( - accountForAssetIssueAddress, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - //Account5 Participate AssetIssue - Assert.assertTrue(PublicMethed.participateAssetIssue( - accountForAssetIssueAddress, assetAccountId.toByteArray(), 1000000, - account5DelegatedResourceAddress, account5DelegatedResourceKey, blockingStubFull)); - //get account013,accountForAssetIssue,Account5 account resources before transferAssets - final long account013CurrentBandwidth = PublicMethed.getAccountResource( - account013Address, blockingStubFull).getNetUsed(); - long accountForAssetIssueCurrentBandwidth = PublicMethed.getAccountResource( - accountForAssetIssueAddress, blockingStubFull).getNetUsed(); - final long account5CurrentBandwidth = PublicMethed.getAccountResource( - account5DelegatedResourceAddress, blockingStubFull).getNetUsed(); - //Account5 transfer Assets receiver - Assert.assertTrue(PublicMethed.transferAsset(receiverDelegateAddress, - assetAccountId.toByteArray(), 100000, account5DelegatedResourceAddress, - account5DelegatedResourceKey, blockingStubFull)); - - PublicMethed.printAddress(accountForAssetIssueKey); - PublicMethed.printAddress(account5DelegatedResourceKey); - - //get account013,accountForAssetIssue,Account5 resource after transferAsset - final long account013CurrentBandwidthAfterTrans = PublicMethed.getAccountResource( - account013Address, blockingStubFull).getNetUsed(); - final long accountForAssetIssueCurrentBandwidthAfterTrans = PublicMethed.getAccountResource( - accountForAssetIssueAddress, blockingStubFull).getFreeNetUsed(); - final long account5CurrentBandwidthAfterTrans = PublicMethed.getAccountResource( - account5DelegatedResourceAddress, blockingStubFull).getNetUsed(); - AccountResourceMessage account5ResourceAfterTrans = PublicMethed.getAccountResource( - account5DelegatedResourceAddress, blockingStubFull); - - String result = ""; - if (account5ResourceAfterTrans.getAssetNetLimitCount() > 0) { - logger.info("getAssetNetLimitCount > 0 "); - for (String name1 : account5ResourceAfterTrans.getAssetNetLimitMap().keySet()) { - logger.info(name1); - result += account5ResourceAfterTrans.getAssetNetUsedMap().get(name1); - - } - } - logger.info(result); - PublicMethed.printAddress(receiverDelegateKey); - PublicMethed.printAddress(account5DelegatedResourceKey); - long account5FreeAssetNetUsed = accountForAssetIssueCurrentBandwidthAfterTrans; - - //check resource diff - Assert.assertTrue(Long.parseLong(result) > 0); - Assert.assertTrue(account013CurrentBandwidth == account013CurrentBandwidthAfterTrans); - Assert.assertTrue(account5CurrentBandwidth == account5CurrentBandwidthAfterTrans); - } - - @Test(enabled = true) - public void test5CanNotDelegateResourceToContract() { - //Create Account6 - ECKey ecKey6 = new ECKey(Utils.getRandom()); - accountForDeployAddress = ecKey6.getAddress(); - accountForDeployKey = ByteArray.toHexString(ecKey6.getPrivKeyBytes()); - //PublicMethed.printAddress(accountForDeployKey); - //sendcoin to Account6 - Assert.assertTrue(PublicMethed.sendcoin(accountForDeployAddress, - 10000000000L, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //deploy contract under Account6 - Integer consumeUserResourcePercent = 0; - Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - String contractName = "TestSStore"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_WalletTestAccount013"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_WalletTestAccount013"); - - logger.info("TestSStore"); - final byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", - maxFeeLimit, 0L, consumeUserResourcePercent, null, accountForDeployKey, - accountForDeployAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Account4 DelegatedResource of Energy to Contract - //After 3.6 can not delegate resource to contract - Assert.assertFalse(PublicMethed.freezeBalanceForReceiver( - account4DelegatedResourceAddress, freezeAmount, freezeDuration, 1, - ByteString.copyFrom(contractAddress), account4DelegatedResourceKey, blockingStubFull)); - - //Account4 DelegatedResource Energy to deploy -// Assert.assertTrue(PublicMethed.freezeBalanceForReceiver( -// account4DelegatedResourceAddress, freezeAmount, freezeDuration, 1, -// ByteString.copyFrom(accountForDeployAddress), -// account4DelegatedResourceKey, blockingStubFull)); -// -// //get Energy of Account013,Account4,Contract before trigger contract -// final long account013CurrentEnergyUsed = PublicMethed.getAccountResource( -// account013Address, blockingStubFull).getEnergyUsed(); -// final long account013CurrentBandwidthUsed = PublicMethed.getAccountResource( -// account013Address, blockingStubFull).getFreeNetUsed(); -// final long account4CurrentEnergyUsed = PublicMethed.getAccountResource( -// account4DelegatedResourceAddress, blockingStubFull).getEnergyUsed(); -// final long contractCurrentEnergyUsed = PublicMethed.getAccountResource( -// contractAddress, blockingStubFull).getEnergyUsed(); -// final long deployCurrentEnergyUsed = PublicMethed.getAccountResource( -// accountForDeployAddress, blockingStubFull).getEnergyUsed(); -// -// //Account013 trigger contract -// String txid = PublicMethed.triggerContract(contractAddress, -// "add2(uint256)", "1", false, -// 0, 1000000000L, "0", 0, account013Address, testKeyForAccount013, blockingStubFull); -// logger.info(txid); -// infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); -// logger.info(String.valueOf(infoById.get().getResultValue())); -// Assert.assertTrue(infoById.get().getResultValue() == 0); -// //get transaction info of Energy used and Bandwidth used -// final long contractTriggerEnergyUsed = infoById.get().getReceipt().getOriginEnergyUsage(); -// final long contractTriggerBandwidthUsed = infoById.get().getReceipt().getNetUsage(); -// -// //get Energy of Account013,Account4,Contract after trigger contract -// final long account013CurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource( -// account013Address, blockingStubFull).getEnergyUsed(); -// final long account013CurrentBandwidthUsedAfterTrig = PublicMethed.getAccountResource( -// account013Address, blockingStubFull).getFreeNetUsed(); -// final long account4CurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource( -// account4DelegatedResourceAddress, blockingStubFull).getEnergyUsed(); -// final long contractCurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource( -// contractAddress, blockingStubFull).getEnergyUsed(); -// final long deployCurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource( -// accountForDeployAddress, blockingStubFull).getEnergyUsed(); -// //compare energy changed -// Assert.assertTrue(account013CurrentEnergyUsed == account013CurrentEnergyUsedAfterTrig); -// Assert.assertTrue(account4CurrentEnergyUsed == account4CurrentEnergyUsedAfterTrig); -// Assert.assertTrue(contractCurrentEnergyUsed == contractCurrentEnergyUsedAfterTrig); -// Assert.assertTrue(deployCurrentEnergyUsed -// == deployCurrentEnergyUsedAfterTrig - contractTriggerEnergyUsed); -// //compare bandwidth of Account013 before and after trigger contract -// Assert.assertTrue(account013CurrentBandwidthUsed -// == account013CurrentBandwidthUsedAfterTrig - contractTriggerBandwidthUsed); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/block/WalletTestBlock003.java b/src/test/java/stest/tron/wallet/block/WalletTestBlock003.java deleted file mode 100644 index be673c111c6..00000000000 --- a/src/test/java/stest/tron/wallet/block/WalletTestBlock003.java +++ /dev/null @@ -1,149 +0,0 @@ -package stest.tron.wallet.block; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestBlock003 { - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void testGetNextMaintenanceTime() { - long now = System.currentTimeMillis(); - NumberMessage getNextMaintenanceTime = blockingStubFull - .getNextMaintenanceTime(GrpcAPI.EmptyMessage.newBuilder().build()); - logger.info(Long.toString(getNextMaintenanceTime.getNum())); - logger.info(Long.toString(now)); - Assert.assertTrue(getNextMaintenanceTime.getNum() > now); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/block/WalletTestBlock004.java b/src/test/java/stest/tron/wallet/block/WalletTestBlock004.java deleted file mode 100644 index 97d12ac7e73..00000000000 --- a/src/test/java/stest/tron/wallet/block/WalletTestBlock004.java +++ /dev/null @@ -1,211 +0,0 @@ -package stest.tron.wallet.block; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; - -//import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class WalletTestBlock004 { - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - - @Test(enabled = true) - public void testGetBlockByLimitNext() { - // - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now has very little block, Please wait"); - currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - - GrpcAPI.BlockLimit.Builder builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(2); - builder.setEndNum(4); - GrpcAPI.BlockList blockList = blockingStubFull.getBlockByLimitNext(builder.build()); - Optional getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.isPresent()); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 2); - logger.info(Long.toString( - getBlockByLimitNext.get().getBlock(0).getBlockHeader().getRawData().getNumber())); - logger.info(Long.toString( - getBlockByLimitNext.get().getBlock(1).getBlockHeader().getRawData().getNumber())); - Assert.assertTrue( - getBlockByLimitNext.get().getBlock(0).getBlockHeader().getRawData().getNumber() < 4); - Assert.assertTrue( - getBlockByLimitNext.get().getBlock(1).getBlockHeader().getRawData().getNumber() < 4); - Assert.assertTrue(getBlockByLimitNext.get().getBlock(0).hasBlockHeader()); - Assert.assertTrue(getBlockByLimitNext.get().getBlock(1).hasBlockHeader()); - Assert.assertFalse( - getBlockByLimitNext.get().getBlock(0).getBlockHeader().getRawData().getParentHash() - .isEmpty()); - Assert.assertFalse( - getBlockByLimitNext.get().getBlock(1).getBlockHeader().getRawData().getParentHash() - .isEmpty()); - } - - @Test(enabled = true) - public void testGetBlockByExceptionLimitNext() { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now has very little block, Please wait"); - currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - - //From -1 to 1 - GrpcAPI.BlockLimit.Builder builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(-1); - builder.setEndNum(1); - GrpcAPI.BlockList blockList = blockingStubFull.getBlockByLimitNext(builder.build()); - Optional getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - - //From 3 to 3 - builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(3); - builder.setEndNum(3); - blockList = blockingStubFull.getBlockByLimitNext(builder.build()); - getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - - //From 4 to 2 - builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(4); - builder.setEndNum(2); - blockList = blockingStubFull.getBlockByLimitNext(builder.build()); - getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - - //From 999999990 to 999999999 - builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(999999990); - builder.setEndNum(999999999); - blockList = blockingStubFull.getBlockByLimitNext(builder.build()); - getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/block/WalletTestBlock005.java b/src/test/java/stest/tron/wallet/block/WalletTestBlock005.java deleted file mode 100644 index f95ee2425dc..00000000000 --- a/src/test/java/stest/tron/wallet/block/WalletTestBlock005.java +++ /dev/null @@ -1,183 +0,0 @@ -package stest.tron.wallet.block; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; - -//import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class WalletTestBlock005 { - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void testGetBlockByLatestNum() { - // - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now the block num is " + Long.toString(currentBlockNum) + " Please wait"); - currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - - NumberMessage numberMessage = NumberMessage.newBuilder().setNum(3).build(); - GrpcAPI.BlockList blockList = blockingStubFull.getBlockByLatestNum(numberMessage); - Optional getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.isPresent()); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 3); - Assert.assertTrue(getBlockByLatestNum.get().getBlock(0).hasBlockHeader()); - Assert.assertTrue( - getBlockByLatestNum.get().getBlock(1).getBlockHeader().getRawData().getNumber() > 0); - Assert.assertFalse( - getBlockByLatestNum.get().getBlock(2).getBlockHeader().getRawData().getParentHash() - .isEmpty()); - logger.info("TestGetBlockByLatestNum ok!!!"); - - } - - @Test(enabled = true) - public void testGetBlockByExceptionNum() { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now the block num is " + Long.toString(currentBlockNum) + " Please wait"); - currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - NumberMessage numberMessage = NumberMessage.newBuilder().setNum(-1).build(); - GrpcAPI.BlockList blockList = blockingStubFull.getBlockByLatestNum(numberMessage); - Optional getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 0); - - numberMessage = NumberMessage.newBuilder().setNum(0).build(); - blockList = blockingStubFull.getBlockByLatestNum(numberMessage); - getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 0); - - numberMessage = NumberMessage.newBuilder().setNum(100).build(); - blockList = blockingStubFull.getBlockByLatestNum(numberMessage); - getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 0); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/block/WalletTestBlock006.java b/src/test/java/stest/tron/wallet/block/WalletTestBlock006.java deleted file mode 100644 index 9d72c636479..00000000000 --- a/src/test/java/stest/tron/wallet/block/WalletTestBlock006.java +++ /dev/null @@ -1,115 +0,0 @@ -package stest.tron.wallet.block; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; - -@Slf4j -public class WalletTestBlock006 { - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void testGetTransactionCountByBlockNumFromFullnode() { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(0); - Long transactionNumInBlock = 0L; - transactionNumInBlock = blockingStubFull.getTransactionCountByBlockNum(builder - .build()).getNum(); - Assert.assertTrue(transactionNumInBlock >= 1); - - builder.setNum(-10); - transactionNumInBlock = blockingStubFull.getTransactionCountByBlockNum(builder - .build()).getNum(); - Assert.assertTrue(transactionNumInBlock == -1); - - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - builder.setNum(currentBlockNum + 10000L); - transactionNumInBlock = blockingStubFull.getTransactionCountByBlockNum(builder - .build()).getNum(); - Assert.assertTrue(transactionNumInBlock == -1); - } - - @Test(enabled = true) - public void testGetTransactionCountByBlockNumFromSolidity() { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(0); - Long transactionNumInBlock = 0L; - transactionNumInBlock = blockingStubSolidity.getTransactionCountByBlockNum(builder - .build()).getNum(); - Assert.assertTrue(transactionNumInBlock >= 1); - - builder.setNum(-10); - transactionNumInBlock = blockingStubSolidity.getTransactionCountByBlockNum(builder - .build()).getNum(); - Assert.assertTrue(transactionNumInBlock == -1); - - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - builder.setNum(currentBlockNum + 10000L); - transactionNumInBlock = blockingStubSolidity.getTransactionCountByBlockNum(builder - .build()).getNum(); - Assert.assertTrue(transactionNumInBlock == -1); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee001.java b/src/test/java/stest/tron/wallet/committee/WalletTestCommittee001.java deleted file mode 100644 index 414441ac1b3..00000000000 --- a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee001.java +++ /dev/null @@ -1,151 +0,0 @@ -package stest.tron.wallet.committee; - -import com.google.protobuf.ByteString; -import com.sun.media.jfxmedia.logging.Logger; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.PaginatedMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class WalletTestCommittee001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - //Witness 47.93.9.236 - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - //Witness 47.93.33.201 - private final String witnessKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - //Witness 123.56.10.6 - private final String witnessKey003 = Configuration.getByPath("testng.conf") - .getString("witness.key3"); - //Wtiness 39.107.80.135 - private final String witnessKey004 = Configuration.getByPath("testng.conf") - .getString("witness.key4"); - //Witness 47.93.184.2 - private final String witnessKey005 = Configuration.getByPath("testng.conf") - .getString("witness.key5"); - - - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - private final byte[] witness002Address = PublicMethed.getFinalAddress(witnessKey002); - private final byte[] witness003Address = PublicMethed.getFinalAddress(witnessKey003); - private final byte[] witness004Address = PublicMethed.getFinalAddress(witnessKey004); - private final byte[] witness005Address = PublicMethed.getFinalAddress(witnessKey005); - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test - public void testListProposals() { - //List proposals - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer beforeProposalCount = listProposals.get().getProposalsCount(); - - //CreateProposal - final long now = System.currentTimeMillis(); - HashMap proposalMap = new HashMap(); - proposalMap.put(0L, 1000000L); - PublicMethed.createProposal(witness001Address, witnessKey001, proposalMap, blockingStubFull); - - //List proposals - proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - listProposals = Optional.ofNullable(proposalList); - Integer afterProposalCount = listProposals.get().getProposalsCount(); - Assert.assertTrue(beforeProposalCount + 1 == afterProposalCount); - logger.info(Long.toString(listProposals.get().getProposals(0).getCreateTime())); - logger.info(Long.toString(now)); - //Assert.assertTrue(listProposals.get().getProposals(0).getCreateTime() >= now); - Assert.assertTrue(listProposals.get().getProposals(0).getParametersMap().equals(proposalMap)); - - //getProposalListPaginated - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(0); - pageMessageBuilder.setLimit(1); - ProposalList paginatedProposalList = blockingStubFull - .getPaginatedProposalList(pageMessageBuilder.build()); - Assert.assertTrue(paginatedProposalList.getProposalsCount() >= 1); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee002.java b/src/test/java/stest/tron/wallet/committee/WalletTestCommittee002.java deleted file mode 100644 index 250f6993922..00000000000 --- a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee002.java +++ /dev/null @@ -1,378 +0,0 @@ -package stest.tron.wallet.committee; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class WalletTestCommittee002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - //Witness 47.93.9.236 - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - //Witness 47.93.33.201 - private final String witnessKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - //Witness 123.56.10.6 - private final String witnessKey003 = Configuration.getByPath("testng.conf") - .getString("witness.key3"); - //Wtiness 39.107.80.135 - private final String witnessKey004 = Configuration.getByPath("testng.conf") - .getString("witness.key4"); - //Witness 47.93.184.2 - private final String witnessKey005 = Configuration.getByPath("testng.conf") - .getString("witness.key5"); - - - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - private final byte[] witness002Address = PublicMethed.getFinalAddress(witnessKey002); - private final byte[] witness003Address = PublicMethed.getFinalAddress(witnessKey003); - private final byte[] witness004Address = PublicMethed.getFinalAddress(witnessKey004); - private final byte[] witness005Address = PublicMethed.getFinalAddress(witnessKey005); - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - } - - - @Test(enabled = true) - public void testCreateProposalMaintenanceTimeInterval() { - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - Assert.assertTrue(PublicMethed.sendcoin(witness001Address, 10000000L, - toAddress, testKey003, blockingStubFull)); - - //0:MAINTENANCE_TIME_INTERVAL,[3*27s,24h] - //Minimum interval - HashMap proposalMap = new HashMap(); - proposalMap.put(0L, 81000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum interval - proposalMap.put(0L, 86400000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum -1 interval, create failed. - proposalMap.put(0L, 80000L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 interval - proposalMap.put(0L, 86401000L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(0L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, proposalMap, - blockingStubFull)); - } - - @Test(enabled = true) - public void testCreateProposalAccountUpgradeCost() { - //1:ACCOUNT_UPGRADE_COST,[0,100 000 000 000 000 000]//drop - //Minimum AccountUpgradeCost - HashMap proposalMap = new HashMap(); - proposalMap.put(1L, 0L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum AccountUpgradeCost - proposalMap.put(1L, 100000000000000000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum - 1 AccountUpgradeCost - proposalMap.put(1L, -1L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 AccountUpgradeCost - proposalMap.put(1L, 100000000000000001L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(1L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, - proposalMap, blockingStubFull)); - } - - @Test(enabled = true) - public void testCreateProposalCreateAccountFee() { - //2:CREATE_ACCOUNT_FEE,[0,100 000 000 000 000 000]//drop - //Minimum CreateAccountFee - HashMap proposalMap = new HashMap(); - proposalMap.put(2L, 0L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum CreateAccountFee - proposalMap.put(2L, 100000000000000000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum - 1 CreateAccountFee - proposalMap.put(2L, -1L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 CreateAccountFee - proposalMap.put(2L, 100000000000000001L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(2L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, - proposalMap, blockingStubFull)); - - } - - @Test(enabled = true) - public void testTransactionFee() { - //3:TRANSACTION_FEE,[0,100 000 000 000 000 000]//drop - //Minimum TransactionFee - HashMap proposalMap = new HashMap(); - proposalMap.put(3L, 0L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum TransactionFee - proposalMap.put(3L, 100000000000000000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum - 1 TransactionFee - proposalMap.put(3L, -1L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 TransactionFee - proposalMap.put(3L, 100000000000000001L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(3L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, - proposalMap, blockingStubFull)); - - } - - @Test(enabled = true) - public void testAssetIssueFee() { - //4:ASSET_ISSUE_FEE,[0,100 000 000 000 000 000]//drop - //Minimum AssetIssueFee - HashMap proposalMap = new HashMap(); - proposalMap.put(4L, 0L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Duplicat proposals - proposalMap.put(4L, 0L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum AssetIssueFee - proposalMap.put(4L, 100000000000000000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum - 1 AssetIssueFee - proposalMap.put(4L, -1L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 AssetIssueFee - proposalMap.put(4L, 100000000000000001L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(4L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, - proposalMap, blockingStubFull)); - - } - - @Test(enabled = true) - public void testWitnessPayPerBlock() { - //5:WITNESS_PAY_PER_BLOCK,[0,100 000 000 000 000 000]//drop - //Minimum WitnessPayPerBlock - HashMap proposalMap = new HashMap(); - proposalMap.put(5L, 0L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum WitnessPayPerBlock - proposalMap.put(5L, 100000000000000000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum - 1 WitnessPayPerBlock - proposalMap.put(5L, -1L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 WitnessPayPerBlock - proposalMap.put(5L, 100000000000000001L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(5L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, - proposalMap, blockingStubFull)); - - } - - @Test(enabled = true) - public void testWitnessStandbyAllowance() { - //6:WITNESS_STANDBY_ALLOWANCE,[0,100 000 000 000 000 000]//drop - //Minimum WitnessStandbyAllowance - HashMap proposalMap = new HashMap(); - proposalMap.put(6L, 0L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum WitnessStandbyAllowance - proposalMap.put(6L, 100000000000000000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum - 1 WitnessStandbyAllowance - proposalMap.put(6L, -1L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 WitnessStandbyAllowance - proposalMap.put(6L, 100000000000000001L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(6L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, - proposalMap, blockingStubFull)); - - } - - @Test(enabled = true) - public void testCreateNewAccountFeeInSystemControl() { - //7:CREATE_NEW_ACCOUNT_FEE_IN_SYSTEM_CONTRACT,0 or 1 - HashMap proposalMap = new HashMap(); - proposalMap.put(7L, 1L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum WitnessStandbyAllowance - proposalMap.put(7L, 100000000000000000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Minimum - 1 WitnessStandbyAllowance - proposalMap.put(6L, -1L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Maximum + 1 WitnessStandbyAllowance - proposalMap.put(6L, 100000000000000001L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //Non witness account - proposalMap.put(6L, 86400000L); - Assert.assertFalse(PublicMethed.createProposal(toAddress, testKey003, - proposalMap, blockingStubFull)); - - } - - - @Test(enabled = true) - public void testInvalidProposals() { - // The index isn't from 0-9 - HashMap proposalMap = new HashMap(); - proposalMap.put(10L, 60L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - //The index is -1 - proposalMap.put(-1L, 6L); - Assert.assertFalse(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee003.java b/src/test/java/stest/tron/wallet/committee/WalletTestCommittee003.java deleted file mode 100644 index 93acbcd94dd..00000000000 --- a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee003.java +++ /dev/null @@ -1,177 +0,0 @@ -package stest.tron.wallet.committee; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class WalletTestCommittee003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - //Witness 47.93.33.201 - private final String witnessKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - //Witness 123.56.10.6 - private final String witnessKey003 = Configuration.getByPath("testng.conf") - .getString("witness.key3"); - //Wtiness 39.107.80.135 - private final String witnessKey004 = Configuration.getByPath("testng.conf") - .getString("witness.key4"); - //Witness 47.93.184.2 - private final String witnessKey005 = Configuration.getByPath("testng.conf") - .getString("witness.key5"); - - - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - private final byte[] witness002Address = PublicMethed.getFinalAddress(witnessKey002); - //private final byte[] witness003Address = PublicMethed.getFinalAddress(witnessKey003); - //private final byte[] witness004Address = PublicMethed.getFinalAddress(witnessKey004); - //private final byte[] witness005Address = PublicMethed.getFinalAddress(witnessKey005); - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void testApproveProposal() { - PublicMethed.sendcoin(witness001Address, 1000000L, - toAddress, testKey003, blockingStubFull); - PublicMethed.sendcoin(witness002Address, 1000000L, - toAddress, testKey003, blockingStubFull); - - HashMap proposalMap = new HashMap(); - proposalMap.put(0L, 81000L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Get proposal list - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer proposalId = listProposals.get().getProposalsCount(); - logger.info(Integer.toString(proposalId)); - - Assert.assertTrue(PublicMethed.approveProposal(witness002Address, witnessKey002, proposalId, - true, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Get proposal list after approve - proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - listProposals = Optional.ofNullable(proposalList); - logger.info(Integer.toString(listProposals.get().getProposals(0).getApprovalsCount())); - Assert.assertTrue(listProposals.get().getProposals(0).getApprovalsCount() == 1); - //logger.info(Base58.encode58Check(witness002Address)); - //logger.info(Base58.encode58Check(listProposals.get().getProposals(0). - // getApprovalsList().get(0).toByteArray())); - Assert.assertTrue(Base58.encode58Check(witness002Address).equals(Base58.encode58Check( - listProposals.get().getProposals(0).getApprovalsList().get(0).toByteArray()))); - - //Failed to approve proposal when you already approval this proposal - Assert.assertFalse(PublicMethed.approveProposal(witness002Address, witnessKey002, proposalId, - true, blockingStubFull)); - - //Success to change the option from true to false. - Assert.assertTrue(PublicMethed.approveProposal(witness002Address, witnessKey002, proposalId, - false, blockingStubFull)); - proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - listProposals = Optional.ofNullable(proposalList); - Assert.assertTrue(listProposals.get().getProposals(0).getApprovalsCount() == 0); - - //Failed to approvel proposal when you already approval this proposal - Assert.assertFalse(PublicMethed.approveProposal(witness002Address, witnessKey002, proposalId, - false, blockingStubFull)); - - //Non witness can't approval proposal - Assert.assertFalse(PublicMethed.approveProposal(toAddress, testKey003, proposalId, - true, blockingStubFull)); - - //Muti approval - Assert.assertTrue(PublicMethed.approveProposal(witness001Address, witnessKey001, proposalId, - true, blockingStubFull)); - Assert.assertTrue(PublicMethed.approveProposal(witness002Address, witnessKey002, proposalId, - true, blockingStubFull)); - //Assert.assertTrue(PublicMethed.approveProposal(witness003Address,witnessKey003,proposalId, - // true,blockingStubFull)); - //Assert.assertTrue(PublicMethed.approveProposal(witness004Address,witnessKey004,proposalId, - // true,blockingStubFull)); - //Assert.assertTrue(PublicMethed.approveProposal(witness005Address,witnessKey005,proposalId, - // true,blockingStubFull)); - proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - listProposals = Optional.ofNullable(proposalList); - Assert.assertTrue(listProposals.get().getProposals(0).getApprovalsCount() == 2); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee004.java b/src/test/java/stest/tron/wallet/committee/WalletTestCommittee004.java deleted file mode 100644 index 3577089bc11..00000000000 --- a/src/test/java/stest/tron/wallet/committee/WalletTestCommittee004.java +++ /dev/null @@ -1,230 +0,0 @@ -package stest.tron.wallet.committee; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.ChainParameters; -import org.tron.protos.Protocol.Proposal; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class WalletTestCommittee004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - //Witness 47.93.33.201 - private final String witnessKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - //Witness 123.56.10.6 - private final String witnessKey003 = Configuration.getByPath("testng.conf") - .getString("witness.key3"); - //Wtiness 39.107.80.135 - private final String witnessKey004 = Configuration.getByPath("testng.conf") - .getString("witness.key4"); - //Witness 47.93.184.2 - private final String witnessKey005 = Configuration.getByPath("testng.conf") - .getString("witness.key5"); - - - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - private final byte[] witness002Address = PublicMethed.getFinalAddress(witnessKey002); - //private final byte[] witness003Address = PublicMethed.getFinalAddress(witnessKey003); - //private final byte[] witness004Address = PublicMethed.getFinalAddress(witnessKey004); - //private final byte[] witness005Address = PublicMethed.getFinalAddress(witnessKey005); - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void test1DeleteProposal() { - PublicMethed.sendcoin(witness001Address, 1000000L, - toAddress, testKey003, blockingStubFull); - PublicMethed.sendcoin(witness002Address, 1000000L, - toAddress, testKey003, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Create a proposal and approval it - HashMap proposalMap = new HashMap(); - proposalMap.put(1L, 99999L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //Get proposal list - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer proposalId = listProposals.get().getProposalsCount(); - Assert.assertTrue(PublicMethed.approveProposal(witness001Address, witnessKey001, - proposalId, true, blockingStubFull)); - logger.info(Integer.toString(listProposals.get().getProposals(0).getStateValue())); - //The state is "pending", state value == 0 - Assert.assertTrue(listProposals.get().getProposals(0).getStateValue() == 0); - - //When the proposal isn't created by you, you can't delete it. - Assert.assertFalse(PublicMethed.deleteProposal(witness002Address, witnessKey002, - proposalId, blockingStubFull)); - //Cancel the proposal - Assert.assertTrue(PublicMethed.deleteProposal(witness001Address, witnessKey001, - proposalId, blockingStubFull)); - //When the state is cancel, you can't delete it again. - Assert.assertFalse(PublicMethed.deleteProposal(witness001Address, witnessKey001, - proposalId, blockingStubFull)); - //You can't delete an invalid proposal - Assert.assertFalse(PublicMethed.deleteProposal(witness001Address, witnessKey001, - proposalId + 100, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - listProposals = Optional.ofNullable(proposalList); - logger.info(Integer.toString(listProposals.get().getProposals(0).getStateValue())); - //The state is "cancel", state value == 3 - Assert.assertTrue(listProposals.get().getProposals(0).getStateValue() == 3); - - //When the state is cancel, you can't approval proposal - Assert.assertFalse(PublicMethed.approveProposal(witness001Address, witnessKey001, - proposalId, true, blockingStubFull)); - Assert.assertFalse(PublicMethed.approveProposal(witness001Address, witnessKey001, - proposalId, false, blockingStubFull)); - } - - @Test(enabled = true) - public void test2GetProposal() { - //Create a proposal and approval it - HashMap proposalMap = new HashMap(); - proposalMap.put(1L, 999999999L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - //Get proposal list - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer proposalId = listProposals.get().getProposalsCount(); - - BytesMessage request = BytesMessage.newBuilder().setValue(ByteString.copyFrom( - ByteArray.fromLong(Long.parseLong(proposalId.toString())))) - .build(); - Proposal proposal = blockingStubFull.getProposalById(request); - Optional getProposal = Optional.ofNullable(proposal); - - Assert.assertTrue(getProposal.isPresent()); - Assert.assertTrue(getProposal.get().getStateValue() == 0); - - //Invalid get proposal - final Integer wrongProposalId = proposalId + 99; - request = BytesMessage.newBuilder().setValue(ByteString.copyFrom( - ByteArray.fromLong(Long.parseLong(wrongProposalId.toString())))) - .build(); - proposal = blockingStubFull.getProposalById(request); - getProposal = Optional.ofNullable(proposal); - logger.info(Long.toString(getProposal.get().getCreateTime())); - Assert.assertTrue(getProposal.get().getCreateTime() == 0); - } - - @Test(enabled = false) - public void testGetChainParameters() { - //Set the default map - HashMap defaultCommitteeMap = new HashMap(); - defaultCommitteeMap.put("MAINTENANCE_TIME_INTERVAL", 300000L); - defaultCommitteeMap.put("ACCOUNT_UPGRADE_COST", 9999000000L); - defaultCommitteeMap.put("CREATE_ACCOUNT_FEE", 100000L); - defaultCommitteeMap.put("TRANSACTION_FEE", 10L); - defaultCommitteeMap.put("ASSET_ISSUE_FEE", 1024000000L); - defaultCommitteeMap.put("WITNESS_PAY_PER_BLOCK", 32000000L); - defaultCommitteeMap.put("WITNESS_STANDBY_ALLOWANCE", 115200000000L); - defaultCommitteeMap.put("CREATE_NEW_ACCOUNT_FEE_IN_SYSTEM_CONTRACT", 0L); - defaultCommitteeMap.put("CREATE_NEW_ACCOUNT_BANDWIDTH_RATE", 1L); - - ChainParameters chainParameters = blockingStubFull - .getChainParameters(EmptyMessage.newBuilder().build()); - Optional getChainParameters = Optional.ofNullable(chainParameters); - logger.info(Long.toString(getChainParameters.get().getChainParameterCount())); - for (Integer i = 0; i < getChainParameters.get().getChainParameterCount(); i++) { - logger.info(getChainParameters.get().getChainParameter(i).getKey()); - logger.info(Long.toString(getChainParameters.get().getChainParameter(i).getValue())); - } - Assert.assertTrue(getChainParameters.get().getChainParameterCount() >= 10); - Assert.assertTrue(getChainParameters.get() - .getChainParameter(1).getValue() == 9999000000L); - Assert.assertTrue(getChainParameters.get().getChainParameter(4) - .getValue() == 1024000000L); - Assert.assertTrue(getChainParameters.get().getChainParameter(7).getValue() == 0); - Assert.assertTrue(getChainParameters.get().getChainParameter(8).getValue() == 1); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/common/.DS_Store b/src/test/java/stest/tron/wallet/common/.DS_Store deleted file mode 100644 index 674c9fbe709..00000000000 Binary files a/src/test/java/stest/tron/wallet/common/.DS_Store and /dev/null differ diff --git a/src/test/java/stest/tron/wallet/common/client/.DS_Store b/src/test/java/stest/tron/wallet/common/client/.DS_Store deleted file mode 100644 index 697523bca8c..00000000000 Binary files a/src/test/java/stest/tron/wallet/common/client/.DS_Store and /dev/null differ diff --git a/src/test/java/stest/tron/wallet/common/client/Configuration.java b/src/test/java/stest/tron/wallet/common/client/Configuration.java deleted file mode 100644 index 8591dd524ed..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/Configuration.java +++ /dev/null @@ -1,47 +0,0 @@ -package stest.tron.wallet.common.client; - -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStreamReader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.apache.commons.lang3.StringUtils.isBlank; - - -public class Configuration { - - private static Config config; - - private static final Logger logger = LoggerFactory.getLogger("Configuration"); - - /** - * constructor. - */ - - public static Config getByPath(final String configurationPath) { - if (isBlank(configurationPath)) { - throw new IllegalArgumentException("Configuration path is required!"); - } - - if (config == null) { - File configFile = new File(System.getProperty("user.dir") + '/' + configurationPath); - if (configFile.exists()) { - try { - config = ConfigFactory.parseReader(new InputStreamReader(new - FileInputStream(configurationPath))); - logger.info("use user defined config file in current dir"); - } catch (FileNotFoundException e) { - logger.error("load user defined config file exception: " + e.getMessage()); - } - } else { - config = ConfigFactory.load(configurationPath); - logger.info("user defined config file doesn't exists, use default config file in jar"); - } - } - return config; - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/GrpcClient.java b/src/test/java/stest/tron/wallet/common/client/GrpcClient.java deleted file mode 100644 index f9dfff7a3f8..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/GrpcClient.java +++ /dev/null @@ -1,377 +0,0 @@ -package stest.tron.wallet.common.client; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.GrpcAPI.AccountPaginated; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.GrpcAPI.BlockLimit; -import org.tron.api.GrpcAPI.BlockList; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.NodeList; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.PaginatedMessage; -import org.tron.api.GrpcAPI.TransactionList; -import org.tron.api.GrpcAPI.WitnessList; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.utils.ByteArray; -import org.tron.protos.Contract; -import org.tron.protos.Contract.AssetIssueContract; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Contract.WithdrawBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; - - -public class GrpcClient { - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - - // public GrpcClient(String host, int port) { - // channel = ManagedChannelBuilder.forAddress(host, port) - // .usePlaintext(true) - // .build(); - // blockingStub = WalletGrpc.newBlockingStub(channel); - // } - - /** - * constructor. - */ - - public GrpcClient(String fullnode, String soliditynode) { - if (!(fullnode.isEmpty())) { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - if (!(soliditynode.isEmpty())) { - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - } - } - - /** - * constructor. - */ - - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(byte[] address) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - if (blockingStubSolidity != null) { - return blockingStubSolidity.getAccount(request); - } else { - return blockingStubFull.getAccount(request); - } - } - - public Transaction createTransaction(Contract.AccountUpdateContract contract) { - return blockingStubFull.updateAccount(contract); - } - - public Transaction createTransaction(Contract.TransferContract contract) { - return blockingStubFull.createTransaction(contract); - } - - public Transaction createTransaction(FreezeBalanceContract contract) { - return blockingStubFull.freezeBalance(contract); - } - - public Transaction createTransaction(WithdrawBalanceContract contract) { - return blockingStubFull.withdrawBalance(contract); - } - - public Transaction createTransaction(UnfreezeBalanceContract contract) { - return blockingStubFull.unfreezeBalance(contract); - } - - public Transaction createTransferAssetTransaction(Contract.TransferAssetContract contract) { - return blockingStubFull.transferAsset(contract); - } - - public Transaction createParticipateAssetIssueTransaction( - Contract.ParticipateAssetIssueContract contract) { - return blockingStubFull.participateAssetIssue(contract); - } - - public Transaction createAccount(Contract.AccountCreateContract contract) { - return blockingStubFull.createAccount(contract); - } - - public Transaction createAssetIssue(Contract.AssetIssueContract contract) { - return blockingStubFull.createAssetIssue(contract); - } - - public Transaction voteWitnessAccount(Contract.VoteWitnessContract contract) { - return blockingStubFull.voteWitnessAccount(contract); - } - - public Transaction createWitness(Contract.WitnessCreateContract contract) { - return blockingStubFull.createWitness(contract); - } - - public boolean broadcastTransaction(Transaction signaturedTransaction) { - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(signaturedTransaction); - return response.getResult(); - } - - /** - * constructor. - */ - - public AccountNetMessage getAccountNet(byte[] address) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccountNet(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum) { - if (blockNum < 0) { - if (blockingStubSolidity != null) { - return blockingStubSolidity.getNowBlock(EmptyMessage.newBuilder().build()); - } else { - return blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - } - } - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - if (blockingStubSolidity != null) { - return blockingStubSolidity.getBlockByNum(builder.build()); - } else { - return blockingStubFull.getBlockByNum(builder.build()); - } - } - - /* public Optional listAccounts() { - if(blockingStubSolidity != null) { - AccountList accountList = blockingStubSolidity.listAccounts( - EmptyMessage.newBuilder().build()); - return Optional.ofNullable(accountList); - }else{ - AccountList accountList = blockingStubFull.listAccounts( - EmptyMessage.newBuilder().build()); - return Optional.ofNullable(accountList); - } - }*/ - - /** - * constructor. - */ - public Optional listWitnesses() { - if (blockingStubSolidity != null) { - WitnessList witnessList = blockingStubSolidity.listWitnesses( - EmptyMessage.newBuilder().build()); - return Optional.ofNullable(witnessList); - } else { - WitnessList witnessList = blockingStubFull.listWitnesses( - EmptyMessage.newBuilder().build()); - return Optional.ofNullable(witnessList); - } - } - - /** - * constructor. - */ - - public Optional getAssetIssueList(long offset, long limit) { - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - if (blockingStubSolidity != null) { - AssetIssueList assetIssueList = blockingStubSolidity - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - return Optional.ofNullable(assetIssueList); - } else { - AssetIssueList assetIssueList = blockingStubFull - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - return Optional.ofNullable(assetIssueList); - } - } - - - /** - * constructor. - */ - - public Optional getAssetIssueList() { - if (blockingStubSolidity != null) { - AssetIssueList assetIssueList = blockingStubSolidity - .getAssetIssueList(EmptyMessage.newBuilder().build()); - return Optional.ofNullable(assetIssueList); - } else { - AssetIssueList assetIssueList = blockingStubFull - .getAssetIssueList(EmptyMessage.newBuilder().build()); - return Optional.ofNullable(assetIssueList); - } - } - - /** - * constructor. - */ - - public Optional listNodes() { - NodeList nodeList = blockingStubFull - .listNodes(EmptyMessage.newBuilder().build()); - return Optional.ofNullable(nodeList); - } - - /* public Optional getAssetIssueByAccount(byte[] address) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - if(blockingStubSolidity != null) { - AssetIssueList assetIssueList = blockingStubSolidity - .getAssetIssueByAccount(request); - return Optional.ofNullable(assetIssueList); - } else { - AssetIssueList assetIssueList = blockingStubFull - .getAssetIssueByAccount(request); - return Optional.ofNullable(assetIssueList); - } - }*/ - /* public AssetIssueContract getAssetIssueByName(String assetName) { - ByteString assetNameBs = ByteString.copyFrom(assetName.getBytes()); - BytesMessage request = BytesMessage.newBuilder().setValue(assetNameBs).build(); - if(blockingStubSolidity != null) { - return blockingStubSolidity.getAssetIssueByName(request); - } else { - return blockingStubFull.getAssetIssueByName(request); - } - }*/ - - /* public NumberMessage getTotalTransaction() { - if(blockingStubSolidity != null) { - return blockingStubSolidity.totalTransaction(EmptyMessage.newBuilder().build()); - } else { - return blockingStubFull.totalTransaction(EmptyMessage.newBuilder().build()); - } - }*/ - - /* public Optional getAssetIssueListByTimestamp(long time) { - NumberMessage.Builder timeStamp = NumberMessage.newBuilder(); - timeStamp.setNum(time); - AssetIssueList assetIssueList = blockingStubSolidity - .getAssetIssueListByTimestamp(timeStamp.build()); - return Optional.ofNullable(assetIssueList); - }*/ - /* public Optional getTransactionsByTimestamp( - long start, long end, int offset , int limit) { - TimeMessage.Builder timeMessage = TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - TimePaginatedMessage.Builder timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(offset); - timePageMessage.setLimit(limit); - TransactionList transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - return Optional.ofNullable(transactionList); - }*/ - - /** - * constructor. - */ - - public Optional getTransactionsFromThis(byte[] address) { - ByteString addressBs = ByteString.copyFrom(address); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder builder = AccountPaginated.newBuilder().setAccount(account); - builder.setLimit(1000); - builder.setOffset(0); - TransactionList transactionList = blockingStubExtension - .getTransactionsFromThis(builder.build()); - return Optional.ofNullable(transactionList); - } - - /** - * constructor. - */ - - public Optional getTransactionsToThis(byte[] address) { - ByteString addressBs = ByteString.copyFrom(address); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder builder = AccountPaginated.newBuilder().setAccount(account); - builder.setLimit(1000); - builder.setOffset(0); - TransactionList transactionList = blockingStubExtension.getTransactionsToThis(builder.build()); - return Optional.ofNullable(transactionList); - } - - /* public Optional getTransactionById(String txID){ - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txID)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - if(blockingStubSolidity != null) { - Transaction transaction = blockingStubSolidity.getTransactionById(request); - return Optional.ofNullable(transaction); - } else { - Transaction transaction = blockingStubFull.getTransactionById(request); - return Optional.ofNullable(transaction); - } - }*/ - - - /** - * constructor. - */ - - public Optional getBlockById(String blockId) { - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(blockId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - Block block = blockingStubFull.getBlockById(request); - return Optional.ofNullable(block); - } - - /** - * constructor. - */ - - public Optional getBlockByLimitNext(long start, long end) { - BlockLimit.Builder builder = BlockLimit.newBuilder(); - builder.setStartNum(start); - builder.setEndNum(end); - BlockList blockList = blockingStubFull.getBlockByLimitNext(builder.build()); - return Optional.ofNullable(blockList); - } - - /** - * constructor. - */ - - public Optional getBlockByLatestNum(long num) { - NumberMessage numberMessage = NumberMessage.newBuilder().setNum(num).build(); - BlockList blockList = blockingStubFull.getBlockByLatestNum(numberMessage); - return Optional.ofNullable(blockList); - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/Parameter.java b/src/test/java/stest/tron/wallet/common/client/Parameter.java deleted file mode 100644 index 8fead433c2e..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/Parameter.java +++ /dev/null @@ -1,14 +0,0 @@ -package stest.tron.wallet.common.client; - -public interface Parameter { - - interface CommonConstant { - - byte ADD_PRE_FIX_BYTE = (byte) 0xa0; //a0 + address ,a0 is version - String ADD_PRE_FIX_STRING = "a0"; - int ADDRESS_SIZE = 21; - int BASE58CHECK_ADDRESS_SIZE = 35; - byte ADD_PRE_FIX_BYTE_MAINNET = (byte) 0x41; //41 + address - byte ADD_PRE_FIX_BYTE_TESTNET = (byte) 0xa0; //a0 + address - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/common/client/WalletClient.java b/src/test/java/stest/tron/wallet/common/client/WalletClient.java deleted file mode 100644 index bab5d50a22a..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/WalletClient.java +++ /dev/null @@ -1,1020 +0,0 @@ -package stest.tron.wallet.common.client; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; -import com.typesafe.config.Config; -import com.typesafe.config.ConfigObject; -import java.io.IOException; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.spongycastle.util.encoders.Hex; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.GrpcAPI.BlockList; -import org.tron.api.GrpcAPI.NodeList; -import org.tron.api.GrpcAPI.TransactionList; -import org.tron.api.GrpcAPI.WitnessList; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.FileUtil; -import org.tron.common.utils.Sha256Hash; -import org.tron.common.utils.Utils; -import org.tron.core.exception.CancelException; -import org.tron.keystore.CipherException; -import org.tron.protos.Contract; -import org.tron.protos.Contract.AssetIssueContract; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Contract.WithdrawBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.AccountType; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Witness; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -/*class AccountComparator implements Comparator { - - public int compare(Object o1, Object o2) { - return Long.compare(((Account) o2).getBalance(), ((Account) o1).getBalance()); - } -}*/ - -class WitnessComparator implements Comparator { - - public int compare(Object o1, Object o2) { - return Long.compare(((Witness) o2).getVoteCount(), ((Witness) o1).getVoteCount()); - } -} - -public class WalletClient { - - - private static final Logger logger = LoggerFactory.getLogger("WalletClient"); - private static final String FilePath = "Wallet"; - private ECKey ecKey = null; - private boolean loginState = false; - - private static GrpcClient rpcCli; - private static String dbPath; - private static String txtPath; - - private static byte addressPreFixByte = CommonConstant.ADD_PRE_FIX_BYTE_MAINNET; - - // static { - // new Timer().schedule(new TimerTask() { - // @Override - // public void run() { - // String fullnode = selectFullNode(); - // if(!"".equals(fullnode)) { - // rpcCli = new GrpcClient(fullnode); - // } - // } - // }, 3 * 60 * 1000, 3 * 60 * 1000); - // } - - /** - * constructor. - */ - - public static boolean init(int itype) { - Config config = Configuration.getByPath("testng.conf"); - dbPath = config.getString("CityDb.DbPath"); - txtPath = System.getProperty("user.dir") + '/' + config.getString("CityDb.TxtPath"); - - String fullNodepathname = ""; - - if (1000 == itype) { - fullNodepathname = "checkfullnode.ip.list"; - } else { - fullNodepathname = "fullnode.ip.list"; - } - String fullNode = ""; - String solidityNode = ""; - if (config.hasPath("soliditynode.ip.list")) { - solidityNode = config.getStringList("soliditynode.ip.list").get(0); - } - if (config.hasPath(fullNodepathname)) { - fullNode = config.getStringList(fullNodepathname).get(itype); - } - if (config.hasPath("net.type") && "mainnet".equalsIgnoreCase(config.getString("net.type"))) { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } else { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_TESTNET); - } - rpcCli = new GrpcClient(fullNode, solidityNode); - return true; - } - - /** - * constructor. - */ - - public static GrpcClient init() { - //Config config = org.tron.core.config.Configuration.getByPath("config.conf"); - Config config = Configuration.getByPath("testng.conf"); - dbPath = config.getString("CityDb.DbPath"); - txtPath = System.getProperty("user.dir") + "/" + config.getString("CityDb.TxtPath"); - - String fullNode = ""; - String solidityNode = ""; - if (config.hasPath("soliditynode.ip.list")) { - solidityNode = config.getStringList("soliditynode.ip.list").get(0); - } - if (config.hasPath("fullnode.ip.list")) { - fullNode = config.getStringList("fullnode.ip.list").get(0); - } - if (config.hasPath("net.type") && "mainnet".equalsIgnoreCase(config.getString("net.type"))) { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } else { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_TESTNET); - } - return new GrpcClient(fullNode, solidityNode); - } - - public static byte getAddressPreFixByte() { - return addressPreFixByte; - } - - public static void setAddressPreFixByte(byte addressPreFixByte) { - WalletClient.addressPreFixByte = addressPreFixByte; - } - - /** - * constructor. - */ - - public static String selectFullNode() { - Map witnessMap = new HashMap<>(); - Config config = Configuration.getByPath("config.conf"); - List list = config.getObjectList("witnesses.witnessList"); - for (int i = 0; i < list.size(); i++) { - ConfigObject obj = (ConfigObject) list.get(i); - String ip = obj.get("ip").unwrapped().toString(); - String url = obj.get("url").unwrapped().toString(); - witnessMap.put(url, ip); - } - - Optional result = rpcCli.listWitnesses(); - long minMissedNum = 100000000L; - String minMissedWitness = ""; - if (result.isPresent()) { - List witnessList = result.get().getWitnessesList(); - for (Witness witness : witnessList) { - String url = witness.getUrl(); - long missedBlocks = witness.getTotalMissed(); - if (missedBlocks < minMissedNum) { - minMissedNum = missedBlocks; - minMissedWitness = url; - } - } - } - if (witnessMap.containsKey(minMissedWitness)) { - return witnessMap.get(minMissedWitness); - } else { - return ""; - } - } - - public static String getDbPath() { - return dbPath; - } - - public static String getTxtPath() { - return txtPath; - } - - /** - * Creates a new WalletClient with a random ECKey or no ECKey. - */ - - public WalletClient(boolean genEcKey) { - if (genEcKey) { - this.ecKey = new ECKey(Utils.getRandom()); - } - } - - /** - * constructor. - */ - - // Create Wallet with a pritKey - public WalletClient(String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - this.ecKey = temKey; - } - - public boolean login(String password) { - loginState = checkPassWord(password); - return loginState; - } - - public boolean isLoginState() { - return loginState; - } - - public void logout() { - loginState = false; - } - - /** - * Creates a Wallet with an existing ECKey. - */ - - public WalletClient(final ECKey ecKey) { - this.ecKey = ecKey; - } - - public ECKey getEcKey() { - return ecKey; - } - - public byte[] getAddress() { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account queryAccount() { - byte[] address; - if (this.ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - this.ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return queryAccount(getAddress()); - } - - public static Account queryAccount(byte[] address) { - return rpcCli.queryAccount(address);//call rpc - } - - private Transaction signTransaction(Transaction transaction) { - if (this.ecKey == null || this.ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, this.ecKey); - } - - /** - * constructor. - */ - - public boolean sendCoin(byte[] to, long amount) { - byte[] owner = getAddress(); - Contract.TransferContract contract = createTransferContract(to, owner, amount); - Transaction transaction = rpcCli.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public boolean updateAccount(byte[] addressBytes, byte[] accountNameBytes) { - Contract.AccountUpdateContract contract = createAccountUpdateContract(accountNameBytes, - addressBytes); - Transaction transaction = rpcCli.createTransaction(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount) { - byte[] owner = getAddress(); - Transaction transaction = createTransferAssetTransaction(to, assertName, owner, amount); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public static Transaction createTransferAssetTransaction(byte[] to, byte[] assertName, - byte[] owner, long amount) { - Contract.TransferAssetContract contract = createTransferAssetContract(to, assertName, owner, - amount); - return rpcCli.createTransferAssetTransaction(contract); - } - - /** - * constructor. - */ - - public boolean participateAssetIssue(byte[] to, byte[] assertName, long amount) { - byte[] owner = getAddress(); - Transaction transaction = participateAssetIssueTransaction(to, assertName, owner, amount); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public static Transaction participateAssetIssueTransaction(byte[] to, byte[] assertName, - byte[] owner, long amount) { - Contract.ParticipateAssetIssueContract contract = participateAssetIssueContract(to, assertName, - owner, amount); - return rpcCli.createParticipateAssetIssueTransaction(contract); - } - - /** - * constructor. - */ - - public static Transaction updateAccountTransaction(byte[] addressBytes, byte[] accountNameBytes) { - Contract.AccountUpdateContract contract = createAccountUpdateContract(accountNameBytes, - addressBytes); - return rpcCli.createTransaction(contract); - } - - /** - * constructor. - */ - - public static boolean broadcastTransaction(byte[] transactionBytes) - throws InvalidProtocolBufferException { - Transaction transaction = Transaction.parseFrom(transactionBytes); - if (false == TransactionUtils.validTransaction(transaction)) { - return false; - } - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public boolean createAssetIssue(AssetIssueContract contract) { - Transaction transaction = rpcCli.createAssetIssue(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public boolean createWitness(byte[] url) { - byte[] owner = getAddress(); - Transaction transaction = createWitnessTransaction(owner, url); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public static Transaction createWitnessTransaction(byte[] owner, byte[] url) { - Contract.WitnessCreateContract contract = createWitnessCreateContract(owner, url); - return rpcCli.createWitness(contract); - } - - - public static Transaction createVoteWitnessTransaction(byte[] owner, - HashMap witness) { - Contract.VoteWitnessContract contract = createVoteWitnessContract(owner, witness); - return rpcCli.voteWitnessAccount(contract); - } - - public static Transaction createAssetIssueTransaction(AssetIssueContract contract) { - return rpcCli.createAssetIssue(contract); - } - - public static Block getGetBlock(long blockNum) { - return rpcCli.getBlock(blockNum); - } - - /** - * constructor. - */ - - public boolean voteWitness(HashMap witness) { - byte[] owner = getAddress(); - Contract.VoteWitnessContract contract = createVoteWitnessContract(owner, witness); - Transaction transaction = rpcCli.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public static Contract.TransferContract createTransferContract(byte[] to, byte[] owner, - long amount) { - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - return builder.build(); - } - - /** - * constructor. - */ - - public static Contract.TransferAssetContract createTransferAssetContract( - byte[] to, byte[] assertName, byte[] owner, long amount) { - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - return builder.build(); - } - - /** - * constructor. - */ - - public static Contract.ParticipateAssetIssueContract participateAssetIssueContract( - byte[] to, byte[] assertName, byte[] owner, long amount) { - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - return builder.build(); - } - - public static Transaction createTransaction4Transfer(Contract.TransferContract contract) { - Transaction transaction = rpcCli.createTransaction(contract); - return transaction; - } - - /** - * constructor. - */ - - public static Contract.AccountCreateContract createAccountCreateContract(byte[] owner, - byte[] address) { - Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setAccountAddress(ByteString.copyFrom(address)); - return builder.build(); - } - - /** - * constructor. - */ - - public static Contract.AccountCreateContract createAccountCreateContract( - AccountType accountType, byte[] accountName, byte[] address) { - Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder(); - ByteString bsaAdress = ByteString.copyFrom(address); - ByteString bsAccountName = ByteString.copyFrom(accountName); - builder.setType(accountType); - builder.setAccountAddress(bsAccountName); - builder.setOwnerAddress(bsaAdress); - return builder.build(); - } - - /** - * constructor. - */ - - public boolean createAccount(byte[] address) - throws CipherException, IOException, CancelException { - byte[] owner = getAddress(); - Transaction transaction = createAccountTransaction(owner, address); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - /** - * constructor. - */ - - public static Transaction createAccountTransaction(byte[] owner, byte[] address) { - Contract.AccountCreateContract contract = createAccountCreateContract(owner, address); - return rpcCli.createAccount(contract); - } - - /** - * constructor. - */ - - public static Contract.AccountUpdateContract createAccountUpdateContract(byte[] accountName, - byte[] address) { - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(address); - ByteString bsAccountName = ByteString.copyFrom(accountName); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - return builder.build(); - } - - /** - * constructor. - */ - - public static Contract.WitnessCreateContract createWitnessCreateContract(byte[] owner, - byte[] url) { - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - - return builder.build(); - } - - /** - * constructor. - */ - - public static Contract.VoteWitnessContract createVoteWitnessContract( - byte[] owner, HashMap witness) { - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - return builder.build(); - } - - public static AccountNetMessage getAccountNet(byte[] address) { - return rpcCli.getAccountNet(address); - } - - private static String loadPassword() { - char[] buf = new char[0x100]; - int len = FileUtil.readData(FilePath, buf); - if (len != 226) { - return null; - } - return String.valueOf(buf, 0, 32); - } - - /** - * constructor. - */ - - public static String loadPubKey() { - char[] buf = new char[0x100]; - int len = FileUtil.readData(FilePath, buf); - if (len != 226) { - return null; - } - return String.valueOf(buf, 32, 130); - } - - private static String loadPriKey() { - char[] buf = new char[0x100]; - int len = FileUtil.readData(FilePath, buf); - if (len != 226) { - return null; - } - return String.valueOf(buf, 162, 64); - } - - /** - * Get a Wallet from storage. - */ - - public static WalletClient getWalletByStorageIgnorPrivKey() { - try { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ECKey eccKey = ECKey.fromPublicOnly(pubKeyHex); - return new WalletClient(eccKey); - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } - - /** - * constructor. - */ - - public static String getAddressByStorage() { - try { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ECKey eccKey = ECKey.fromPublicOnly(pubKeyHex); - return ByteArray.toHexString(eccKey.getAddress()); - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } - - /** - * constructor. - */ - - public static byte[] getPassWord(String password) { - if (!passwordValid(password)) { - return null; - } - byte[] pwd; - pwd = Sha256Hash.hash(password.getBytes()); - pwd = Sha256Hash.hash(pwd); - pwd = Arrays.copyOfRange(pwd, 0, 16); - return pwd; - } - - /** - * constructor. - */ - - public static byte[] getEncKey(String password) { - if (!passwordValid(password)) { - return null; - } - byte[] encKey; - encKey = Sha256Hash.hash(password.getBytes()); - encKey = Arrays.copyOfRange(encKey, 0, 16); - return encKey; - } - - /** - * constructor. - */ - - public static boolean checkPassWord(String password) { - byte[] pwd = getPassWord(password); - if (pwd == null) { - return false; - } - String pwdAsc = ByteArray.toHexString(pwd); - String pwdInstore = loadPassword(); - return pwdAsc.equals(pwdInstore); - } - - /** - * constructor. - */ - - public static boolean passwordValid(String password) { - if (StringUtils.isEmpty(password)) { - logger.warn("Warning: Password is empty !!"); - return false; - } - if (password.length() < 6) { - logger.warn("Warning: Password is too short !!"); - return false; - } - //Other rule; - return true; - } - - /** - * constructor. - */ - - public static boolean addressValid(byte[] address) { - if (address == null || address.length == 0) { - logger.warn("Warning: Address is empty !!"); - return false; - } - if (address.length != CommonConstant.ADDRESS_SIZE) { - logger.warn( - "Warning: Address length need " + CommonConstant.ADDRESS_SIZE + " but " + address.length - + " !!"); - return false; - } - byte preFixbyte = address[0]; - if (preFixbyte != getAddressPreFixByte()) { - logger.warn("Warning: Address need prefix with " + getAddressPreFixByte() + " but " - + preFixbyte + " !!"); - return false; - } - //Other rule; - return true; - } - - /** - * constructor. - */ - - public static String encode58Check(byte[] input) { - byte[] hash0 = Sha256Hash.hash(input); - byte[] hash1 = Sha256Hash.hash(hash0); - byte[] inputCheck = new byte[input.length + 4]; - System.arraycopy(input, 0, inputCheck, 0, input.length); - System.arraycopy(hash1, 0, inputCheck, input.length, 4); - return Base58.encode(inputCheck); - } - - private static byte[] decode58Check(String input) { - byte[] decodeCheck = Base58.decode(input); - if (decodeCheck.length <= 4) { - return null; - } - byte[] decodeData = new byte[decodeCheck.length - 4]; - System.arraycopy(decodeCheck, 0, decodeData, 0, decodeData.length); - byte[] hash0 = Sha256Hash.hash(decodeData); - byte[] hash1 = Sha256Hash.hash(hash0); - if (hash1[0] == decodeCheck[decodeData.length] - && hash1[1] == decodeCheck[decodeData.length + 1] - && hash1[2] == decodeCheck[decodeData.length + 2] - && hash1[3] == decodeCheck[decodeData.length + 3]) { - return decodeData; - } - return null; - } - - /** - * constructor. - */ - - public static byte[] decodeFromBase58Check(String addressBase58) { - if (StringUtils.isEmpty(addressBase58)) { - logger.warn("Warning: Address is empty !!"); - return null; - } - byte[] address = decode58Check(addressBase58); - if (!addressValid(address)) { - return null; - } - return address; - } - - /** - * constructor. - */ - - public static boolean priKeyValid(String priKey) { - if (StringUtils.isEmpty(priKey)) { - logger.warn("Warning: PrivateKey is empty !!"); - return false; - } - if (priKey.length() != 64) { - logger.warn("Warning: PrivateKey length need 64 but " + priKey.length() + " !!"); - return false; - } - //Other rule; - return true; - } - - /* public static Optional listAccounts() { - Optional result = rpcCli.listAccounts(); - if (result.isPresent()) { - AccountList accountList = result.get(); - List list = accountList.getAccountsList(); - List newList = new ArrayList(); - newList.addAll(list); - newList.sort(new AccountComparator()); - AccountList.Builder builder = AccountList.newBuilder(); - newList.forEach(account -> builder.addAccounts(account)); - result = Optional.of(builder.build()); - } - return result; - }*/ - - /** - * constructor. - */ - public static Optional listWitnesses() { - Optional result = rpcCli.listWitnesses(); - if (result.isPresent()) { - WitnessList witnessList = result.get(); - List list = witnessList.getWitnessesList(); - List newList = new ArrayList(); - newList.addAll(list); - newList.sort(new WitnessComparator()); - WitnessList.Builder builder = WitnessList.newBuilder(); - newList.forEach(witness -> builder.addWitnesses(witness)); - result = Optional.of(builder.build()); - } - return result; - } - - /* public static Optional getAssetIssueListByTimestamp(long timestamp) { - return rpcCli.getAssetIssueListByTimestamp(timestamp); - }*/ - - /* public static Optional getTransactionsByTimestamp( - long start, long end, int offset, int limit) { - return rpcCli.getTransactionsByTimestamp(start, end, offset, limit); - }*/ - - - public static Optional getAssetIssueList() { - return rpcCli.getAssetIssueList(); - } - - public static Optional listNodes() { - return rpcCli.listNodes(); - } - - /* public static Optional getAssetIssueByAccount(byte[] address) { - return rpcCli.getAssetIssueByAccount(address); - } - - public static AssetIssueContract getAssetIssueByName(String assetName) { - return rpcCli.getAssetIssueByName(assetName); - } - - public static GrpcAPI.NumberMessage getTotalTransaction() { - return rpcCli.getTotalTransaction(); - }*/ - - public static Optional getTransactionsFromThis(byte[] address) { - return rpcCli.getTransactionsFromThis(address); - } - - public static Optional getTransactionsToThis(byte[] address) { - return rpcCli.getTransactionsToThis(address); - } - - /* public static Optional getTransactionById(String txID) { - return rpcCli.getTransactionById(txID); - }*/ - - /** - * constructor. - */ - - public boolean freezeBalance(long frozenBalance, long frozenDuration) { - - FreezeBalanceContract contract = createFreezeBalanceContract(frozenBalance, - frozenDuration); - - Transaction transaction = rpcCli.createTransaction(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - private FreezeBalanceContract createFreezeBalanceContract(long frozenBalance, - long frozenDuration) { - byte[] address = getAddress(); - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - return builder.build(); - } - - /** - * constructor. - */ - - public boolean unfreezeBalance() { - UnfreezeBalanceContract contract = createUnfreezeBalanceContract(); - - Transaction transaction = rpcCli.createTransaction(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - private UnfreezeBalanceContract createUnfreezeBalanceContract() { - - byte[] address = getAddress(); - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - - return builder.build(); - } - - /** - * constructor. - */ - - public boolean withdrawBalance() { - WithdrawBalanceContract contract = createWithdrawBalanceContract(); - - Transaction transaction = rpcCli.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(transaction); - return rpcCli.broadcastTransaction(transaction); - } - - private WithdrawBalanceContract createWithdrawBalanceContract() { - - byte[] address = getAddress(); - WithdrawBalanceContract.Builder builder = WithdrawBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - return builder.build(); - } - - public static Block getBlock(long blockNum) { - return rpcCli.getBlock(blockNum); - } - - public static Optional getBlockById(String blockId) { - return rpcCli.getBlockById(blockId); - } - - public static Optional getBlockByLimitNext(long start, long end) { - return rpcCli.getBlockByLimitNext(start, end); - } - - public static Optional getBlockByLatestNum(long num) { - return rpcCli.getBlockByLatestNum(num); - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/AbiUtil.java b/src/test/java/stest/tron/wallet/common/client/utils/AbiUtil.java deleted file mode 100644 index 50b568d5ed4..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/AbiUtil.java +++ /dev/null @@ -1,438 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.ByteUtil; -import org.tron.core.Wallet; - -public class AbiUtil { - - private static Pattern paramTypeBytes = Pattern.compile("^bytes([0-9]*)$"); - private static Pattern paramTypeNumber = Pattern.compile("^(u?int)([0-9]*)$"); - private static Pattern paramTypeArray = Pattern.compile("^(.*)\\[([0-9]*)]$"); - - static abstract class Coder { - - boolean dynamic = false; - - // DataWord[] encode - abstract byte[] encode(String value); - - abstract byte[] decode(); - - } - - public static String[] getTypes(String methodSign) { - int start = methodSign.indexOf('(') + 1; - int end = methodSign.indexOf(')'); - if (start == end) { - return new String[0]; - } - String typeString = methodSign.subSequence(start, end).toString(); - return typeString.split(","); - } - - private static Coder getParamCoder(String type) { - - switch (type) { - case "address": - return new CoderAddress(); - case "string": - return new CoderString(); - case "bool": - return new CoderBool(); - case "bytes": - return new CoderDynamicBytes(); - case "trcToken": - return new CoderNumber(); - } - - if (paramTypeBytes.matcher(type).find()) { - return new CoderFixedBytes(); - } - - if (paramTypeNumber.matcher(type).find()) { - return new CoderNumber(); - } - - Matcher m = paramTypeArray.matcher(type); - if (m.find()) { - String arrayType = m.group(1); - int length = -1; - if (!m.group(2).equals("")) { - length = Integer.valueOf(m.group(2)); - } - return new CoderArray(arrayType, length); - } - return null; - } - - static class CoderArray extends Coder { - - private String elementType; - private int length; - - CoderArray(String arrayType, int length) { - this.elementType = arrayType; - this.length = length; - if (length == -1) { - this.dynamic = true; - } - this.dynamic = true; - } - - @Override - byte[] encode(String arrayValues) { - - Coder coder = getParamCoder(elementType); - - List items; - try { - ObjectMapper mapper = new ObjectMapper(); - items = mapper.readValue(arrayValues, List.class); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - - List coders = new ArrayList<>(); - - if (this.length == -1) { - for (int i = 0; i < items.size(); i++) { - coders.add(coder); - } - } else { - for (int i = 0; i < this.length; i++) { - coders.add(coder); - } - } - - if (this.length == -1) { - return ByteUtil.merge(new DataWord(items.size()).getData(), pack(coders, items)); - } else { - return pack(coders, items); - } - } - - @Override - byte[] decode() { - return new byte[0]; - } - } - - static class CoderNumber extends Coder { - - @Override - byte[] encode(String value) { - long n = Long.valueOf(value); - DataWord word = new DataWord(Math.abs(n)); - if (n < 0) { - word.negate(); - } - return word.getData(); - } - - @Override - byte[] decode() { - return new byte[0]; - } - } - - static class CoderFixedBytes extends Coder { - - @Override - byte[] encode(String value) { - - if (value.startsWith("0x")) { - value = value.substring(2); - } - - if (value.length() % 2 != 0) { - value = "0" + value; - } - - byte[] result = new byte[32]; - byte[] bytes = Hex.decode(value); - System.arraycopy(bytes, 0, result, 0, bytes.length); - return result; - } - - @Override - byte[] decode() { - return new byte[0]; - } - } - - static class CoderDynamicBytes extends Coder { - - CoderDynamicBytes() { - dynamic = true; - } - - @Override - byte[] encode(String value) { - return encodeDynamicBytes(value, true); - } - - @Override - byte[] decode() { - return new byte[0]; - } - } - - static class CoderBool extends Coder { - - @Override - byte[] encode(String value) { - if (value.equals("true") || value.equals("1")) { - return new DataWord(1).getData(); - } else { - return new DataWord(0).getData(); - } - - } - - @Override - byte[] decode() { - return new byte[0]; - } - } - - static class CoderAddress extends Coder { - - @Override - byte[] encode(String value) { - byte[] address = Wallet.decodeFromBase58Check(value); - if (address == null) { - return null; - } - return new DataWord(address).getData(); - } - - @Override - byte[] decode() { - return new byte[0]; - } - } - - static class CoderString extends Coder { - - CoderString() { - dynamic = true; - } - - @Override - byte[] encode(String value) { - return encodeDynamicBytes(value); - } - - @Override - byte[] decode() { - return new byte[0]; - } - } - - private static byte[] encodeDynamicBytes(String value, boolean hex) { - byte[] data; - if (hex) { - if (value.startsWith("0x")) { - value = value.substring(2); - } - data = Hex.decode(value); - } else { - data = value.getBytes(); - } - return encodeDynamicBytes(data); - } - - private static byte[] encodeDynamicBytes(byte[] data) { - List ret = new ArrayList<>(); - ret.add(new DataWord(data.length)); - - int readInx = 0; - int len = data.length; - while (readInx < data.length) { - byte[] wordData = new byte[32]; - int readLen = len - readInx >= 32 ? 32 : (len - readInx); - System.arraycopy(data, readInx, wordData, 0, readLen); - DataWord word = new DataWord(wordData); - ret.add(word); - readInx += 32; - } - - byte[] retBytes = new byte[ret.size() * 32]; - int retIndex = 0; - - for (DataWord w : ret) { - System.arraycopy(w.getData(), 0, retBytes, retIndex, 32); - retIndex += 32; - } - - return retBytes; - } - - private static byte[] encodeDynamicBytes(String value) { - byte[] data = value.getBytes(); - List ret = new ArrayList<>(); - ret.add(new DataWord(data.length)); - return encodeDynamicBytes(data); - } - - public static byte[] pack(List codes, List values) { - - int staticSize = 0; - int dynamicSize = 0; - - List encodedList = new ArrayList<>(); - - for (int idx = 0; idx < codes.size(); idx++) { - Coder coder = codes.get(idx); - Object parameter = values.get(idx); - String value; - if (parameter instanceof List) { - StringBuilder sb = new StringBuilder(); - for (Object item : (List) parameter) { - if (sb.length() != 0) { - sb.append(","); - } - sb.append("\"").append(item).append("\""); - } - value = "[" + sb.toString() + "]"; - } else { - value = parameter.toString(); - } - byte[] encoded = coder.encode(value); - encodedList.add(encoded); - - if (coder.dynamic) { - staticSize += 32; - dynamicSize += encoded.length; - } else { - staticSize += encoded.length; - } - } - - int offset = 0; - int dynamicOffset = staticSize; - - byte[] data = new byte[staticSize + dynamicSize]; - - for (int idx = 0; idx < codes.size(); idx++) { - Coder coder = codes.get(idx); - - if (coder.dynamic) { - System.arraycopy(new DataWord(dynamicOffset).getData(), 0, data, offset, 32); - offset += 32; - - System.arraycopy(encodedList.get(idx), 0, data, dynamicOffset, encodedList.get(idx).length); - dynamicOffset += encodedList.get(idx).length; - } else { - System.arraycopy(encodedList.get(idx), 0, data, offset, encodedList.get(idx).length); - offset += encodedList.get(idx).length; - } - } - - return data; - } - - public static String parseMethod(String methodSign, String params) { - return parseMethod(methodSign, params, false); - } - - public static String parseParameters(String methodSign, List parameters) { - String[] inputArr = new String[parameters.size()]; - int i = 0; - for (Object parameter: parameters) { - if (parameter instanceof List) { - StringBuilder sb = new StringBuilder(); - for (Object item: (List) parameter) { - if (sb.length() != 0) { - sb.append(","); - } - sb.append("\"").append(item).append("\""); - } - inputArr[i++] = "[" + sb.toString() + "]"; - } else { - inputArr[i++] = (parameter instanceof String) ? ("\"" + parameter + "\"") : ("" + parameter); - } - } - String input = StringUtils.join(inputArr, ','); - return parseParameters(methodSign, input); - } - - public static String parseParameters(String methodSign, String input) { - byte[] encodedParms = encodeInput(methodSign, input); - return Hex.toHexString(encodedParms); - } - - public static String parseSelector(String methodSign) { - byte[] selector = new byte[4]; - System.arraycopy(Hash.sha3(methodSign.getBytes()), 0, selector,0, 4); - return Hex.toHexString(selector); - } - - public static String parseMethod(String methodSign, String input, boolean isHex) { - if (isHex) { - return parseSelector(methodSign) + input; - } else { - return parseSelector(methodSign) + parseParameters(methodSign, input); - } - } - - public static byte[] encodeInput(String methodSign, String input) { - ObjectMapper mapper = new ObjectMapper(); - input = "[" + input + "]"; - List items; - try { - items = mapper.readValue(input, List.class); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - - List coders = new ArrayList<>(); - for (String s : getTypes(methodSign)) { - Coder c = getParamCoder(s); - coders.add(c); - } - - return pack(coders, items); - } - - public static String parseMethod(String methodSign, List parameters) { - return parseSelector(methodSign) + parseParameters(methodSign, parameters); - } - - public static void main(String[] args) { - String method = "test(string,int2,string)"; - String params = "asdf,3123,adf"; - - String arrayMethod1 = "test(uint,uint256[3])"; - String arrayMethod2 = "test(uint,uint256[])"; - String arrayMethod3 = "test(uint,address[])"; - String byteMethod1 = "test(bytes32,bytes11)"; - String tokenMethod = "test(trcToken,uint256)"; - String tokenParams = "\"nmb\",111"; - - System.out.println("token:" + parseMethod(tokenMethod, tokenParams)); - - String method1 = "test(uint256,string,string,uint256[])"; - String expected1 = "db103cf30000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000014200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000143000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"; - String method2 = "test(uint256,string,string,uint256[3])"; - String expected2 = "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"; - String listString = "1 ,\"B\",\"C\", [1, 2, 3]"; - System.out.println(parseMethod(method1, listString)); - System.out.println(parseMethod(method2, listString)); - - String bytesValue1 = "\"0112313\",112313"; - - System.out.println(parseMethod(byteMethod1, bytesValue1)); - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/Base58.java b/src/test/java/stest/tron/wallet/common/client/utils/Base58.java deleted file mode 100644 index bb795eca1eb..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/Base58.java +++ /dev/null @@ -1,237 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import java.io.UnsupportedEncodingException; -import java.math.BigInteger; -import org.tron.common.utils.Sha256Hash; - -public class Base58 { - - private static final int BASE58CHECK_ADDRESS_SIZE = 35; - private static final int ADDRESS_SIZE = 21; - private static final byte ADD_PRE_FIX_BYTE = (byte) 0xa0; - /** - * constructor. - */ - - public static final char[] ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" - .toCharArray(); - private static final int[] INDEXES = new int[128]; - - static { - for (int i = 0; i < INDEXES.length; i++) { - INDEXES[i] = -1; - } - for (int i = 0; i < ALPHABET.length; i++) { - INDEXES[ALPHABET[i]] = i; - } - } - - /** - * constructor. - */ - - public static String encode(byte[] input) { - if (input.length == 0) { - return ""; - } - input = copyOfRange(input, 0, input.length); - int zeroCount = 0; - while (zeroCount < input.length && input[zeroCount] == 0) { - ++zeroCount; - } - byte[] temp = new byte[input.length * 2]; - int j = temp.length; - - int startAt = zeroCount; - while (startAt < input.length) { - byte mod = divmod58(input, startAt); - if (input[startAt] == 0) { - ++startAt; - } - temp[--j] = (byte) ALPHABET[mod]; - } - - // Strip extra '1' if there are some after decoding. - while (j < temp.length && temp[j] == ALPHABET[0]) { - ++j; - } - // Add as many leading '1' as there were leading zeros. - while (--zeroCount >= 0) { - temp[--j] = (byte) ALPHABET[0]; - } - - byte[] output = copyOfRange(temp, j, temp.length); - try { - return new String(output, "US-ASCII"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); // Cannot happen. - } - } - - /** - * constructor. - */ - - public static byte[] decode(String input) throws IllegalArgumentException { - if (input.length() == 0) { - return new byte[0]; - } - byte[] input58 = new byte[input.length()]; - // Transform the String to a base58 byte sequence - for (int i = 0; i < input.length(); ++i) { - char c = input.charAt(i); - - int digit58 = -1; - if (c >= 0 && c < 128) { - digit58 = INDEXES[c]; - } - if (digit58 < 0) { - throw new IllegalArgumentException("Illegal character " + c + " at " + i); - } - - input58[i] = (byte) digit58; - } - // Count leading zeroes - int zeroCount = 0; - while (zeroCount < input58.length && input58[zeroCount] == 0) { - ++zeroCount; - } - byte[] temp = new byte[input.length()]; - int j = temp.length; - - int startAt = zeroCount; - while (startAt < input58.length) { - byte mod = divmod256(input58, startAt); - if (input58[startAt] == 0) { - ++startAt; - } - - temp[--j] = mod; - } - // Do no add extra leading zeroes, move j to first non null byte. - while (j < temp.length && temp[j] == 0) { - ++j; - } - - return copyOfRange(temp, j - zeroCount, temp.length); - } - - public static BigInteger decodeToBigInteger(String input) throws IllegalArgumentException { - return new BigInteger(1, decode(input)); - } - - private static byte divmod58(byte[] number, int startAt) { - int remainder = 0; - for (int i = startAt; i < number.length; i++) { - int digit256 = (int) number[i] & 0xFF; - int temp = remainder * 256 + digit256; - - number[i] = (byte) (temp / 58); - - remainder = temp % 58; - } - - return (byte) remainder; - } - - - private static byte divmod256(byte[] number58, int startAt) { - int remainder = 0; - for (int i = startAt; i < number58.length; i++) { - int digit58 = (int) number58[i] & 0xFF; - int temp = remainder * 58 + digit58; - - number58[i] = (byte) (temp / 256); - - remainder = temp % 256; - } - - return (byte) remainder; - } - - private static byte[] copyOfRange(byte[] source, int from, int to) { - byte[] range = new byte[to - from]; - System.arraycopy(source, from, range, 0, range.length); - - return range; - } - - /** - * constructor. - */ - - public static byte[] decodeFromBase58Check(String addressBase58) { - if (addressBase58 == null || addressBase58.length() == 0) { - System.out.println("Warning: Address is empty !!"); - return null; - } - if (addressBase58.length() != BASE58CHECK_ADDRESS_SIZE) { - System.out.println( - "Warning: Base58 address length need " + BASE58CHECK_ADDRESS_SIZE + " but " - + addressBase58.length() - + " !!"); - return null; - } - byte[] address = decode58Check(addressBase58); - if (!addressValid(address)) { - return null; - } - return address; - } - - private static byte[] decode58Check(String input) { - byte[] decodeCheck = Base58.decode(input); - if (decodeCheck.length <= 4) { - return null; - } - byte[] decodeData = new byte[decodeCheck.length - 4]; - System.arraycopy(decodeCheck, 0, decodeData, 0, decodeData.length); - byte[] hash0 = Sha256Hash.hash(decodeData); - byte[] hash1 = Sha256Hash.hash(hash0); - if (hash1[0] == decodeCheck[decodeData.length] - && hash1[1] == decodeCheck[decodeData.length + 1] - && hash1[2] == decodeCheck[decodeData.length + 2] - && hash1[3] == decodeCheck[decodeData.length + 3]) { - return decodeData; - } - return null; - } - - /** - * constructor. - */ - - public static boolean addressValid(byte[] address) { - if (address == null || address.length == 0) { - System.out.println("Warning: Address is empty !!"); - return false; - } - if (address.length != ADDRESS_SIZE) { - System.out.println( - "Warning: Address length need " + ADDRESS_SIZE + " but " + address.length - + " !!"); - return false; - } - byte preFixbyte = address[0]; - if (preFixbyte != ADD_PRE_FIX_BYTE) { - System.out.println("Warning: Address need prefix with " + ADD_PRE_FIX_BYTE + " but " - + preFixbyte + " !!"); - return false; - } - //Other rule; - return true; - } - - /** - * constructor. - */ - - public static String encode58Check(byte[] input) { - byte[] hash0 = Sha256Hash.hash(input); - byte[] hash1 = Sha256Hash.hash(hash0); - byte[] inputCheck = new byte[input.length + 4]; - System.arraycopy(input, 0, inputCheck, 0, input.length); - System.arraycopy(hash1, 0, inputCheck, input.length, 4); - return Base58.encode(inputCheck); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/common/client/utils/ByteArrayWrapper.java b/src/test/java/stest/tron/wallet/common/client/utils/ByteArrayWrapper.java deleted file mode 100644 index c9d38ffa103..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/ByteArrayWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package stest.tron.wallet.common.client.utils; -/* - * Copyright (c) [2016] [ ] - * This file is part of the ethereumJ library. - * - * The ethereumJ library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The ethereumJ library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with the ethereumJ library. If not, see . - */ - -import java.io.Serializable; -import java.util.Arrays; -import org.spongycastle.util.encoders.Hex; -import org.tron.common.utils.FastByteComparisons; - -public class ByteArrayWrapper implements Comparable, Serializable { - - private final byte[] data; - private int hashCode = 0; - - /** - * constructor. - */ - public ByteArrayWrapper(byte[] data) { - if (data == null) { - throw new NullPointerException("Data must not be null"); - } - this.data = data; - this.hashCode = Arrays.hashCode(data); - } - - - /** - * equals Objects. - */ - public boolean equals(Object other) { - if (other == null || this.getClass() != other.getClass()) { - return false; - } - byte[] otherData = ((ByteArrayWrapper) other).getData(); - return FastByteComparisons.compareTo( - data, 0, data.length, - otherData, 0, otherData.length) == 0; - } - - @Override - public int hashCode() { - return hashCode; - } - - @Override - public int compareTo(ByteArrayWrapper o) { - return FastByteComparisons.compareTo( - data, 0, data.length, - o.getData(), 0, o.getData().length); - } - - public byte[] getData() { - return data; - } - - @Override - public String toString() { - return Hex.toHexString(data); - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/DailyBuildReport.java b/src/test/java/stest/tron/wallet/common/client/utils/DailyBuildReport.java deleted file mode 100644 index 1e36434ec6a..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/DailyBuildReport.java +++ /dev/null @@ -1,84 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.TestListenerAdapter; - -public class DailyBuildReport extends TestListenerAdapter { - - private Integer passedNum = 0; - private Integer failedNum = 0; - private Integer skippedNum = 0; - private String reportPath; - StringBuilder passedDescriptionList = new StringBuilder(""); - StringBuilder failedDescriptionList = new StringBuilder(""); - StringBuilder skippedDescriptionList = new StringBuilder(""); - - @Override - public void onStart(ITestContext context) { - reportPath = "Daily_Build_Report"; - StringBuilder sb = new StringBuilder("3.Stest report: "); - String res = sb.toString(); - try { - Files.write((Paths.get(reportPath)), res.getBytes("utf-8")); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void onTestSuccess(ITestResult result) { - passedDescriptionList.append(result.getMethod().getRealClass() + ": " - + result.getMethod().getDescription() + "\n"); - passedNum++; - } - - @Override - public void onTestFailure(ITestResult result) { - failedDescriptionList.append(result.getMethod().getRealClass() + ": " - + result.getMethod().getDescription() + "\n"); - failedNum++; - } - - @Override - public void onTestSkipped(ITestResult result) { - skippedDescriptionList.append(result.getMethod().getRealClass() + ": " - + result.getMethod().getDescription() + "\n"); - skippedNum++; - } - - - @Override - public void onFinish(ITestContext testContext) { - StringBuilder sb = new StringBuilder(); - sb.append("Total: " + (passedNum + failedNum + skippedNum) + ", " + "Passed: " + passedNum - + ", " + "Failed: " + failedNum + ", " + "Skipped: " + skippedNum + "\n"); - sb.append("------------------------------------------------------------------------------\n"); - sb.append("Passed list " + "\n"); - //sb.append("Passed case List: " + "\n"); - sb.append(passedDescriptionList.toString()); - sb.append("------------------------------------------------------------------------------\n"); - sb.append("Failed list: " + "\n"); - //sb.append("Failed case List: " + "\n"); - sb.append(failedDescriptionList.toString()); - sb.append("------------------------------------------------------------------------------\n"); - sb.append("Skipped list: " + "\n"); - //sb.append("Skipped case List: " + "\n"); - sb.append(skippedDescriptionList.toString()); - sb.append("----------------------------------------------------------------\n"); - - String res = sb.toString(); - try { - Files.write((Paths.get(reportPath)), res.getBytes("utf-8"), StandardOpenOption.APPEND); - } catch (IOException e) { - e.printStackTrace(); - } - - } - -} - diff --git a/src/test/java/stest/tron/wallet/common/client/utils/DataWord.java b/src/test/java/stest/tron/wallet/common/client/utils/DataWord.java deleted file mode 100644 index fa9dd231f1f..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/DataWord.java +++ /dev/null @@ -1,508 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -/* - * Copyright (c) [2016] [ ] - * This file is part of the ethereumJ library. - * - * The ethereumJ library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The ethereumJ library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with the ethereumJ library. If not, see . - */ - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigInteger; -import java.nio.ByteBuffer; -import org.spongycastle.util.Arrays; -import org.spongycastle.util.encoders.Hex; -import org.tron.common.utils.ByteUtil; -import org.tron.common.utils.FastByteComparisons; - -public class DataWord implements Comparable { - - /* Maximum value of the DataWord */ - public static final BigInteger _2_256 = BigInteger.valueOf(2).pow(256); - public static final BigInteger MAX_VALUE = _2_256.subtract(BigInteger.ONE); - public static final DataWord ZERO = new DataWord(new byte[32]); - public static final DataWord ZERO_EMPTY_ARRAY = new DataWord(new byte[0]); - - private byte[] data = new byte[32]; - - public DataWord() { - } - - public DataWord(int num) { - this(ByteBuffer.allocate(4).putInt(num)); - } - - public DataWord(long num) { - this(ByteBuffer.allocate(8).putLong(num)); - } - - private DataWord(ByteBuffer buffer) { - final ByteBuffer data = ByteBuffer.allocate(32); - final byte[] array = buffer.array(); - System.arraycopy(array, 0, data.array(), 32 - array.length, array.length); - this.data = data.array(); - } - - @JsonCreator - public DataWord(String data) { - this(Hex.decode(data)); - } - - public DataWord(ByteArrayWrapper wrappedData) { - this(wrappedData.getData()); - } - - /** - * constructor. - */ - - public DataWord(byte[] data) { - if (data == null) { - this.data = ByteUtil.EMPTY_BYTE_ARRAY; - } else if (data.length == 32) { - this.data = data; - } else if (data.length <= 32) { - System.arraycopy(data, 0, this.data, 32 - data.length, data.length); - } else { - throw new RuntimeException("Data word can't exceed 32 bytes: " + data); - } - - } - - public byte[] getData() { - return data; - } - - /** - * constructor. - */ - - public byte[] getNoLeadZeroesData() { - return ByteUtil.stripLeadingZeroes(data); - } - - public byte[] getLast20Bytes() { - return Arrays.copyOfRange(data, 12, data.length); - } - - public BigInteger value() { - return new BigInteger(1, data); - } - - /** - * Converts this DataWord to an int, checking for lost information. - * If this DataWord is out of the possible range for an int result - * then an ArithmeticException is thrown. - * - * @return this DataWord converted to an int. - * @throws ArithmeticException - if this will not fit in an int. - */ - /** - * constructor. - */ - - public int intValue() { - int intVal = 0; - - for (byte aaData : data) { - intVal = (intVal << 8) + (aaData & 0xff); - } - - return intVal; - } - - /** - * In case of int overflow returns Integer.MAX_VALUE otherwise works as #intValue() - */ - public int intValueSafe() { - int bytesOccupied = bytesOccupied(); - int intValue = intValue(); - if (bytesOccupied > 4 || intValue < 0) { - return Integer.MAX_VALUE; - } - return intValue; - } - - /** - * Converts this DataWord to a long, checking for lost information. If this DataWord is out of the - * possible range for a long result then an ArithmeticException is thrown. - * - * @return this DataWord converted to a long. - * @throws ArithmeticException - if this will not fit in a long. - */ - public long longValue() { - - long longVal = 0; - for (byte aaData : data) { - longVal = (longVal << 8) + (aaData & 0xff); - } - - return longVal; - } - - /** - * In case of long overflow returns Long.MAX_VALUE otherwise works as #longValue() - */ - public long longValueSafe() { - int bytesOccupied = bytesOccupied(); - long longValue = longValue(); - if (bytesOccupied > 8 || longValue < 0) { - return Long.MAX_VALUE; - } - return longValue; - } - - /** - * constructor. - */ - - public BigInteger ssValue() { - return new BigInteger(data); - } - - public String bigIntValue() { - return new BigInteger(data).toString(); - } - - /** - * constructor. - */ - - public boolean isZero() { - for (byte tmp : data) { - if (tmp != 0) { - return false; - } - } - return true; - } - - // only in case of signed operation - // when the number is explicit defined - // as negative - public boolean isNegative() { - int result = data[0] & 0x80; - return result == 0x80; - } - - /** - * constructor. - */ - - public DataWord and(DataWord w2) { - - for (int i = 0; i < this.data.length; ++i) { - this.data[i] &= w2.data[i]; - } - return this; - } - - /** - * constructor. - */ - - public DataWord or(DataWord w2) { - - for (int i = 0; i < this.data.length; ++i) { - this.data[i] |= w2.data[i]; - } - return this; - } - - /** - * constructor. - */ - - public DataWord xor(DataWord w2) { - - for (int i = 0; i < this.data.length; ++i) { - this.data[i] ^= w2.data[i]; - } - return this; - } - - /** - * constructor. - */ - - public void negate() { - - if (this.isZero()) { - return; - } - - for (int i = 0; i < this.data.length; ++i) { - this.data[i] = (byte) ~this.data[i]; - } - - for (int i = this.data.length - 1; i >= 0; --i) { - this.data[i] = (byte) (1 + this.data[i] & 0xFF); - if (this.data[i] != 0) { - break; - } - } - } - - /** - * constructor. - */ - - public void bnot() { - if (this.isZero()) { - this.data = ByteUtil.copyToArray(MAX_VALUE); - return; - } - this.data = ByteUtil.copyToArray(MAX_VALUE.subtract(this.value())); - } - - /** - * constructor. - */ - - // By : Holger - // From : http://stackoverflow.com/a/24023466/459349 - public void add(DataWord word) { - byte[] result = new byte[32]; - for (int i = 31, overflow = 0; i >= 0; i--) { - int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; - result[i] = (byte) v; - overflow = v >>> 8; - } - this.data = result; - } - - // old add-method with BigInteger quick hack - public void add2(DataWord word) { - BigInteger result = value().add(word.value()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - // TODO: mul can be done in more efficient way - // TODO: with shift left shift right trick - // TODO without BigInteger quick hack - public void mul(DataWord word) { - BigInteger result = value().multiply(word.value()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - /** - * constructor. - */ - - // TODO: improve with no BigInteger - public void div(DataWord word) { - - if (word.isZero()) { - this.and(ZERO); - return; - } - - BigInteger result = value().divide(word.value()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - /** - * constructor. - */ - - // TODO: improve with no BigInteger - public void ssDiv(DataWord word) { - - if (word.isZero()) { - this.and(ZERO); - return; - } - - BigInteger result = ssValue().divide(word.ssValue()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - // TODO: improve with no BigInteger - public void sub(DataWord word) { - BigInteger result = value().subtract(word.value()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - // TODO: improve with no BigInteger - public void exp(DataWord word) { - BigInteger result = value().modPow(word.value(), _2_256); - this.data = ByteUtil.copyToArray(result); - } - - /** - * constructor. - */ - - // TODO: improve with no BigInteger - public void mod(DataWord word) { - - if (word.isZero()) { - this.and(ZERO); - return; - } - - BigInteger result = value().mod(word.value()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - /** - * constructor. - */ - - public void ssMod(DataWord word) { - - if (word.isZero()) { - this.and(ZERO); - return; - } - - BigInteger result = ssValue().abs().mod(word.ssValue().abs()); - result = (ssValue().signum() == -1) ? result.negate() : result; - - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - /** - * constructor. - */ - - public void addmod(DataWord word1, DataWord word2) { - if (word2.isZero()) { - this.data = new byte[32]; - return; - } - - BigInteger result = value().add(word1.value()).mod(word2.value()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - /** - * constructor. - */ - - public void mulmod(DataWord word1, DataWord word2) { - - if (this.isZero() || word1.isZero() || word2.isZero()) { - this.data = new byte[32]; - return; - } - - BigInteger result = value().multiply(word1.value()).mod(word2.value()); - this.data = ByteUtil.copyToArray(result.and(MAX_VALUE)); - } - - @JsonValue - @Override - public String toString() { - return Hex.toHexString(data); - } - - /** - * constructor. - */ - - public String toPrefixString() { - - byte[] pref = getNoLeadZeroesData(); - if (pref.length == 0) { - return ""; - } - - if (pref.length < 7) { - return Hex.toHexString(pref); - } - - return Hex.toHexString(pref).substring(0, 6); - } - - public String shortHex() { - String hexValue = Hex.toHexString(getNoLeadZeroesData()).toUpperCase(); - return "0x" + hexValue.replaceFirst("^0+(?!$)", ""); - } - - public DataWord clone() { - return new DataWord(Arrays.clone(data)); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - DataWord dataWord = (DataWord) o; - - return java.util.Arrays.equals(data, dataWord.data); - - } - - @Override - public int hashCode() { - return java.util.Arrays.hashCode(data); - } - - @Override - public int compareTo(DataWord o) { - if (o == null || o.getData() == null) { - return -1; - } - int result = FastByteComparisons.compareTo( - data, 0, data.length, - o.getData(), 0, o.getData().length); - // Convert result into -1, 0 or 1 as is the convention - return (int) Math.signum(result); - } - - /** - * constructor. - */ - - public void signExtend(byte k) { - if (0 > k || k > 31) { - throw new IndexOutOfBoundsException(); - } - byte mask = this.ssValue().testBit((k * 8) + 7) ? (byte) 0xff : 0; - for (int i = 31; i > k; i--) { - this.data[31 - i] = mask; - } - } - - /** - * constructor. - */ - - public int bytesOccupied() { - int firstNonZero = ByteUtil.firstNonZeroByte(data); - if (firstNonZero == -1) { - return 0; - } - return 31 - firstNonZero + 1; - } - - public boolean isHex(String hex) { - return Hex.toHexString(data).equals(hex); - } - - public String asString() { - return new String(getNoLeadZeroesData()); - } - - public String toHexString() { - return Hex.toHexString(data); - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/FileUtil.java b/src/test/java/stest/tron/wallet/common/client/utils/FileUtil.java deleted file mode 100644 index 36fbdea1a2a..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/FileUtil.java +++ /dev/null @@ -1,147 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.FileVisitor; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.List; - -public class FileUtil { - - /** - * constructor. - */ - - public static List recursiveList(String path) throws IOException { - - final List files = new ArrayList<>(); - - Files.walkFileTree(Paths.get(path), new FileVisitor() { - @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - files.add(file.toString()); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFileFailed(Path file, IOException exc) { - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) { - return FileVisitResult.CONTINUE; - } - }); - - return files; - } - - /** - * constructor. - */ - - public static boolean recursiveDelete(String fileName) { - File file = new File(fileName); - if (file.exists()) { - //check if the file is a directory - if (file.isDirectory()) { - if ((file.list()).length > 0) { - for (String s : file.list()) { - //call deletion of file individually - recursiveDelete(fileName + System.getProperty("file.separator") + s); - } - } - } - - file.setWritable(true); - boolean result = file.delete(); - return result; - } else { - return false; - } - } - - /** - * constructor. - */ - - public static void saveData(String filePath, byte[] data) { - FileOutputStream fos = null; - try { - File file = new File(filePath); - file.createNewFile(); - fos = new FileOutputStream(file); - fos.write(data); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - /** - * constructor. - */ - - public static byte[] readData(String filePath) { - FileInputStream fi = null; - try { - File file = new File(filePath); - long fileSize = file.length(); - if (fileSize > Integer.MAX_VALUE) { - System.out.println("file too big..."); - return null; - } - fi = new FileInputStream(file); - byte[] buffer = new byte[(int) fileSize]; - int offset = 0; - int numRead; - while (offset < buffer.length - && (numRead = fi.read(buffer, offset, buffer.length - offset)) >= 0) { - offset += numRead; - } - if (offset != buffer.length) { - return null; - } - return buffer; - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (fi != null) { - try { - fi.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return null; - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/HttpMethed.java b/src/test/java/stest/tron/wallet/common/client/utils/HttpMethed.java deleted file mode 100644 index 2d24bbaccc5..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/HttpMethed.java +++ /dev/null @@ -1,3518 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.protobuf.ByteString; -import io.netty.util.internal.StringUtil; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.PoolingClientConnectionManager; -import org.apache.http.params.CoreConnectionPNames; -import org.apache.http.util.EntityUtils; -import org.junit.Assert; -import org.testng.collections.Lists; -import org.tron.api.GrpcAPI; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.ByteUtil; -import org.tron.core.zen.address.DiversifierT; -import stest.tron.wallet.common.client.Configuration; -import org.apache.http.client.HttpClient; - -@Slf4j -public class HttpMethed { - - static HttpClient httpClient; - static HttpPost httppost; - static HttpResponse response; - static Integer connectionTimeout = Configuration.getByPath("testng.conf") - .getInt("defaultParameter.httpConnectionTimeout"); - static Integer soTimeout = Configuration.getByPath("testng.conf") - .getInt("defaultParameter.httpSoTimeout"); - static String transactionString; - static String transactionSignString; - static JSONObject responseContent; - static JSONObject signResponseContent; - static JSONObject transactionApprovedListContent; - - static { - PoolingClientConnectionManager pccm = new PoolingClientConnectionManager(); - pccm.setDefaultMaxPerRoute(20); - pccm.setMaxTotal(100); - - httpClient = new DefaultHttpClient(pccm); - } - - /** - * constructor. - */ - public static HttpResponse updateAccount(String httpNode, byte[] updateAccountAddress, - String accountName, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/updateaccount"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("account_name", str2hex(accountName)); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(updateAccountAddress)); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse setAccountId(String httpNode, byte[] setAccountIdAddress, - String accountId, Boolean visable, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/setaccountid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("account_id", accountId); - userBaseObj2.addProperty("owner_address", - Base58.encode58Check(PublicMethed.getFinalAddress(fromKey))); - userBaseObj2.addProperty("visible", visable); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse updateWitness(String httpNode, byte[] witnessAddress, String updateUrl, - String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/updatewitness"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("update_url", str2hex(updateUrl)); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(witnessAddress)); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse voteWitnessAccount(String httpNode, byte[] ownerAddress, - JsonArray voteArray, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/votewitnessaccount"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.add("votes", voteArray); - logger.info(userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse createAccount(String httpNode, byte[] ownerAddress, - byte[] accountAddress, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/createaccount"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("account_address", ByteArray.toHexString(accountAddress)); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse createWitness(String httpNode, byte[] ownerAddress, String url) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/createwitness"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("url", str2hex(url)); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - //transactionString = EntityUtils.toString(response.getEntity()); - //transactionSignString = gettransactionsign(httpNode,transactionString,fromKey); - //response = broadcastTransaction(httpNode,transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse withdrawBalance(String httpNode, byte[] witnessAddress) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/withdrawbalance"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(witnessAddress)); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - //transactionString = EntityUtils.toString(response.getEntity()); - //transactionSignString = gettransactionsign(httpNode,transactionString,fromKey); - //response = broadcastTransaction(httpNode,transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse sendCoin(String httpNode, byte[] fromAddress, byte[] toAddress, - Long amount, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/createtransaction"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("to_address", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(fromAddress)); - userBaseObj2.addProperty("amount", amount); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse sendCoin(String httpNode, byte[] fromAddress, byte[] toAddress, - Long amount, Integer permissionId, String[] managerKeys) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/createtransaction"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("to_address", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(fromAddress)); - userBaseObj2.addProperty("amount", amount); - userBaseObj2.addProperty("Permission_id", permissionId); - response = createConnect(requestUrl, userBaseObj2); - transactionSignString = EntityUtils.toString(response.getEntity()); - HttpResponse getSignWeightResponse; - HttpResponse getTransactionApprovedListResponse; - - for (String key : managerKeys) { - transactionSignString = gettransactionsign(httpNode, transactionSignString, key); - getSignWeightResponse = getSignWeight(httpNode, transactionSignString); - signResponseContent = parseResponseContent(getSignWeightResponse); - logger.info("-----------sign information-----------------"); - printJsonContent(signResponseContent); - getSignWeightResponse = getTransactionApprovedList(httpNode, transactionSignString); - signResponseContent = parseResponseContent(getSignWeightResponse); - logger.info("-----------get Transaction Approved List-----------------"); - printJsonContent(signResponseContent); - - - } - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static String sendCoinGetTxid(String httpNode, byte[] fromAddress, byte[] toAddress, - Long amount, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/createtransaction"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("to_address", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(fromAddress)); - userBaseObj2.addProperty("amount", amount); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - responseContent = HttpMethed.parseStringContent(transactionString); - logger.info(responseContent.getString("txID")); - return responseContent.getString("txID"); - } - - /** - * constructor. - */ - public static HttpResponse createProposal(String httpNode, byte[] ownerAddress, Long proposalKey, - Long proposalValue, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/proposalcreate"; - JsonObject userBaseObj2 = new JsonObject(); - JsonObject proposalMap = new JsonObject(); - proposalMap.addProperty("key", proposalKey); - proposalMap.addProperty("value", proposalValue); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.add("parameters", proposalMap); - - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse approvalProposal(String httpNode, byte[] ownerAddress, - Integer proposalId, Boolean isAddApproval, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/proposalapprove"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("proposal_id", proposalId); - userBaseObj2.addProperty("is_add_approval", isAddApproval); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse deleteProposal(String httpNode, byte[] ownerAddress, - Integer proposalId, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/proposaldelete"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("proposal_id", proposalId); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getChainParameters(String httpNode) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/getchainparameters"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse accountPermissionUpdate(String httpNode, byte[] ownerAddress, - JsonObject ownerObject, JsonObject witnessObject, JsonObject activesObject, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/accountpermissionupdate"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.add("owner", ownerObject); - //userBaseObj2.add("witness", witnessObject); - userBaseObj2.add("actives", activesObject); - logger.info(userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse exchangeCreate(String httpNode, byte[] ownerAddress, - String firstTokenId, Long firstTokenBalance, - String secondTokenId, Long secondTokenBalance, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/exchangecreate"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("first_token_id", str2hex(firstTokenId)); - userBaseObj2.addProperty("first_token_balance", firstTokenBalance); - userBaseObj2.addProperty("second_token_id", str2hex(secondTokenId)); - userBaseObj2.addProperty("second_token_balance", secondTokenBalance); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse exchangeInject(String httpNode, byte[] ownerAddress, - Integer exchangeId, String tokenId, Long quant, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/exchangeinject"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("exchange_id", exchangeId); - userBaseObj2.addProperty("token_id", str2hex(tokenId)); - userBaseObj2.addProperty("quant", quant); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse exchangeWithdraw(String httpNode, byte[] ownerAddress, - Integer exchangeId, String tokenId, Long quant, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/exchangewithdraw"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("exchange_id", exchangeId); - userBaseObj2.addProperty("token_id", str2hex(tokenId)); - userBaseObj2.addProperty("quant", quant); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse exchangeTransaction(String httpNode, byte[] ownerAddress, - Integer exchangeId, String tokenId, Long quant, Long expected, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/exchangetransaction"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("exchange_id", exchangeId); - userBaseObj2.addProperty("token_id", str2hex(tokenId)); - userBaseObj2.addProperty("quant", quant); - userBaseObj2.addProperty("expected", expected); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse assetIssue(String httpNode, byte[] ownerAddress, String name, - String abbr, Long totalSupply, Integer trxNum, Integer num, Long startTime, Long endTime, - Integer voteScore, Integer precision, String description, String url, Long freeAssetNetLimit, - Long publicFreeAssetNetLimit, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/createassetissue"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("name", str2hex(name)); - userBaseObj2.addProperty("abbr", str2hex(abbr)); - userBaseObj2.addProperty("total_supply", totalSupply); - userBaseObj2.addProperty("trx_num", trxNum); - userBaseObj2.addProperty("num", num); - userBaseObj2.addProperty("precision", precision); - userBaseObj2.addProperty("start_time", startTime); - userBaseObj2.addProperty("end_time", endTime); - userBaseObj2.addProperty("vote_score", voteScore); - userBaseObj2.addProperty("description", str2hex(description)); - userBaseObj2.addProperty("url", str2hex(url)); - userBaseObj2.addProperty("free_asset_net_limit", freeAssetNetLimit); - userBaseObj2.addProperty("public_free_asset_net_limit", publicFreeAssetNetLimit); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse transferAsset(String httpNode, byte[] ownerAddress, - byte[] toAddress, String assetIssueById, Long amount, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/transferasset"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("to_address", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("asset_name", str2hex(assetIssueById)); - userBaseObj2.addProperty("amount", amount); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse deployContract(String httpNode, String name, String abi, - String bytecode, - Long bandwidthLimit, Long feeLimit, Integer consumeUserResourcePercent, - Long originEnergyLimit, - Long callValue, Integer tokenId, Long tokenValue, byte[] ownerAddress, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/deploycontract"; - JsonObject userBaseObj2 = new JsonObject(); - //userBaseObj2.addProperty("name", str2hex(name)); - userBaseObj2.addProperty("name", name); - userBaseObj2.addProperty("abi", abi); - userBaseObj2.addProperty("bytecode", bytecode); - userBaseObj2.addProperty("bandwidth_limit", bandwidthLimit); - userBaseObj2.addProperty("fee_limit", feeLimit); - userBaseObj2.addProperty("consume_user_resource_percent", consumeUserResourcePercent); - userBaseObj2.addProperty("origin_energy_limit", originEnergyLimit); - userBaseObj2.addProperty("call_value", callValue); - userBaseObj2.addProperty("token_id", tokenId); - userBaseObj2.addProperty("tokenValue", tokenValue); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static String deployContractGetTxid(String httpNode, String name, String abi, - String bytecode, - Long bandwidthLimit, Long feeLimit, Integer consumeUserResourcePercent, - Long originEnergyLimit, - Long callValue, Integer tokenId, Long tokenValue, byte[] ownerAddress, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/deploycontract"; - JsonObject userBaseObj2 = new JsonObject(); - //userBaseObj2.addProperty("name", str2hex(name)); - userBaseObj2.addProperty("name", name); - userBaseObj2.addProperty("abi", abi); - userBaseObj2.addProperty("bytecode", bytecode); - userBaseObj2.addProperty("bandwidth_limit", bandwidthLimit); - userBaseObj2.addProperty("fee_limit", feeLimit); - userBaseObj2.addProperty("consume_user_resource_percent", consumeUserResourcePercent); - userBaseObj2.addProperty("origin_energy_limit", originEnergyLimit); - userBaseObj2.addProperty("call_value", callValue); - userBaseObj2.addProperty("token_id", tokenId); - userBaseObj2.addProperty("call_token_value", tokenValue); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - - logger.info(userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - responseContent = HttpMethed.parseStringContent(transactionString); - return responseContent.getString("txID"); - } - - /** - * constructor. - */ - public static HttpResponse deployContractGetTxidWithTooBigLong(String httpNode, String name, - String abi, String bytecode, Long bandwidthLimit, Long feeLimit, - Integer consumeUserResourcePercent, Long originEnergyLimit, Long callValue, Integer tokenId, - Long tokenValue, byte[] ownerAddress, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/deploycontract"; - - String text = "{\"call_token_value\": 10000000e100000000}"; - JSONObject jsonObject = JSONObject.parseObject(text); - logger.info("jsonObject: " + jsonObject.toString()); - jsonObject.put("name", name); - jsonObject.put("abi", abi); - jsonObject.put("bytecode", bytecode); - jsonObject.put("bandwidth_limit", bandwidthLimit); - jsonObject.put("fee_limit", feeLimit); - jsonObject.put("consume_user_resource_percent", consumeUserResourcePercent); - jsonObject.put("origin_energy_limit", originEnergyLimit); - jsonObject.put("call_value", callValue); - jsonObject.put("token_id", tokenId); - jsonObject.put("owner_address", ByteArray.toHexString(ownerAddress)); - - logger.info(jsonObject.toString()); - response = createConnect1(requestUrl, jsonObject); - /* transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString);*/ - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static String triggerContractGetTxid(String httpNode, byte[] ownerAddress, - String contractAddress, String functionSelector, String parameter, Long feeLimit, - Long callValue, Integer tokenId, Long tokenValue, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/triggersmartcontract"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("contract_address", contractAddress); - userBaseObj2.addProperty("function_selector", functionSelector); - userBaseObj2.addProperty("parameter", parameter); - userBaseObj2.addProperty("fee_limit", feeLimit); - userBaseObj2.addProperty("call_value", callValue); - userBaseObj2.addProperty("token_id", tokenId); - userBaseObj2.addProperty("call_token_value", tokenValue); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - - transactionSignString = gettransactionsign(httpNode, parseStringContent(transactionString) - .getString("transaction"), fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - responseContent = HttpMethed.parseStringContent(transactionSignString); - return responseContent.getString("txID"); - } - - /** - * constructor. - */ - public static HttpResponse triggerConstantContract(String httpNode, byte[] ownerAddress, - String contractAddress, String functionSelector, String parameter, Long feeLimit, - String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/triggerconstantcontract"; - JsonObject userBaseObj2 = new JsonObject(); - - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("contract_address", contractAddress); - userBaseObj2.addProperty("function_selector", functionSelector); - userBaseObj2.addProperty("parameter", parameter); - userBaseObj2.addProperty("fee_limit", feeLimit); - - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse triggerConstantContract(String httpNode, byte[] ownerAddress, - String contractAddress, - String functionSelector, String parameter) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/triggerconstantcontract"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("contract_address", contractAddress); - userBaseObj2.addProperty("function_selector", functionSelector); - userBaseObj2.addProperty("parameter", parameter); - response = createConnect(requestUrl, userBaseObj2); - return response; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static HttpResponse participateAssetIssue(String httpNode, byte[] toAddress, - byte[] ownerAddress, String assetIssueById, Long amount, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/participateassetissue"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("to_address", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("asset_name", str2hex(assetIssueById)); - userBaseObj2.addProperty("amount", amount); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse updateAssetIssue(String httpNode, byte[] ownerAddress, - String description, String url, Long newLimit, Long newPublicLimit, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/updateasset"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("url", str2hex(url)); - userBaseObj2.addProperty("description", str2hex(description)); - userBaseObj2.addProperty("new_limit", newLimit); - userBaseObj2.addProperty("new_public_limit", newPublicLimit); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static Boolean verificationResult(HttpResponse response) { - if (response.getStatusLine().getStatusCode() != 200) { - return false; - } - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - return Boolean.valueOf(responseContent.getString("result")).booleanValue(); - } - - /** - * constructor. - */ - public static HttpResponse freezeBalance(String httpNode, byte[] ownerAddress, - Long frozenBalance, Integer frozenDuration, Integer resourceCode, String fromKey) { - return freezeBalance(httpNode, ownerAddress, frozenBalance, frozenDuration, resourceCode, - null, fromKey); - } - - /** - * constructor. - */ - public static HttpResponse freezeBalance(String httpNode, byte[] ownerAddress, - Long frozenBalance, Integer frozenDuration, Integer resourceCode, byte[] receiverAddress, - String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/freezebalance"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("frozen_balance", frozenBalance); - userBaseObj2.addProperty("frozen_duration", frozenDuration); - if (resourceCode == 0) { - userBaseObj2.addProperty("resource", "BANDWIDTH"); - } - if (resourceCode == 1) { - userBaseObj2.addProperty("resource", "ENERGY"); - } - if (receiverAddress != null) { - userBaseObj2.addProperty("receiver_address", ByteArray.toHexString(receiverAddress)); - } - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse unFreezeBalance(String httpNode, byte[] ownerAddress, - Integer resourceCode, String fromKey) { - return unFreezeBalance(httpNode, ownerAddress, resourceCode, null, fromKey); - } - - /** - * constructor. - */ - public static HttpResponse unFreezeBalance(String httpNode, byte[] ownerAddress, - Integer resourceCode, byte[] receiverAddress, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/unfreezebalance"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - if (resourceCode == 0) { - userBaseObj2.addProperty("resource", "BANDWIDTH"); - } - if (resourceCode == 1) { - userBaseObj2.addProperty("resource", "ENERGY"); - } - if (receiverAddress != null) { - userBaseObj2.addProperty("receiver_address", ByteArray.toHexString(receiverAddress)); - } - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static String gettransactionsign(String httpNode, String transactionString, - String privateKey) { - try { - String requestUrl = "http://" + httpNode + "/wallet/gettransactionsign"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("transaction", transactionString); - userBaseObj2.addProperty("privateKey", privateKey); - response = createConnect(requestUrl, userBaseObj2); - transactionSignString = EntityUtils.toString(response.getEntity()); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return transactionSignString; - } - - /** - * constructor. - */ - public static HttpResponse broadcastTransaction(String httpNode, String transactionSignString) { - try { - String requestUrl = "http://" + httpNode + "/wallet/broadcasttransaction"; - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout); - httppost = new HttpPost(requestUrl); - httppost.setHeader("Content-type", "application/json; charset=utf-8"); - httppost.setHeader("Connection", "Close"); - if (transactionSignString != null) { - StringEntity entity = new StringEntity(transactionSignString, Charset.forName("UTF-8")); - entity.setContentEncoding("UTF-8"); - entity.setContentType("application/json"); - httppost.setEntity(entity); - } - response = httpClient.execute(httppost); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - - responseContent = HttpMethed.parseResponseContent(response); - Integer times = 0; - - while (times++ <= 10 && responseContent.getString("code") != null && responseContent - .getString("code").equalsIgnoreCase("SERVER_BUSY")) { - logger.info("retry num are " + times); - try { - response = httpClient.execute(httppost); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - responseContent = HttpMethed.parseResponseContent(response); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - httppost.releaseConnection(); - return response; - } - - /** - * constructor. - */ - public static HttpResponse broadcasthex(String httpNode, String transactionHex) { - try { - String requestUrl = "http://" + httpNode + "/wallet/broadcasthex"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("transaction", transactionHex); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getAccountById(String httpNode, String accountId, Boolean visable) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getaccountbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("account_id", accountId); - userBaseObj2.addProperty("visible", visable); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAccountByIdFromSolidity(String httpSolidityNode, String accountId, - Boolean visable) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getaccountbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("account_id", accountId); - userBaseObj2.addProperty("visible", visable); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getAccount(String httpNode, byte[] queryAddress) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getaccount"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", ByteArray.toHexString(queryAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static Long getAccountForResponse(String httpNode, byte[] queryAddress, Integer times) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getaccount"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", ByteArray.toHexString(queryAddress)); - Long duration = createConnectForResponse(requestUrl, userBaseObj2, times); - return duration; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return -1L; - } - } - - - - /** - * constructor. - */ - public static HttpResponse getAccountFromSolidity(String httpSolidityNode, byte[] queryAddress) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getaccount"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", ByteArray.toHexString(queryAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getContract(String httpNode, String contractAddress) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getcontract"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", contractAddress); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getSignWeight(String httpNode, String transactionSignString) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getsignweight"; - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout); - httppost = new HttpPost(requestUrl); - httppost.setHeader("Content-type", "application/json; charset=utf-8"); - httppost.setHeader("Connection", "Close"); - if (transactionSignString != null) { - StringEntity entity = new StringEntity(transactionSignString, Charset.forName("UTF-8")); - entity.setContentEncoding("UTF-8"); - entity.setContentType("application/json"); - httppost.setEntity(entity); - } - response = httpClient.execute(httppost); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - //httppost.releaseConnection(); - return response; - } - - /** - * constructor. - */ - public static HttpResponse getTransactionApprovedList(String httpNode, - String transactionSignString) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getapprovedlist"; - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout); - httppost = new HttpPost(requestUrl); - httppost.setHeader("Content-type", "application/json; charset=utf-8"); - httppost.setHeader("Connection", "Close"); - if (transactionSignString != null) { - StringEntity entity = new StringEntity(transactionSignString, Charset.forName("UTF-8")); - entity.setContentEncoding("UTF-8"); - entity.setContentType("application/json"); - httppost.setEntity(entity); - } - response = httpClient.execute(httppost); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - //httppost.releaseConnection(); - return response; - } - - - /** - * constructor. - */ - public static HttpResponse listExchanges(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/listexchanges"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse listExchangesFromSolidity(String httpSolidityNode) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/listexchanges"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse listNodes(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/listnodes"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getNextmaintenanceTime(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getnextmaintenancetime"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getChainParameter(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getchainparameters"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getNodeInfo(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getnodeinfo"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse listwitnesses(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/listwitnesses"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse listwitnessesFromSolidity(String httpSolidityNode) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/listwitnesses"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse listProposals(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/listproposals"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getExchangeById(String httpNode, Integer exchangeId) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getexchangebyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("id", exchangeId); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getExchangeByIdFromSolidity(String httpSolidityNode, - Integer exchangeId) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getexchangebyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("id", exchangeId); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getProposalById(String httpNode, Integer proposalId) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getproposalbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("id", proposalId); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAssetIssueListByName(String httpNode, String name) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getassetissuelistbyname"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", str2hex(name)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAssetIssueListByNameFromSolidity(String httpSolidityNode, - String name) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getassetissuelistbyname"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", str2hex(name)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAssetIssueById(String httpNode, String assetIssueId) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getassetissuebyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", assetIssueId); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAssetIssueByIdFromSolidity(String httpSolidityNode, - String assetIssueId) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getassetissuebyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", assetIssueId); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getTransactionById(String httpNode, String txid) { - try { - String requestUrl = "http://" + httpNode + "/wallet/gettransactionbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", txid); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static Long getTransactionByIdForResponse(String httpNode, String txid, Integer times) { - try { - String requestUrl = "http://" + httpNode + "/wallet/gettransactionbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", txid); - Long duration = createConnectForResponse(requestUrl, userBaseObj2, times); - return duration; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - - - /** - * constructor. - */ - public static HttpResponse getTransactionByIdFromSolidity(String httpSolidityNode, String txid) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/gettransactionbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", txid); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getTransactionInfoById(String httpNode, String txid) { - try { - String requestUrl = "http://" + httpNode + "/wallet/gettransactioninfobyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", txid); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getTransactionInfoByIdFromSolidity(String httpSolidityNode, - String txid) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/gettransactioninfobyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", txid); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getTransactionCountByBlocknumFromSolidity(String httpSolidityNode, - long blocknum) { - try { - String requestUrl = - "http://" + httpSolidityNode + "/walletsolidity/gettransactioncountbyblocknum"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("num", blocknum); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getTransactionsFromThisFromSolidity(String httpSolidityNode, - byte[] fromAddress, long offset, long limit) { - try { - Map map1 = new HashMap(); - Map map = new HashMap(); - map1.put("address", ByteArray.toHexString(fromAddress)); - map.put("account", map1); - map.put("offset", offset); - map.put("limit", limit); - String requestUrl = "http://" + httpSolidityNode + "/walletextension/gettransactionsfromthis"; - String jsonStr = new Gson().toJson(map); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - response = createConnect(requestUrl, jsonObj); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getTransactionsToThisFromSolidity(String httpSolidityNode, - byte[] toAddress, long offset, long limit) { - try { - Map map1 = new HashMap(); - Map map = new HashMap(); - map1.put("address", ByteArray.toHexString(toAddress)); - map.put("account", map1); - map.put("offset", offset); - map.put("limit", limit); - String requestUrl = "http://" + httpSolidityNode + "/walletextension/gettransactionstothis"; - String jsonStr = new Gson().toJson(map); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - response = createConnect(requestUrl, jsonObj); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAssetIssueByName(String httpNode, String name) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getassetissuebyname"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", str2hex(name)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getAssetIssueByNameFromSolidity(String httpSolidityNode, String name) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getassetissuebyname"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", str2hex(name)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static Long getBalance(String httpNode, byte[] queryAddress) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getaccount"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", ByteArray.toHexString(queryAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - responseContent = HttpMethed.parseResponseContent(response); - //HttpMethed.printJsonContent(responseContent); - //httppost.releaseConnection(); - return Long.parseLong(responseContent.get("balance").toString()); - } - - - /** - * constructor. - */ - public static HttpResponse getAccountNet(String httpNode, byte[] queryAddress) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getaccountnet"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", ByteArray.toHexString(queryAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAccountReource(String httpNode, byte[] queryAddress) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getaccountresource"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", ByteArray.toHexString(queryAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getNowBlock(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getnowblock"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getNowBlockFromSolidity(String httpSolidityNode) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getnowblock"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static void waitToProduceOneBlock(String httpNode) { - response = HttpMethed.getNowBlock(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - responseContent = HttpMethed.parseStringContent(responseContent.get("block_header").toString()); - responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString()); - Integer currentBlockNum = Integer.parseInt(responseContent.get("number").toString()); - Integer nextBlockNum = 0; - Integer times = 0; - while (nextBlockNum <= currentBlockNum && times++ <= 3) { - response = HttpMethed.getNowBlock(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - responseContent = HttpMethed.parseStringContent(responseContent.get("block_header") - .toString()); - responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString()); - nextBlockNum = Integer.parseInt(responseContent.get("number").toString()); - try { - Thread.sleep(3500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - /** - * constructor. - */ - public static void waitToProduceOneBlockFromSolidity(String httpNode, String httpSolidityNode) { - response = HttpMethed.getNowBlock(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - responseContent = HttpMethed.parseStringContent(responseContent.get("block_header").toString()); - responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString()); - Integer currentBlockNum = Integer.parseInt(responseContent.get("number").toString()); - Integer nextBlockNum = 0; - Integer times = 0; - while (nextBlockNum <= currentBlockNum && times++ <= 3) { - response = HttpMethed.getNowBlockFromSolidity(httpSolidityNode); - responseContent = HttpMethed.parseResponseContent(response); - responseContent = HttpMethed.parseStringContent(responseContent.get("block_header") - .toString()); - responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString()); - nextBlockNum = Integer.parseInt(responseContent.get("number").toString()); - try { - Thread.sleep(3500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - /** - * constructor. - */ - public static HttpResponse getBlockByNum(String httpNode, Integer blockNUm) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getblockbynum"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("num", blockNUm); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static Long getBlockByNumForResponse(String httpNode, Integer blockNUm, Integer times) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getblockbynum"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("num", blockNUm); - Long duration = createConnectForResponse(requestUrl, userBaseObj2, times); - return duration; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return -1L; - } - } - - - /** - * constructor. - */ - public static HttpResponse getBlockByNumFromSolidity(String httpSolidityNode, Integer blockNum) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getblockbynum"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("num", blockNum); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getBlockByLimitNext(String httpNode, Integer startNum, - Integer endNum) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getblockbylimitnext"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("startNum", startNum); - userBaseObj2.addProperty("endNum", endNum); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getBlockByLimitNextFromSolidity(String httpNode, Integer startNum, - Integer endNum) { - try { - String requestUrl = "http://" + httpNode + "/walletsolidity/getblockbylimitnext"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("startNum", startNum); - userBaseObj2.addProperty("endNum", endNum); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getBlockByLastNum(String httpNode, Integer num) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getblockbylatestnum"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("num", num); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getBlockByLastNumFromSolidity(String httpNode, Integer num) { - try { - String requestUrl = "http://" + httpNode + "/walletsolidity/getblockbylatestnum"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("num", num); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getBlockById(String httpNode, String blockId) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getblockbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", blockId); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getBlockByIdFromSolidity(String httpNode, String blockId) { - try { - String requestUrl = "http://" + httpNode + "/walletsolidity/getblockbyid"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", blockId); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getDelegatedResource( - String httpNode, byte[] fromAddress, byte[] toAddress) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getdelegatedresource"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("fromAddress", ByteArray.toHexString(fromAddress)); - userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getDelegatedResourceFromSolidity( - String httpSolidityNode, byte[] fromAddress, byte[] toAddress) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getdelegatedresource"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("fromAddress", ByteArray.toHexString(fromAddress)); - userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getDelegatedResourceAccountIndex(String httpNode, - byte[] queryAddress) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getdelegatedresourceaccountindex"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", ByteArray.toHexString(queryAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getDelegatedResourceAccountIndexFromSolidity(String httpSolidityNode, - byte[] queryAddress) { - try { - String requestUrl = - "http://" + httpSolidityNode + "/walletsolidity/getdelegatedresourceaccountindex"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", ByteArray.toHexString(queryAddress)); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse createConnect(String url) { - return createConnect(url, null); - } - - /** - * constructor. - */ - public static HttpResponse createConnect(String url, JsonObject requestBody) { - try { - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout); - httppost = new HttpPost(url); - httppost.setHeader("Content-type", "application/json; charset=utf-8"); - httppost.setHeader("Connection", "Close"); - if (requestBody != null) { - StringEntity entity = new StringEntity(requestBody.toString(), Charset.forName("UTF-8")); - entity.setContentEncoding("UTF-8"); - entity.setContentType("application/json"); - httppost.setEntity(entity); - } - response = httpClient.execute(httppost); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static Long createConnectForResponse(String url, JsonObject requestBody, Integer times) { - try { - - Long start = 0L; - Long end = 0L; - Long duration = 0L; - while (times-- > 0) { - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout); - httppost = new HttpPost(url); - httppost.setHeader("Content-type", "application/json; charset=utf-8"); - httppost.setHeader("Connection", "Close"); - if (requestBody != null) { - StringEntity entity = new StringEntity(requestBody.toString(), Charset.forName("UTF-8")); - entity.setContentEncoding("UTF-8"); - entity.setContentType("application/json"); - httppost.setEntity(entity); - } - - start = System.currentTimeMillis(); - response = httpClient.execute(httppost); - /* responseContent = HttpMethed.parseResponseContent(response); - logger.info(responseContent.toString());*/ - end = System.currentTimeMillis(); - duration = duration + end - start; - httppost.releaseConnection(); - } - return duration; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return -1L; - } - } - - - - /** - * constructor. - */ - public static HttpResponse createConnect1(String url, JSONObject requestBody) { - try { - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout * 10000); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout * 10000); - httppost = new HttpPost(url); - httppost.setHeader("Content-type", "application/json; charset=utf-8"); - httppost.setHeader("Connection", "Close"); - if (requestBody != null) { - StringEntity entity = new StringEntity(requestBody.toString(), Charset.forName("UTF-8")); - entity.setContentEncoding("UTF-8"); - entity.setContentType("application/json"); - httppost.setEntity(entity); - } - response = httpClient.execute(httppost); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getAssetissueList(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getassetissuelist"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static Long getAssetIssueValue(String httpNode, byte[] accountAddress, - String assetIssueId) { - response = HttpMethed.getAccount(httpNode, accountAddress); - responseContent = HttpMethed.parseResponseContent(response); - JSONArray assetV2 = responseContent.getJSONArray("assetV2"); - if (assetV2 != null && assetV2.size() > 0) { - for (int i = 0; i < assetV2.size(); i++) { - String assetString = assetV2.get(i).toString(); - logger.info("assetString:" + assetString); - String assetKey = HttpMethed.parseStringContent(assetString).getString("key"); - if (assetKey.equals(assetIssueId)) { - return HttpMethed.parseStringContent(assetString).getLong("value"); - } - } - } - return 0L; - } - - /** - * constructor. - */ - public static HttpResponse getAssetIssueListFromSolidity(String httpSolidityNode) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getassetissuelist"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getPaginatedAssetissueList(String httpNode, Integer offset, - Integer limit) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getpaginatedassetissuelist"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("offset", offset); - userBaseObj2.addProperty("limit", limit); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getPaginatedAssetissueListFromSolidity(String httpSolidityNode, - Integer offset, Integer limit) { - try { - String requestUrl = - "http://" + httpSolidityNode + "/walletsolidity/getpaginatedassetissuelist"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("offset", offset); - userBaseObj2.addProperty("limit", limit); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getPaginatedProposalList(String httpNode, Integer offset, - Integer limit) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getpaginatedproposallist"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("offset", offset); - userBaseObj2.addProperty("limit", limit); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse getPaginatedExchangeList(String httpNode, Integer offset, - Integer limit) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getpaginatedexchangelist"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("offset", offset); - userBaseObj2.addProperty("limit", limit); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse updateSetting(String httpNode, byte[] ownerAddress, - String contractAddress, Integer consumeUserResourcePercent, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/updatesetting"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("contract_address", contractAddress); - userBaseObj2.addProperty("consume_user_resource_percent", consumeUserResourcePercent); - logger.info(userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse updateEnergyLimit(String httpNode, byte[] ownerAddress, - String contractAddress, Integer originEnergyLimit, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/updateenergylimit"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("contract_address", contractAddress); - userBaseObj2.addProperty("origin_energy_limit", originEnergyLimit); - logger.info(userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - logger.info(transactionString); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse createAddress(String httpNode, String value) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/createaddress"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", str2hex(value)); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse generateAddress(String httpNode) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/generateaddress"; - JsonObject userBaseObj2 = new JsonObject(); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static HttpResponse validateAddress(String httpNode, String address) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/validateaddress"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", address); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse easyTransfer(String httpNode, String value, byte[] toAddress, - Long amount) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/easytransfer"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("passPhrase", str2hex(value)); - userBaseObj2.addProperty("amount", amount); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse easyTransferByPrivate(String httpNode, String privateKey, - byte[] toAddress, Long amount) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/easytransferbyprivate"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("privateKey", privateKey); - userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("amount", amount); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse easyTransferAsset(String httpNode, String value, byte[] toAddress, - Long amount, String assetId) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/easytransferasset"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("passPhrase", str2hex(value)); - userBaseObj2.addProperty("amount", amount); - userBaseObj2.addProperty("assetId", assetId); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse easyTransferAssetByPrivate(String httpNode, String privateKey, - byte[] toAddress, Long amount, String assetId) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/easytransferassetbyprivate"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("privateKey", privateKey); - userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress)); - userBaseObj2.addProperty("amount", amount); - userBaseObj2.addProperty("assetId", assetId); - response = createConnect(requestUrl, userBaseObj2); - logger.info(userBaseObj2.toString()); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - - /** - * constructor. - */ - public static void disConnect() { - httppost.releaseConnection(); - } - - /** - * constructor. - */ - public static JSONObject parseResponseContent(HttpResponse response) { - try { - String result = EntityUtils.toString(response.getEntity()); - StringEntity entity = new StringEntity(result, Charset.forName("UTF-8")); - response.setEntity(entity); - JSONObject obj = JSONObject.parseObject(result); - return obj; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - /** - * constructor. - */ - public static JSONObject parseStringContent(String content) { - try { - JSONObject obj = JSONObject.parseObject(content); - return obj; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - /** - * constructor. - */ - public static void printJsonContent(JSONObject responseContent) { - logger.info("----------------------------Print JSON Start---------------------------"); - for (String str : responseContent.keySet()) { - logger.info(str + ":" + responseContent.get(str)); - } - logger.info("JSON content size are: " + responseContent.size()); - logger.info("----------------------------Print JSON End-----------------------------"); - } - - /** - * constructor. - */ - public static String str2hex(String str) { - char[] chars = "0123456789ABCDEF".toCharArray(); - StringBuilder sb = new StringBuilder(""); - byte[] bs = str.getBytes(); - int bit; - for (int i = 0; i < bs.length; i++) { - bit = (bs[i] & 0x0f0) >> 4; - sb.append(chars[bit]); - bit = bs[i] & 0x0f; - sb.append(chars[bit]); - // sb.append(' '); - } - return sb.toString().trim(); - } - - - /** - * constructor. - */ - public static HttpResponse clearABiGetTxid(String httpNode, byte[] ownerAddress, - String contractAddress, String fromKey) { - try { - final String requestUrl = "http://" + httpNode + "/wallet/clearabi"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress)); - userBaseObj2.addProperty("contract_address", contractAddress); - response = createConnect(requestUrl, userBaseObj2); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - - transactionSignString = gettransactionsign(httpNode, transactionString, fromKey); - - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - - - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static Optional generateShieldAddress(String httpnode) { - ShieldAddressInfo addressInfo = new ShieldAddressInfo(); - String sk; - String d; - String ask; - String nsk; - String ovk; - String ak; - String nk; - String ivk; - String pkD; - try { - response = HttpMethed.getSpendingKey(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - sk = responseContent.getString("value"); - - response = HttpMethed.getDiversifier(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - d = responseContent.getString("d"); - - response = HttpMethed.getExpandedSpendingKey(httpnode, sk); - responseContent = HttpMethed.parseResponseContent(response); - ask = responseContent.getString("ask"); - nsk = responseContent.getString("nsk"); - ovk = responseContent.getString("ovk"); - - response = HttpMethed.getAkFromAsk(httpnode, ask); - responseContent = HttpMethed.parseResponseContent(response); - ak = responseContent.getString("value"); - - response = HttpMethed.getNkFromNsk(httpnode, nsk); - responseContent = HttpMethed.parseResponseContent(response); - nk = responseContent.getString("value"); - - response = HttpMethed.getIncomingViewingKey(httpnode, ak, nk); - responseContent = HttpMethed.parseResponseContent(response); - ivk = responseContent.getString("ivk"); - - response = HttpMethed.getZenPaymentAddress(httpnode, ivk, d); - responseContent = HttpMethed.parseResponseContent(response); - pkD = responseContent.getString("pkD"); - - addressInfo.setSk(ByteArray.fromHexString(sk)); - addressInfo.setD(new DiversifierT(ByteArray.fromHexString(d))); - addressInfo.setIvk(ByteArray.fromHexString(ivk)); - addressInfo.setOvk(ByteArray.fromHexString(ovk)); - addressInfo.setPkD(ByteArray.fromHexString(pkD)); - logger.info("sk:" + sk); - - if (addressInfo.validateCheck()) { - return Optional.of(addressInfo); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return Optional.empty(); - } - - /** - * constructor. - */ - public static List addShieldOutputList(String httpNode, - List shieldOutList, String shieldToAddress, - String toAmountString, String menoString) { - String shieldAddress = shieldToAddress; - String amountString = toAmountString; - if (menoString.equals("null")) { - menoString = ""; - } - long shieldAmount = 0; - if (!StringUtil.isNullOrEmpty(amountString)) { - shieldAmount = Long.valueOf(amountString); - } - - GrpcAPI.Note.Builder noteBuild = GrpcAPI.Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddress); - noteBuild.setPaymentAddress(shieldAddress); - noteBuild.setValue(shieldAmount); - - response = HttpMethed.getRcm(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - String rcm = responseContent.getString("value"); - - noteBuild.setRcm(ByteString.copyFrom(rcm.getBytes())); - noteBuild.setMemo(ByteString.copyFrom(menoString.getBytes())); - shieldOutList.add(noteBuild.build()); - return shieldOutList; - } - - /** - * constructor. - */ - public static HttpResponse getSpendingKey(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getspendingkey"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getDiversifier(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getdiversifier"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getRcm(String httpNode) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getrcm"; - response = createConnect(requestUrl); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getExpandedSpendingKey(String httpNode, String spendingKey) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getexpandedspendingkey"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", spendingKey); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getAkFromAsk(String httpNode, String ask) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getakfromask"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", ask); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getNkFromNsk(String httpNode, String nsk) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getnkfromnsk"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("value", nsk); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getIncomingViewingKey(String httpNode, String ak, String nk) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getincomingviewingkey"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("ak", ak); - userBaseObj2.addProperty("nk", nk); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getZenPaymentAddress(String httpNode, String ivk, String d) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getzenpaymentaddress"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("ivk", ivk); - userBaseObj2.addProperty("d", d); - response = createConnect(requestUrl, userBaseObj2); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getMerkleTreeVoucherInfo(String httpNode, String hash, Integer index, - int blockNum) { - try { - String requestUrl = "http://" + httpNode + "/wallet/getmerkletreevoucherinfo"; - JSONObjectWarp jsonObjectWarp = new JSONObjectWarp(); - jsonObjectWarp - .put("out_points", Lists.newArrayList(new JSONObjectWarp() - .put("hash", hash) - .put("index", index))) - .put("block_num", blockNum); - String jsonStr = jsonObjectWarp.toJSONString(); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - logger.info("jsonObj:" + jsonObj.toString()); - response = createConnect(requestUrl, jsonObj); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse getMerkleTreeVoucherInfoFromSolidity(String httpSolidityNode, - String hash, Integer index, int blockNum) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getmerkletreevoucherinfo"; - JSONObjectWarp jsonObjectWarp = new JSONObjectWarp(); - jsonObjectWarp - .put("out_points", Lists.newArrayList(new JSONObjectWarp() - .put("hash", hash) - .put("index", index))) - .put("block_num", blockNum); - String jsonStr = jsonObjectWarp.toJSONString(); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - logger.info("jsonObj:" + jsonObj.toString()); - response = createConnect(requestUrl, jsonObj); - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static HttpResponse sendShieldCoin(String httpNode, byte[] publicZenTokenOwnerAddress, - long fromAmount, ShieldAddressInfo shieldAddressInfo, - ShieldNoteInfo noteTx, List shieldOutputList, - byte[] publicZenTokenToAddress, - long toAmount, String zenTokenOwnerKey) { - try { - String requestUrl = "http://" + httpNode + "/wallet/createshieldedtransaction"; - - Map map = new HashMap(); - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - map.put("transparent_from_address", ByteArray.toHexString(publicZenTokenOwnerAddress)); - map.put("from_amount", fromAmount); - } - if (shieldAddressInfo != null) { - HttpResponse expandedSpendingKey = HttpMethed - .getExpandedSpendingKey(httpNode, ByteArray.toHexString(shieldAddressInfo.getSk())); - responseContent = HttpMethed.parseResponseContent(expandedSpendingKey); - HttpMethed.printJsonContent(responseContent); - String ovk = responseContent.getString("ovk"); - map.put("ask", responseContent.getString("ask")); - map.put("nsk", responseContent.getString("nsk")); - map.put("ovk", ovk); - - response = HttpMethed - .getMerkleTreeVoucherInfo(httpNode, noteTx.getTrxId(), noteTx.getIndex(), 1); - responseContent = HttpMethed.parseResponseContent(response); - JSONArray vouchers = responseContent.getJSONArray("vouchers"); - JSONArray paths = responseContent.getJSONArray("paths"); - - List shieldedSpends = Lists.newArrayList( - new JSONObjectWarp() - .put("note", new JSONObjectWarp() - .put("value", noteTx.getValue()) - .put("payment_address", noteTx.getPaymentAddress()) - .put("rcm", ByteArray.toHexString(noteTx.getR())) - .put("memo", ByteArray.toHexString(noteTx.getMemo()))) - .put("alpha", ByteArray.toHexString(org.tron.core.zen.note.Note.generateR())) - .put("voucher", Lists.newArrayList(vouchers)) - .put("path", Lists.newArrayList(paths)) - ); - - map.put("shielded_spends", shieldedSpends); - } else { - map.put("ovk", "030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d"); - } - - if (!ByteUtil.isNullOrZeroArray(publicZenTokenToAddress)) { - map.put("transparent_to_address", ByteArray.toHexString(publicZenTokenToAddress)); - map.put("to_amount", toAmount); - } - - if (shieldOutputList.size() > 0) { - ArrayList noteList = new ArrayList<>(); - for (int i = 0; i < shieldOutputList.size(); ++i) { - Map note = new HashMap(); - Map noteInfo = new HashMap(); - noteInfo.put("value", shieldOutputList.get(i).getValue()); - noteInfo.put("payment_address", shieldOutputList.get(i).getPaymentAddress()); - noteInfo.put("rcm", shieldOutputList.get(i).getRcm().toStringUtf8()); - noteInfo.put("memo", - ByteArray.toHexString(shieldOutputList.get(i).getMemo().toStringUtf8().getBytes())); - note.put("note", noteInfo); - noteList.add(note); - } - map.put("shielded_receives", noteList); - } - - String jsonStr = new Gson().toJson(map); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - logger.info("jsonObj:" + jsonObj.toString()); - response = createConnect(requestUrl, jsonObj); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info(transactionString); - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - transactionSignString = gettransactionsign(httpNode, transactionString, zenTokenOwnerKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } else { - response = broadcastTransaction(httpNode, transactionString); - } - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - - /** - * constructor. - */ - public static Boolean getSpendResult(String httpNode, ShieldAddressInfo shieldAddressInfo, - ShieldNoteInfo noteTx) { - try { - String requestUrl = "http://" + httpNode + "/wallet/isspend"; - JSONObjectWarp jsonObjectWarp = new JSONObjectWarp(); - - response = HttpMethed - .getExpandedSpendingKey(httpNode, ByteArray.toHexString(shieldAddressInfo.sk)); - responseContent = HttpMethed.parseResponseContent(response); - String ask = responseContent.getString("ask"); - String nsk = responseContent.getString("nsk"); - response = HttpMethed.getAkFromAsk(httpNode, ask); - responseContent = HttpMethed.parseResponseContent(response); - jsonObjectWarp.put("ak", responseContent.getString("value")); - - response = HttpMethed.getNkFromNsk(httpNode, nsk); - responseContent = HttpMethed.parseResponseContent(response); - jsonObjectWarp.put("nk", responseContent.getString("value")); - - jsonObjectWarp.put("note", new JSONObjectWarp() - .put("value", noteTx.getValue()) - .put("payment_address", noteTx.getPaymentAddress()) - .put("rcm", ByteArray.toHexString(noteTx.getR())) - .put("memo", ByteArray.toHexString(noteTx.getMemo()))) - .put("txid", noteTx.getTrxId()); - - String jsonStr = jsonObjectWarp.toJSONString(); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - logger.info("jsonObj:" + jsonObj.toString()); - HttpMethed.response = createConnect(requestUrl, jsonObj); - - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String jsonString = responseContent.toJSONString(); - if (jsonString.contains("result") && (responseContent.getString("result").equals("true") - && responseContent.getString("message").equals("input note already spent"))) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; - } - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static Boolean getSpendResultFromSolidity(String httpNode, String httpSolidityNode, - ShieldAddressInfo shieldAddressInfo, ShieldNoteInfo noteTx) { - try { - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/isspend"; - JSONObjectWarp jsonObjectWarp = new JSONObjectWarp(); - - response = HttpMethed - .getExpandedSpendingKey(httpNode, ByteArray.toHexString(shieldAddressInfo.sk)); - responseContent = HttpMethed.parseResponseContent(response); - String ask = responseContent.getString("ask"); - String nsk = responseContent.getString("nsk"); - response = HttpMethed.getAkFromAsk(httpNode, ask); - responseContent = HttpMethed.parseResponseContent(response); - jsonObjectWarp.put("ak", responseContent.getString("value")); - - response = HttpMethed.getNkFromNsk(httpNode, nsk); - responseContent = HttpMethed.parseResponseContent(response); - jsonObjectWarp.put("nk", responseContent.getString("value")); - - jsonObjectWarp.put("note", new JSONObjectWarp() - .put("value", noteTx.getValue()) - .put("payment_address", noteTx.getPaymentAddress()) - .put("rcm", ByteArray.toHexString(noteTx.getR())) - .put("memo", ByteArray.toHexString(noteTx.getMemo()))) - .put("txid", noteTx.getTrxId()); - - String jsonStr = jsonObjectWarp.toJSONString(); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - logger.info("jsonObj:" + jsonObj.toString()); - HttpMethed.response = createConnect(requestUrl, jsonObj); - responseContent = HttpMethed.parseResponseContent(response); - - HttpMethed.printJsonContent(responseContent); - String jsonString = responseContent.toJSONString(); - if (jsonString.contains("result") && (responseContent.getString("result").equals("true") - && responseContent.getString("message").equals("input note already spent"))) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; - } - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static List scanNoteByIvk(String httpNode, - ShieldAddressInfo shieldAddressInfo) { - try { - response = HttpMethed.getNowBlock(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String blockHeaderString = responseContent.getString("block_header"); - String rawDataString = HttpMethed.parseStringContent(blockHeaderString).get("raw_data") - .toString(); - Integer currentBlockNum = HttpMethed.parseStringContent(rawDataString).getInteger("number"); - Integer startBlockNum = 0; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - - String requestUrl = "http://" + httpNode + "/wallet/scannotebyivk"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("start_block_index", startBlockNum); - userBaseObj2.addProperty("end_block_index", currentBlockNum); - userBaseObj2.addProperty("ivk", ByteArray.toHexString(shieldAddressInfo.ivk)); - logger.info("userBaseObj2:" + userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - List shieldNoteInfoList = new ArrayList<>(); - JSONArray jsonArray = responseContent.getJSONArray("noteTxs"); - if (jsonArray != null) { - for (int i = 0; i < jsonArray.size(); i++) { - ShieldNoteInfo noteTx = new ShieldNoteInfo(); - String noteTxs = jsonArray.get(i).toString(); - String noteString = HttpMethed.parseStringContent(noteTxs).getString("note"); - noteTx.setValue(HttpMethed.parseStringContent(noteString).getLong("value")); - noteTx - .setPaymentAddress( - HttpMethed.parseStringContent(noteString).getString("payment_address")); - noteTx - .setR( - ByteArray - .fromHexString(HttpMethed.parseStringContent(noteString).getString("rcm"))); - noteTx.setMemo( - ByteArray.fromHexString(HttpMethed.parseStringContent(noteString).getString("memo"))); - noteTx.setTrxId(HttpMethed.parseStringContent(noteTxs).getString("txid")); - noteTx.setIndex(HttpMethed.parseStringContent(noteTxs).getIntValue("index")); - shieldNoteInfoList.add(noteTx); - } - } - return shieldNoteInfoList; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static List scanNoteByIvkFromSolidity(String httpSolidityNode, - ShieldAddressInfo shieldAddressInfo) { - try { - response = HttpMethed.getNowBlockFromSolidity(httpSolidityNode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String blockHeaderString = responseContent.getString("block_header"); - String rawDataString = HttpMethed.parseStringContent(blockHeaderString).get("raw_data") - .toString(); - Integer currentBlockNum = HttpMethed.parseStringContent(rawDataString).getInteger("number"); - Integer startBlockNum = 0; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/scannotebyivk"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("start_block_index", startBlockNum); - userBaseObj2.addProperty("end_block_index", currentBlockNum); - userBaseObj2.addProperty("ivk", ByteArray.toHexString(shieldAddressInfo.ivk)); - logger.info("userBaseObj2:" + userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - List shieldNoteInfoList = new ArrayList<>(); - JSONArray jsonArray = responseContent.getJSONArray("noteTxs"); - for (int i = 0; i < jsonArray.size(); i++) { - ShieldNoteInfo noteTx = new ShieldNoteInfo(); - String noteTxs = jsonArray.get(i).toString(); - String noteString = HttpMethed.parseStringContent(noteTxs).getString("note"); - noteTx.setValue(HttpMethed.parseStringContent(noteString).getLong("value")); - noteTx - .setPaymentAddress( - HttpMethed.parseStringContent(noteString).getString("payment_address")); - noteTx - .setR( - ByteArray - .fromHexString(HttpMethed.parseStringContent(noteString).getString("rcm"))); - noteTx.setMemo( - ByteArray.fromHexString(HttpMethed.parseStringContent(noteString).getString("memo"))); - noteTx.setTrxId(HttpMethed.parseStringContent(noteTxs).getString("txid")); - noteTx.setIndex(HttpMethed.parseStringContent(noteTxs).getIntValue("index")); - shieldNoteInfoList.add(noteTx); - } - return shieldNoteInfoList; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static List scanAndMarkNoteByIvk(String httpNode, - ShieldAddressInfo shieldAddressInfo) { - try { - response = HttpMethed - .getExpandedSpendingKey(httpNode, ByteArray.toHexString(shieldAddressInfo.sk)); - responseContent = HttpMethed.parseResponseContent(response); - String ask = responseContent.getString("ask"); - String nsk = responseContent.getString("nsk"); - response = HttpMethed.getAkFromAsk(httpNode, ask); - responseContent = HttpMethed.parseResponseContent(response); - String ak = responseContent.getString("value"); - - response = HttpMethed.getNkFromNsk(httpNode, nsk); - responseContent = HttpMethed.parseResponseContent(response); - String nk = responseContent.getString("value"); - - response = HttpMethed.getNowBlock(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String blockHeaderString = responseContent.getString("block_header"); - String rawDataString = HttpMethed.parseStringContent(blockHeaderString).get("raw_data") - .toString(); - Integer currentBlockNum = HttpMethed.parseStringContent(rawDataString).getInteger("number"); - Integer startBlockNum = 0; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - - String requestUrl = "http://" + httpNode + "/wallet/scanandmarknotebyivk"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("start_block_index", startBlockNum); - userBaseObj2.addProperty("end_block_index", currentBlockNum); - userBaseObj2.addProperty("ivk", ByteArray.toHexString(shieldAddressInfo.ivk)); - userBaseObj2.addProperty("ak", ak); - userBaseObj2.addProperty("nk", nk); - logger.info("userBaseObj2:" + userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - List shieldNoteInfoList = new ArrayList<>(); - JSONArray jsonArray = responseContent.getJSONArray("noteTxs"); - logger.info("jsonArray:" + jsonArray.toJSONString()); - for (int i = 0; i < jsonArray.size(); i++) { - ShieldNoteInfo noteTx = new ShieldNoteInfo(); - String noteTxs = jsonArray.get(i).toString(); - String noteString = HttpMethed.parseStringContent(noteTxs).getString("note"); - noteTx.setValue(HttpMethed.parseStringContent(noteString).getLong("value")); - noteTx - .setPaymentAddress( - HttpMethed.parseStringContent(noteString).getString("payment_address")); - noteTx - .setR( - ByteArray - .fromHexString(HttpMethed.parseStringContent(noteString).getString("rcm"))); - noteTx.setMemo( - ByteArray.fromHexString(HttpMethed.parseStringContent(noteString).getString("memo"))); - noteTx.setTrxId(HttpMethed.parseStringContent(noteTxs).getString("txid")); - noteTx.setIsSpend(HttpMethed.parseStringContent(noteTxs).getBoolean("is_spend")); - noteTx.setIndex(HttpMethed.parseStringContent(noteTxs).getIntValue("index")); - shieldNoteInfoList.add(noteTx); - } - return shieldNoteInfoList; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static List scanAndMarkNoteByIvkFromSolidity(String httpNode, - String httpSolidityNode, ShieldAddressInfo shieldAddressInfo) { - try { - response = HttpMethed - .getExpandedSpendingKey(httpNode, ByteArray.toHexString(shieldAddressInfo.sk)); - responseContent = HttpMethed.parseResponseContent(response); - String ask = responseContent.getString("ask"); - String nsk = responseContent.getString("nsk"); - response = HttpMethed.getAkFromAsk(httpNode, ask); - responseContent = HttpMethed.parseResponseContent(response); - String ak = responseContent.getString("value"); - - response = HttpMethed.getNkFromNsk(httpNode, nsk); - responseContent = HttpMethed.parseResponseContent(response); - String nk = responseContent.getString("value"); - - response = HttpMethed.getNowBlock(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String blockHeaderString = responseContent.getString("block_header"); - String rawDataString = HttpMethed.parseStringContent(blockHeaderString).get("raw_data") - .toString(); - Integer currentBlockNum = HttpMethed.parseStringContent(rawDataString).getInteger("number"); - Integer startBlockNum = 0; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/scanandmarknotebyivk"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("start_block_index", startBlockNum); - userBaseObj2.addProperty("end_block_index", currentBlockNum); - userBaseObj2.addProperty("ivk", ByteArray.toHexString(shieldAddressInfo.ivk)); - userBaseObj2.addProperty("ak", ak); - userBaseObj2.addProperty("nk", nk); - logger.info("userBaseObj2:" + userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - List shieldNoteInfoList = new ArrayList<>(); - JSONArray jsonArray = responseContent.getJSONArray("noteTxs"); - logger.info("jsonArray:" + jsonArray.toJSONString()); - for (int i = 0; i < jsonArray.size(); i++) { - ShieldNoteInfo noteTx = new ShieldNoteInfo(); - String noteTxs = jsonArray.get(i).toString(); - String noteString = HttpMethed.parseStringContent(noteTxs).getString("note"); - noteTx.setValue(HttpMethed.parseStringContent(noteString).getLong("value")); - noteTx - .setPaymentAddress( - HttpMethed.parseStringContent(noteString).getString("payment_address")); - noteTx - .setR( - ByteArray - .fromHexString(HttpMethed.parseStringContent(noteString).getString("rcm"))); - noteTx.setMemo( - ByteArray.fromHexString(HttpMethed.parseStringContent(noteString).getString("memo"))); - noteTx.setTrxId(HttpMethed.parseStringContent(noteTxs).getString("txid")); - noteTx.setIsSpend(HttpMethed.parseStringContent(noteTxs).getBoolean("is_spend")); - noteTx.setIndex(HttpMethed.parseStringContent(noteTxs).getIntValue("index")); - shieldNoteInfoList.add(noteTx); - } - return shieldNoteInfoList; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static List scanNoteByOvk(String httpNode, - ShieldAddressInfo shieldAddressInfo) { - try { - response = HttpMethed.getNowBlock(httpNode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String blockHeaderString = responseContent.getString("block_header"); - String rawDataString = HttpMethed.parseStringContent(blockHeaderString).get("raw_data") - .toString(); - Integer currentBlockNum = HttpMethed.parseStringContent(rawDataString).getInteger("number"); - Integer startBlockNum = 0; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - - String requestUrl = "http://" + httpNode + "/wallet/scannotebyovk"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("start_block_index", startBlockNum); - userBaseObj2.addProperty("end_block_index", currentBlockNum); - userBaseObj2.addProperty("ovk", ByteArray.toHexString(shieldAddressInfo.getOvk())); - logger.info("userBaseObj2:" + userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - List shieldNoteInfoList = new ArrayList<>(); - JSONArray jsonArray = responseContent.getJSONArray("noteTxs"); - for (int i = 0; i < jsonArray.size(); i++) { - ShieldNoteInfo noteTx = new ShieldNoteInfo(); - String noteTxs = jsonArray.get(i).toString(); - String noteString = HttpMethed.parseStringContent(noteTxs).getString("note"); - noteTx.setValue(HttpMethed.parseStringContent(noteString).getLong("value")); - noteTx - .setPaymentAddress( - HttpMethed.parseStringContent(noteString).getString("payment_address")); - noteTx - .setR( - ByteArray - .fromHexString(HttpMethed.parseStringContent(noteString).getString("rcm"))); - noteTx.setMemo( - ByteArray.fromHexString(HttpMethed.parseStringContent(noteString).getString("memo"))); - noteTx.setTrxId(HttpMethed.parseStringContent(noteTxs).getString("txid")); - noteTx.setIndex(HttpMethed.parseStringContent(noteTxs).getIntValue("index")); - shieldNoteInfoList.add(noteTx); - } - return shieldNoteInfoList; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static List scanNoteByOvkFromSolidity(String httpSolidityNode, - ShieldAddressInfo shieldAddressInfo) { - try { - response = HttpMethed.getNowBlockFromSolidity(httpSolidityNode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String blockHeaderString = responseContent.getString("block_header"); - String rawDataString = HttpMethed.parseStringContent(blockHeaderString).get("raw_data") - .toString(); - Integer currentBlockNum = HttpMethed.parseStringContent(rawDataString).getInteger("number"); - Integer startBlockNum = 0; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - - String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/scannotebyovk"; - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("start_block_index", startBlockNum); - userBaseObj2.addProperty("end_block_index", currentBlockNum); - userBaseObj2.addProperty("ovk", ByteArray.toHexString(shieldAddressInfo.getOvk())); - logger.info("userBaseObj2:" + userBaseObj2.toString()); - response = createConnect(requestUrl, userBaseObj2); - - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - List shieldNoteInfoList = new ArrayList<>(); - JSONArray jsonArray = responseContent.getJSONArray("noteTxs"); - for (int i = 0; i < jsonArray.size(); i++) { - ShieldNoteInfo noteTx = new ShieldNoteInfo(); - String noteTxs = jsonArray.get(0).toString(); - String noteString = HttpMethed.parseStringContent(noteTxs).getString("note"); - noteTx.setValue(HttpMethed.parseStringContent(noteString).getLong("value")); - noteTx - .setPaymentAddress( - HttpMethed.parseStringContent(noteString).getString("payment_address")); - noteTx - .setR( - ByteArray - .fromHexString(HttpMethed.parseStringContent(noteString).getString("rcm"))); - noteTx.setMemo( - ByteArray.fromHexString(HttpMethed.parseStringContent(noteString).getString("memo"))); - noteTx.setTrxId(HttpMethed.parseStringContent(noteTxs).getString("txid")); - noteTx.setIndex(HttpMethed.parseStringContent(noteTxs).getIntValue("index")); - shieldNoteInfoList.add(noteTx); - } - return shieldNoteInfoList; - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - } - - /** - * constructor. - */ - public static HttpResponse sendShieldCoinWithoutAsk(String httpNode, String httpSolidityNode, - byte[] publicZenTokenOwnerAddress, - long fromAmount, ShieldAddressInfo shieldAddressInfo, - ShieldNoteInfo noteTx, List shieldOutputList, - byte[] publicZenTokenToAddress, - long toAmount, String zenTokenOwnerKey) { - try { - String requestUrl = - "http://" + httpNode + "/wallet/createshieldedtransactionwithoutspendauthsig"; - - Map map = new HashMap(); - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - map.put("transparent_from_address", ByteArray.toHexString(publicZenTokenOwnerAddress)); - map.put("from_amount", fromAmount); - } - String ask = ""; - byte[] alpha = null; - if (shieldAddressInfo != null) { - HttpResponse expandedSpendingKey = HttpMethed - .getExpandedSpendingKey(httpNode, ByteArray.toHexString(shieldAddressInfo.getSk())); - responseContent = HttpMethed.parseResponseContent(expandedSpendingKey); - HttpMethed.printJsonContent(responseContent); - map.put("nsk", responseContent.getString("nsk")); - map.put("ovk", responseContent.getString("ovk")); - ask = responseContent.getString("ask"); - response = HttpMethed.getAkFromAsk(httpNode, ask); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - map.put("ak", responseContent.getString("value")); - - logger.info("noteTx.getTrxId():" + noteTx.getTrxId()); - HttpMethed.response = HttpMethed - .getMerkleTreeVoucherInfoFromSolidity(httpSolidityNode, noteTx.getTrxId(), - noteTx.getIndex(), 3); - HttpMethed.responseContent = HttpMethed.parseResponseContent(HttpMethed.response); - HttpMethed.printJsonContent(responseContent); - JSONArray vouchers = HttpMethed.responseContent.getJSONArray("vouchers"); - JSONArray paths = HttpMethed.responseContent.getJSONArray("paths"); - alpha = org.tron.core.zen.note.Note.generateR(); - - List shieldedSpends = Lists.newArrayList( - new JSONObjectWarp() - .put("note", new JSONObjectWarp() - .put("value", noteTx.getValue()) - .put("payment_address", noteTx.getPaymentAddress()) - .put("rcm", ByteArray.toHexString(noteTx.getR())) - .put("memo", ByteArray.toHexString(noteTx.getMemo()))) - .put("alpha", ByteArray.toHexString(alpha)) - .put("voucher", Lists.newArrayList(vouchers)) - .put("path", Lists.newArrayList(paths)) - ); - - map.put("shielded_spends", shieldedSpends); - } else { - map.put("ovk", "030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d"); - } - - if (!ByteUtil.isNullOrZeroArray(publicZenTokenToAddress)) { - map.put("transparent_to_address", ByteArray.toHexString(publicZenTokenToAddress)); - map.put("to_amount", toAmount); - } - - if (shieldOutputList.size() > 0) { - ArrayList noteList = new ArrayList<>(); - for (int i = 0; i < shieldOutputList.size(); ++i) { - Map note = new HashMap(); - Map noteInfo = new HashMap(); - noteInfo.put("value", shieldOutputList.get(i).getValue()); - noteInfo.put("payment_address", shieldOutputList.get(i).getPaymentAddress()); - noteInfo.put("rcm", shieldOutputList.get(i).getRcm().toStringUtf8()); - noteInfo.put("memo", - ByteArray.toHexString(shieldOutputList.get(i).getMemo().toStringUtf8().getBytes())); - note.put("note", noteInfo); - noteList.add(note); - } - map.put("shielded_receives", noteList); - } - - String jsonStr = new Gson().toJson(map); - JsonObject jsonObj = new JsonParser().parse(jsonStr).getAsJsonObject(); - logger.info("jsonObj:" + jsonObj.toString()); - response = createConnect(requestUrl, jsonObj); - transactionString = EntityUtils.toString(response.getEntity()); - logger.info("transactionString1:" + transactionString); - - if (shieldAddressInfo != null) { - String getHashUrl = "http://" + httpNode + "/wallet/getshieldtransactionhash"; - JsonObject gethashObject = new JsonParser().parse(transactionString).getAsJsonObject(); - logger.info("gethashObject:" + gethashObject); - response = createConnect(getHashUrl, gethashObject); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String hash = responseContent.getString("value"); - - String spendauthsigUrl = "http://" + httpNode + "/wallet/createspendauthsig"; - JSONObjectWarp spendauthsigJson = new JSONObjectWarp() - .put("ask", ask) - .put("alpha", ByteArray.toHexString(alpha)) - .put("tx_hash", hash); - String spendauthsigStr = spendauthsigJson.toJSONString(); - JsonObject spendauthsigObj = new JsonParser().parse(spendauthsigStr).getAsJsonObject(); - logger.info("spendauthsigObj:" + spendauthsigObj.toString()); - response = createConnect(spendauthsigUrl, spendauthsigObj); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String spendauthsig = responseContent.getString("value"); - - JSONObject jsonObject = HttpMethed.parseStringContent(transactionString); - jsonObject.getJSONObject("raw_data").getJSONArray("contract") - .getJSONObject(0).getJSONObject("parameter").getJSONObject("value") - .getJSONArray("spend_description").getJSONObject(0) - .put("spend_authority_signature", spendauthsig); - transactionString = jsonObject.toString(); - logger.info("transactionString2:" + transactionString); - } - - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - transactionSignString = gettransactionsign(httpNode, transactionString, zenTokenOwnerKey); - logger.info(transactionSignString); - response = broadcastTransaction(httpNode, transactionSignString); - } else { - response = broadcastTransaction(httpNode, transactionString); - } - } catch (Exception e) { - e.printStackTrace(); - httppost.releaseConnection(); - return null; - } - return response; - } - -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/JSONObjectWarp.java b/src/test/java/stest/tron/wallet/common/client/utils/JSONObjectWarp.java deleted file mode 100755 index b482068f118..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/JSONObjectWarp.java +++ /dev/null @@ -1,11 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import com.alibaba.fastjson.JSONObject; - -public class JSONObjectWarp extends JSONObject { - - public JSONObjectWarp put(String key, Object value) { - super.put(key, value); - return this; - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/PublicMethed.java b/src/test/java/stest/tron/wallet/common/client/utils/PublicMethed.java deleted file mode 100644 index 9d60c61de69..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/PublicMethed.java +++ /dev/null @@ -1,5769 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.google.common.primitives.Longs; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.protobuf.Any; -import com.google.protobuf.ByteString; -import io.netty.util.internal.StringUtil; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.DecryptNotes.NoteTx; -import org.tron.api.GrpcAPI.DecryptNotesMarked; -import org.tron.api.GrpcAPI.DelegatedResourceList; -import org.tron.api.GrpcAPI.DelegatedResourceMessage; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ExchangeList; -import org.tron.api.GrpcAPI.IvkDecryptAndMarkParameters; -import org.tron.api.GrpcAPI.IvkDecryptParameters; -import org.tron.api.GrpcAPI.NfParameters; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.GrpcAPI.NoteParameters; -import org.tron.api.GrpcAPI.OvkDecryptParameters; -import org.tron.api.GrpcAPI.PrivateParameters; -import org.tron.api.GrpcAPI.PrivateParametersWithoutAsk; -import org.tron.api.GrpcAPI.ReceiveNote; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.Return.response_code; -import org.tron.api.GrpcAPI.SpendAuthSigParameters; -import org.tron.api.GrpcAPI.SpendNote; -import org.tron.api.GrpcAPI.SpendResult; -import org.tron.api.GrpcAPI.TransactionApprovedList; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.ECKey.ECDSASignature; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.ByteUtil; -import org.tron.core.Wallet; -import org.tron.core.zen.address.DiversifierT; -import org.tron.core.zen.address.ExpandedSpendingKey; -import org.tron.core.zen.address.FullViewingKey; -import org.tron.core.zen.address.IncomingViewingKey; -import org.tron.core.zen.address.PaymentAddress; -import org.tron.core.zen.address.SpendingKey; -import org.tron.keystore.WalletFile; -import org.tron.protos.Contract; -import org.tron.protos.Contract.CreateSmartContract; -import org.tron.protos.Contract.CreateSmartContract.Builder; -import org.tron.protos.Contract.IncrementalMerkleVoucherInfo; -import org.tron.protos.Contract.OutputPoint; -import org.tron.protos.Contract.OutputPointInfo; -import org.tron.protos.Contract.ShieldedTransferContract; -import org.tron.protos.Contract.SpendDescription; -import org.tron.protos.Contract.UpdateEnergyLimitContract; -import org.tron.protos.Contract.UpdateSettingContract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.DelegatedResourceAccountIndex; -import org.tron.protos.Protocol.Exchange; -import org.tron.protos.Protocol.Key; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import org.tron.protos.Protocol.Transaction.Result; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; - -public class PublicMethed { - - Wallet wallet = new Wallet(); - //Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - private static final String FilePath = "Wallet"; - private static List walletFile = new ArrayList<>(); - private static final Logger logger = LoggerFactory.getLogger("TestLogger"); - private static ShieldWrapper shieldWrapper = new ShieldWrapper(); - //private WalletGrpc.WalletBlockingStub blockingStubFull = null; - //private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - public static Map utxoMapNote = new ConcurrentHashMap(); - public static List spendUtxoList = new ArrayList<>(); - - /** - * constructor. - */ - - public static Boolean createAssetIssue(byte[] address, String name, Long totalSupply, - Integer trxNum, Integer icoNum, Long startTime, Long endTime, Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = Contract.AssetIssueContract - .FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Protocol.Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public static Boolean createAssetIssue(byte[] address, String name, String abbreviation, - Long totalSupply, Integer trxNum, Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long freeAssetNetLimit, - Long publicFreeAssetNetLimit, Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setAbbr(ByteString.copyFrom(abbreviation.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Protocol.Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public static Boolean createAssetIssue(byte[] address, String name, Long totalSupply, - Integer trxNum, Integer icoNum, int precision, Long startTime, Long endTime, - Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setPrecision(precision); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Protocol.Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public static Return createAssetIssue2(byte[] address, String name, Long totalSupply, - Integer trxNum, Integer icoNum, Long startTime, Long endTime, Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(ecKey, blockingStubFull); - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - //builder.setPublicFreeAssetNetUsage(); - //builder.setPublicLatestFreeNetTime(); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - TransactionExtention transactionExtention = blockingStubFull - .createAssetIssue2(builder.build()); - - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return response; - } else { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - return ret; - } catch (Exception ex) { - ex.printStackTrace(); - //return false; - return Return.getDefaultInstance(); - } - } - - /** - * constructor. - */ - - public static Account queryAccountByAddress(byte[] address, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public static Account queryAccount(byte[] address, WalletGrpc - .WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public static Account queryAccount(byte[] address, WalletSolidityGrpc - .WalletSolidityBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - - /** - * constructor. - */ - - public static Protocol.Account queryAccount(String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - /** - * constructor. - */ - - public static String loadPubKey() { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - /** - * constructor. - */ - - public static byte[] getAddress(ECKey ecKey) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public static Protocol.Account grpcQueryAccount(byte[] address, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Protocol.Account request = Protocol.Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public static Protocol.Block getBlock(long blockNum, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - GrpcAPI.NumberMessage.Builder builder = GrpcAPI.NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - /** - * constructor. - */ - - public static Protocol.Transaction signTransaction(ECKey ecKey, - Protocol.Transaction transaction) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - if (ecKey == null || ecKey.getPrivKey() == null) { - //logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - logger.info("Txid in sign is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public static Protocol.Transaction signTransactionForShield(ECKey ecKey, - Protocol.Transaction transaction) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - if (ecKey == null || ecKey.getPrivKey() == null) { - //logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - logger.info("Txid in sign is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - return TransactionUtils.sign(transaction, ecKey); - } - - - /** - * constructor. - */ - - public static boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, - byte[] from, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static Return participateAssetIssue2(byte[] to, byte[] assertName, long amount, - byte[] from, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.participateAssetIssue2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - //Protocol.Transaction transaction = blockingStubFull.participateAssetIssue(contract); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return response; - } else { - return ret; - } - } - - /** - * constructor. - */ - - public static Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Protocol.Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Protocol.Account beforeFronzen = queryAccount(priKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - /* Long afterBlockNum = 0L; - - while (afterBlockNum < beforeBlockNum) { - Protocol.Block currentBlock1 = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - } - - Protocol.Account afterFronzen = queryAccount(priKey, blockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - logger.info("beforefronen" + beforeFrozenBalance.toString() + " afterfronzen" - + afterFrozenBalance.toString()); - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance);*/ - } - - /** - * constructor. - */ - - public static Return freezeBalance2(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Protocol.Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Protocol.Account beforeFronzen = queryAccount(priKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.freezeBalance2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - if (response.getResult() == false) { - return response; - } - - Long afterBlockNum = 0L; - - while (afterBlockNum < beforeBlockNum) { - Protocol.Block currentBlock1 = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - } - - Protocol.Account afterFronzen = queryAccount(priKey, blockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - logger.info("beforefronen" + beforeFrozenBalance.toString() + " afterfronzen" - + afterFrozenBalance.toString()); - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - return ret; - } - - /** - * constructor. - */ - - public static Boolean unFreezeBalance(byte[] address, String priKey, int resourceCode, - byte[] receiverAddress, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UnfreezeBalanceContract.Builder builder = Contract.UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess).setResourceValue(resourceCode); - if (receiverAddress != null) { - ByteString receiverAddressBytes = ByteString.copyFrom(receiverAddress); - builder.setReceiverAddress(receiverAddressBytes); - } - - Contract.UnfreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - } - - /** - * constructor. - */ - - public static Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Integer times = 0; - while (times++ <= 2) { - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - continue; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - return false; - } - - /** - * constructor. - */ - - public static String sendcoinGetTransactionHex(byte[] to, long amount, byte[] owner, - String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Integer times = 0; - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return null; - - } - transaction = signTransaction(ecKey, transaction); - logger.info("HEX transaction is : " + "transaction hex string is " + ByteArray - .toHexString(transaction.toByteArray())); - return ByteArray.toHexString(transaction.toByteArray()); - } - - - /** - * constructor. - */ - - public static Boolean cancelDeferredTransactionById(String txid, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - /*Contract.CancelDeferredTransactionContract.Builder builder = Contract - .CancelDeferredTransactionContract.newBuilder(); - builder.setTransactionId(ByteString.copyFrom(ByteArray.fromHexString(txid))); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.CancelDeferredTransactionContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .createCancelDeferredTransactionContract(contract); - - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Cancel transaction before sign txid = " + ByteArray.toHexString( - transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - System.out.println( - "Cancel transaction txid = " + ByteArray.toHexString(transactionExtention - .getTxid().toByteArray())); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult();*/ - return null; - } - - /** - * constructor. - */ - - public static String cancelDeferredTransactionByIdGetTxid(String txid, byte[] owner, - String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - /* Contract.CancelDeferredTransactionContract.Builder builder = Contract - .CancelDeferredTransactionContract.newBuilder(); - builder.setTransactionId(ByteString.copyFrom(ByteArray.fromHexString(txid))); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.CancelDeferredTransactionContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .createCancelDeferredTransactionContract(contract); - - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - System.out.println( - "Cancel transaction before sign txid = " + ByteArray.toHexString( - transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - System.out.println( - "Cancel transaction txid = " + ByteArray.toHexString(transactionExtention - .getTxid().toByteArray())); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()));*/ - return null; - } - - - /** - * constructor. - */ - - public static Boolean sendcoinDelayed(byte[] to, long amount, long delaySeconds, byte[] owner, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean transferAssetDelay(byte[] to, byte[] assertName, long amount, - long delaySeconds, byte[] address, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.transferAsset(contract); - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - logger.info("transaction == null"); - } else { - logger.info("transaction.getRawData().getContractCount() == 0"); - } - return false; - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static String createAccountDelayGetTxid(byte[] ownerAddress, byte[] newAddress, - Long delaySeconds, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setAccountAddress(ByteString.copyFrom(newAddress)); - Contract.AccountCreateContract contract = builder.build(); - Transaction transaction = blockingStubFull.createAccount(contract); - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - - } - - /** - * constructor. - */ - - public static String updateAccountDelayGetTxid(byte[] addressBytes, byte[] accountNameBytes, - Long delaySeconds, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(addressBytes); - ByteString bsAccountName = ByteString.copyFrom(accountNameBytes); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - Contract.AccountUpdateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateAccount(contract); - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return null; - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - /** - * constructor. - */ - - public static String unfreezeAssetDelayGetTxid(byte[] address, Long delaySeconds, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.unfreezeAsset(contract); - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return null; - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - - - } - - - /** - * constructor. - */ - - public static String transferAssetDelayGetTxid(byte[] to, byte[] assertName, long amount, - long delaySeconds, byte[] address, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.transferAsset(contract); - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - logger.info("transaction == null"); - } else { - logger.info("transaction.getRawData().getContractCount() == 0"); - } - return null; - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - - /** - * constructor. - */ - - public static String sendcoinDelayedGetTxid(byte[] to, long amount, long delaySeconds, - byte[] owner, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return null; - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - /** - * constructor. - */ - - public static String setAccountIdDelayGetTxid(byte[] accountIdBytes, long delaySeconds, - byte[] ownerAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.SetAccountIdContract.Builder builder = Contract.SetAccountIdContract.newBuilder(); - ByteString bsAddress = ByteString.copyFrom(owner); - ByteString bsAccountId = ByteString.copyFrom(accountIdBytes); - builder.setAccountId(bsAccountId); - builder.setOwnerAddress(bsAddress); - Contract.SetAccountIdContract contract = builder.build(); - Transaction transaction = blockingStubFull.setAccountId(contract); - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - - /** - * constructor. - */ - - public static String updateAssetDelay(byte[] address, byte[] description, byte[] url, - long newLimit, long newPublicLimit, long delaySeconds, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UpdateAssetContract.Builder builder = - Contract.UpdateAssetContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(address); - builder.setDescription(ByteString.copyFrom(description)); - builder.setUrl(ByteString.copyFrom(url)); - builder.setNewLimit(newLimit); - builder.setNewPublicLimit(newPublicLimit); - builder.setOwnerAddress(basAddreess); - - Contract.UpdateAssetContract contract - = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateAsset(contract); - //transaction = TransactionUtils.setDelaySeconds(transaction, delaySeconds); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return null; - } - - transaction = signTransaction(ecKey, transaction); - logger.info("Txid is " + ByteArray.toHexString(Sha256Hash.hash(transaction - .getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - - /** - * constructor. - */ - - public static Return sendcoin2(byte[] to, long amount, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.createTransaction2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - // logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } - return ret; - } - - /** - * constructor. - */ - - public static String sendcoinGetTransactionId(byte[] to, long amount, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return null; - } - //Test raw data - /* Protocol.Transaction.raw.Builder builder1 = transaction.getRawData().toBuilder(); - builder1.setData(ByteString.copyFromUtf8("12345678")); - Transaction.Builder builder2 = transaction.toBuilder(); - builder2.setRawData(builder1); - transaction = builder2.build();*/ - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - //logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static Optional getTransactionById(String txId, - WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubFull) { - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - Transaction transaction = blockingStubFull.getTransactionById(request); - - return Optional.ofNullable(transaction); - } - - /** - * constructor. - */ - - public static Optional getTransactionById(String txId, - WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - Transaction transaction = blockingStubFull.getTransactionById(request); - return Optional.ofNullable(transaction); - } - - /** - * constructor. - */ - public static Long getAssetBalanceByAssetId(ByteString assetId, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Account assetOwnerAccount = queryAccount(priKey, blockingStubFull); - Long assetOwnerAssetBalance = 0L; - for (String id : assetOwnerAccount.getAssetV2Map().keySet()) { - if (assetId.toStringUtf8().equalsIgnoreCase(id)) { - assetOwnerAssetBalance = assetOwnerAccount.getAssetV2Map().get(id); - } - } - logger.info("asset balance is " + assetOwnerAssetBalance); - return assetOwnerAssetBalance; - } - - /** - * constructor. - */ - /* - public static Optional getDeferredTransactionById(String txId, - WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - DeferredTransaction transaction = blockingStubFull.getDeferredTransactionById(request); - if (Objects.isNull(transaction)) { - transaction = blockingStubFull.getDeferredTransactionById(request); - } - return Optional.ofNullable(transaction); - } - */ - - - /** - * constructor. - */ - - public static Optional getTransactionByIdSolidity(String txId, - WalletGrpc.WalletBlockingStub blockingStubSolidity) { - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - Transaction transaction = blockingStubSolidity.getTransactionById(request); - return Optional.ofNullable(transaction); - } - - /** - * constructor. - */ - - public static String printTransaction(Transaction transaction) { - String result = ""; - result += "hash: "; - result += "\n"; - result += ByteArray.toHexString(Sha256Hash.hash(transaction.toByteArray())); - result += "\n"; - result += "txid: "; - result += "\n"; - result += ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - result += "\n"; - - if (transaction.getRawData() != null) { - result += "raw_data: "; - result += "\n"; - result += "{"; - result += "\n"; - result += printTransactionRow(transaction.getRawData()); - result += "}"; - result += "\n"; - } - - return result; - } - - /** - * constructor. - */ - - public static long printTransactionRow(Transaction.raw raw) { - long timestamp = raw.getTimestamp(); - - return timestamp; - } - - /** - * constructor. - */ - - public static boolean updateAsset(byte[] address, byte[] description, byte[] url, long newLimit, - long newPublicLimit, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UpdateAssetContract.Builder builder = - Contract.UpdateAssetContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(address); - builder.setDescription(ByteString.copyFrom(description)); - builder.setUrl(ByteString.copyFrom(url)); - builder.setNewLimit(newLimit); - builder.setNewPublicLimit(newPublicLimit); - builder.setOwnerAddress(basAddreess); - - Contract.UpdateAssetContract contract - = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static Return updateAsset2(byte[] address, byte[] description, byte[] url, long newLimit, - long newPublicLimit, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UpdateAssetContract.Builder builder = - Contract.UpdateAssetContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(address); - builder.setDescription(ByteString.copyFrom(description)); - builder.setUrl(ByteString.copyFrom(url)); - builder.setNewLimit(newLimit); - builder.setNewPublicLimit(newPublicLimit); - builder.setOwnerAddress(basAddreess); - - Contract.UpdateAssetContract contract - = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.updateAsset2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - //logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } - return ret; - } - - /** - * constructor. - */ - - public static boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.transferAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - logger.info("transaction == null"); - } else { - logger.info("transaction.getRawData().getContractCount() == 0"); - } - return false; - } - transaction = signTransaction(ecKey, transaction); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - - /** - * constructor. - */ - - public static boolean updateAccount(byte[] addressBytes, byte[] accountNameBytes, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(addressBytes); - ByteString bsAccountName = ByteString.copyFrom(accountNameBytes); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - Contract.AccountUpdateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateAccount(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean waitSolidityNodeSynFullNodeData(WalletGrpc.WalletBlockingStub - blockingStubFull, WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Block solidityCurrentBlock = blockingStubSolidity.getNowBlock(GrpcAPI.EmptyMessage - .newBuilder().build()); - Integer wait = 0; - logger.info("Fullnode block num is " + Long.toString(currentBlock - .getBlockHeader().getRawData().getNumber())); - while (solidityCurrentBlock.getBlockHeader().getRawData().getNumber() - < currentBlock.getBlockHeader().getRawData().getNumber() + 1 && wait <= 10) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("Soliditynode num is " + Long.toString(solidityCurrentBlock - .getBlockHeader().getRawData().getNumber())); - solidityCurrentBlock = blockingStubSolidity.getNowBlock(GrpcAPI.EmptyMessage.newBuilder() - .build()); - if (wait == 10) { - logger.info("Didn't syn,skip to next case."); - return false; - } - wait++; - } - return true; - } - - /** - * constructor. - */ - - public static boolean waitProduceNextBlock(WalletGrpc.WalletBlockingStub - blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - final Long currentNum = currentBlock.getBlockHeader().getRawData().getNumber(); - - Block nextBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long nextNum = nextBlock.getBlockHeader().getRawData().getNumber(); - - Integer wait = 0; - logger.info("Block num is " + Long.toString(currentBlock - .getBlockHeader().getRawData().getNumber())); - while (nextNum <= currentNum + 1 && wait <= 45) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("Wait to produce next block"); - nextBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - nextNum = nextBlock.getBlockHeader().getRawData().getNumber(); - if (wait == 45) { - logger.info("These 45 second didn't produce a block,please check."); - return false; - } - wait++; - } - logger.info("quit normally"); - return true; - } - - /** - * constructor. - */ - - public static AccountNetMessage getAccountNet(byte[] address, WalletGrpc.WalletBlockingStub - blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccountNet(request); - } - - /* public static byte[] addPreFix(byte[] address) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - Config config = Configuration.getByPath("testng.conf"); - byte ADD_PRE_FIX_BYTE_MAINNET = (byte) 0x41; //41 + address - byte ADD_PRE_FIX_BYTE_TESTNET = (byte) 0xa0; //a0 + address - byte[] preFix = new byte[1]; - if (config.hasPath("net.type") && "mainnet".equalsIgnoreCase(config.getString("net.type"))) { - WalletClient.setAddressPreFixByte(ADD_PRE_FIX_BYTE_MAINNET); - preFix[0] = ADD_PRE_FIX_BYTE_MAINNET; - }else { - WalletClient.setAddressPreFixByte(ADD_PRE_FIX_BYTE_TESTNET); - preFix[0] = ADD_PRE_FIX_BYTE_TESTNET; - } - byte[] finalAddress = new byte[preFix.length+address.length]; - System.arraycopy(preFix, 0, finalAddress, 0, preFix.length); - System.arraycopy(address, 0, finalAddress, preFix.length, address.length); - return finalAddress; - - }*/ - - /** - * constructor. - */ - - public static byte[] getFinalAddress(String priKey) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - WalletClient walletClient; - walletClient = new WalletClient(priKey); - //walletClient.init(0); - return walletClient.getAddress(); - } - - /** - * constructor. - */ - - public static boolean createAccount(byte[] ownerAddress, byte[] newAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setAccountAddress(ByteString.copyFrom(newAddress)); - Contract.AccountCreateContract contract = builder.build(); - Transaction transaction = blockingStubFull.createAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static Return createAccount2(byte[] ownerAddress, byte[] newAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setAccountAddress(ByteString.copyFrom(newAddress)); - Contract.AccountCreateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.createAccount2(contract); - - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - //logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } - return ret; - } - - /** - * constructor. - */ - - public static boolean createProposal(byte[] ownerAddress, String priKey, - HashMap parametersMap, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalCreateContract.Builder builder = Contract.ProposalCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.putAllParameters(parametersMap); - - Contract.ProposalCreateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalCreate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean approveProposal(byte[] ownerAddress, String priKey, long id, - boolean isAddApproval, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalApproveContract.Builder builder = Contract.ProposalApproveContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setProposalId(id); - builder.setIsAddApproval(isAddApproval); - Contract.ProposalApproveContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalApprove(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean deleteProposal(byte[] ownerAddress, String priKey, long id, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalDeleteContract.Builder builder = Contract.ProposalDeleteContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setProposalId(id); - - Contract.ProposalDeleteContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalDelete(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean printAddress(String key) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - logger.info(key); - logger.info(ByteArray.toHexString(getFinalAddress(key))); - logger.info(Base58.encode58Check(getFinalAddress(key))); - return true; - } - - /** - * constructor. - */ - - public static String getAddressString(String key) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - return Base58.encode58Check(getFinalAddress(key)); - } - - /** - * constructor. - */ - - - public static ArrayList getAddressInfo(String key) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ArrayList accountList = new ArrayList(); - accountList.add(key); - accountList.add(ByteArray.toHexString(getFinalAddress(key))); - accountList.add(Base58.encode58Check(getFinalAddress(key))); - return accountList; - } - - /** - * constructor. - */ - - public static boolean setAccountId(byte[] accountIdBytes, byte[] ownerAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.SetAccountIdContract.Builder builder = Contract.SetAccountIdContract.newBuilder(); - ByteString bsAddress = ByteString.copyFrom(owner); - ByteString bsAccountId = ByteString.copyFrom(accountIdBytes); - builder.setAccountId(bsAccountId); - builder.setOwnerAddress(bsAddress); - Contract.SetAccountIdContract contract = builder.build(); - Transaction transaction = blockingStubFull.setAccountId(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static Boolean freezeBalanceGetEnergy(byte[] addRess, long freezeBalance, - long freezeDuration, - int resourceCode, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration).setResourceValue(resourceCode); - - Contract.FreezeBalanceContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - public static AccountResourceMessage getAccountResource(byte[] address, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccountResource(request); - } - - /** - * constructor. - */ - - public static boolean buyStorage(long quantity, byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.BuyStorageContract.Builder builder = Contract.BuyStorageContract.newBuilder(); - ByteString byteAddress = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddress).setQuant(quantity); - Contract.BuyStorageContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.buyStorage(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean sellStorage(long quantity, byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.SellStorageContract.Builder builder = Contract.SellStorageContract.newBuilder(); - ByteString byteAddress = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddress).setStorageBytes(quantity); - Contract.SellStorageContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.sellStorage(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - public static byte[] deployContract(String contractName, String abiString, String code, - String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - byte[] contractAddress = generateContractAddress(transactionExtention.getTransaction(), owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - contractAddress = generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - //logger.info("brodacast succesfully"); - return contractAddress; - } - } - - /** - * constructor. - */ - public static byte[] deployContract(String contractName, String abiString, String code, - String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - return deployContract(contractName, abiString, code, data, feeLimit, value, - consumeUserResourcePercent, 1000L, "0", 0L, libraryAddress, - priKey, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - - public static byte[] deployContractForLibrary(String contractName, String abiString, String code, - String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - String compilerVersion, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(1000L); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - if (compilerVersion.equals("v5") || compilerVersion.equals("V5")) { - byteCode = replaceLibraryAddresscompilerVersion(code, libraryAddress, "v5"); - } else { - //old version - byteCode = replaceLibraryAddresscompilerVersion(code, libraryAddress, null); - } - - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(0); - contractBuilder.setTokenId(Long.parseLong("0")); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - byte[] contractAddress = generateContractAddress(transactionExtention.getTransaction(), owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - contractAddress = generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - //logger.info("brodacast succesfully"); - return contractAddress; - } - - } - - /** - * constructor. - */ - - public static String deployContractAndGetTransactionInfoById(String contractName, - String abiString, String code, String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - return deployContractAndGetTransactionInfoById(contractName, abiString, code, data, feeLimit, - value, consumeUserResourcePercent, 1000L, "0", 0L, libraryAddress, - priKey, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - - public static String deployContractAndGetTransactionInfoById(String contractName, - String abiString, String code, String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - byte[] contractAddress = generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - //logger.info("brodacast succesfully"); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static SmartContract.ABI jsonStr2Abi(String jsonStr) { - if (jsonStr == null) { - return null; - } - - JsonParser jsonParser = new JsonParser(); - JsonElement jsonElementRoot = jsonParser.parse(jsonStr); - JsonArray jsonRoot = jsonElementRoot.getAsJsonArray(); - SmartContract.ABI.Builder abiBuilder = SmartContract.ABI.newBuilder(); - for (int index = 0; index < jsonRoot.size(); index++) { - JsonElement abiItem = jsonRoot.get(index); - boolean anonymous = abiItem.getAsJsonObject().get("anonymous") != null - ? abiItem.getAsJsonObject().get("anonymous").getAsBoolean() : false; - final boolean constant = abiItem.getAsJsonObject().get("constant") != null - ? abiItem.getAsJsonObject().get("constant").getAsBoolean() : false; - final String name = abiItem.getAsJsonObject().get("name") != null - ? abiItem.getAsJsonObject().get("name").getAsString() : null; - JsonArray inputs = abiItem.getAsJsonObject().get("inputs") != null - ? abiItem.getAsJsonObject().get("inputs").getAsJsonArray() : null; - final JsonArray outputs = abiItem.getAsJsonObject().get("outputs") != null - ? abiItem.getAsJsonObject().get("outputs").getAsJsonArray() : null; - String type = abiItem.getAsJsonObject().get("type") != null - ? abiItem.getAsJsonObject().get("type").getAsString() : null; - final boolean payable = abiItem.getAsJsonObject().get("payable") != null - ? abiItem.getAsJsonObject().get("payable").getAsBoolean() : false; - final String stateMutability = abiItem.getAsJsonObject().get("stateMutability") != null - ? abiItem.getAsJsonObject().get("stateMutability").getAsString() : null; - if (type == null) { - logger.error("No type!"); - return null; - } - if (!type.equalsIgnoreCase("fallback") && null == inputs) { - logger.error("No inputs!"); - return null; - } - - SmartContract.ABI.Entry.Builder entryBuilder = SmartContract.ABI.Entry.newBuilder(); - entryBuilder.setAnonymous(anonymous); - entryBuilder.setConstant(constant); - if (name != null) { - entryBuilder.setName(name); - } - - /* { inputs : optional } since fallback function not requires inputs*/ - if (inputs != null) { - for (int j = 0; j < inputs.size(); j++) { - JsonElement inputItem = inputs.get(j); - if (inputItem.getAsJsonObject().get("name") == null - || inputItem.getAsJsonObject().get("type") == null) { - logger.error("Input argument invalid due to no name or no type!"); - return null; - } - String inputName = inputItem.getAsJsonObject().get("name").getAsString(); - String inputType = inputItem.getAsJsonObject().get("type").getAsString(); - SmartContract.ABI.Entry.Param.Builder paramBuilder = SmartContract.ABI.Entry.Param - .newBuilder(); - JsonElement indexed = inputItem.getAsJsonObject().get("indexed"); - - paramBuilder.setIndexed((indexed == null) ? false : indexed.getAsBoolean()); - paramBuilder.setName(inputName); - paramBuilder.setType(inputType); - entryBuilder.addInputs(paramBuilder.build()); - } - } - - /* { outputs : optional } */ - if (outputs != null) { - for (int k = 0; k < outputs.size(); k++) { - JsonElement outputItem = outputs.get(k); - if (outputItem.getAsJsonObject().get("name") == null - || outputItem.getAsJsonObject().get("type") == null) { - logger.error("Output argument invalid due to no name or no type!"); - return null; - } - String outputName = outputItem.getAsJsonObject().get("name").getAsString(); - String outputType = outputItem.getAsJsonObject().get("type").getAsString(); - SmartContract.ABI.Entry.Param.Builder paramBuilder = SmartContract.ABI.Entry.Param - .newBuilder(); - JsonElement indexed = outputItem.getAsJsonObject().get("indexed"); - - paramBuilder.setIndexed((indexed == null) ? false : indexed.getAsBoolean()); - paramBuilder.setName(outputName); - paramBuilder.setType(outputType); - entryBuilder.addOutputs(paramBuilder.build()); - } - } - - entryBuilder.setType(getEntryType(type)); - entryBuilder.setPayable(payable); - if (stateMutability != null) { - entryBuilder.setStateMutability(getStateMutability(stateMutability)); - } - - abiBuilder.addEntrys(entryBuilder.build()); - } - - return abiBuilder.build(); - } - - /** - * constructor. - */ - - public static SmartContract.ABI.Entry.EntryType getEntryType(String type) { - switch (type) { - case "constructor": - return SmartContract.ABI.Entry.EntryType.Constructor; - case "function": - return SmartContract.ABI.Entry.EntryType.Function; - case "event": - return SmartContract.ABI.Entry.EntryType.Event; - case "fallback": - return SmartContract.ABI.Entry.EntryType.Fallback; - default: - return SmartContract.ABI.Entry.EntryType.UNRECOGNIZED; - } - } - - /** - * constructor. - */ - - public static SmartContract.ABI.Entry.StateMutabilityType getStateMutability( - String stateMutability) { - switch (stateMutability) { - case "pure": - return SmartContract.ABI.Entry.StateMutabilityType.Pure; - case "view": - return SmartContract.ABI.Entry.StateMutabilityType.View; - case "nonpayable": - return SmartContract.ABI.Entry.StateMutabilityType.Nonpayable; - case "payable": - return SmartContract.ABI.Entry.StateMutabilityType.Payable; - default: - return SmartContract.ABI.Entry.StateMutabilityType.UNRECOGNIZED; - } - } - - /** - * constructor. - */ - - public static byte[] generateContractAddress(Transaction trx, byte[] owneraddress) { - - // get owner address - // this address should be as same as the onweraddress in trx, DONNOT modify it - byte[] ownerAddress = owneraddress; - - // get tx hash - byte[] txRawDataHash = Sha256Hash.of(trx.getRawData().toByteArray()).getBytes(); - - // combine - byte[] combined = new byte[txRawDataHash.length + ownerAddress.length]; - System.arraycopy(txRawDataHash, 0, combined, 0, txRawDataHash.length); - System.arraycopy(ownerAddress, 0, combined, txRawDataHash.length, ownerAddress.length); - - return Hash.sha3omit12(combined); - - } - - /** - * constructor. - */ - - public static SmartContract getContract(byte[] address, WalletGrpc - .WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString byteString = ByteString.copyFrom(address); - BytesMessage bytesMessage = BytesMessage.newBuilder().setValue(byteString).build(); - Integer i = 0; - while (blockingStubFull.getContract(bytesMessage).getName().isEmpty() && i++ < 4) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - logger.info("contract name is " + blockingStubFull.getContract(bytesMessage).getName()); - logger.info("contract address is " + WalletClient.encode58Check(address)); - return blockingStubFull.getContract(bytesMessage); - } - - private static byte[] replaceLibraryAddress(String code, String libraryAddressPair) { - - String[] libraryAddressList = libraryAddressPair.split("[,]"); - - for (int i = 0; i < libraryAddressList.length; i++) { - String cur = libraryAddressList[i]; - - int lastPosition = cur.lastIndexOf(":"); - if (-1 == lastPosition) { - throw new RuntimeException("libraryAddress delimit by ':'"); - } - String libraryName = cur.substring(0, lastPosition); - String addr = cur.substring(lastPosition + 1); - String libraryAddressHex = ByteArray.toHexString(Wallet.decodeFromBase58Check(addr)) - .substring(2); - - String repeated = new String(new char[40 - libraryName.length() - 2]).replace("\0", "_"); - String beReplaced = "__" + libraryName + repeated; - Matcher m = Pattern.compile(beReplaced).matcher(code); - code = m.replaceAll(libraryAddressHex); - } - - return Hex.decode(code); - } - - private static byte[] replaceLibraryAddress_1(String code, byte[] libraryAddress) { - - String libraryAddressHex = ByteArray.toHexString(libraryAddress).substring(2); - - Matcher m = Pattern.compile("__.*__").matcher(code); - code = m.replaceAll(libraryAddressHex); - return Hex.decode(code); - } - - private static byte[] replaceLibraryAddresscompilerVersion(String code, String libraryAddressPair, - String compilerVersion) { - - String[] libraryAddressList = libraryAddressPair.split("[,]"); - - for (int i = 0; i < libraryAddressList.length; i++) { - String cur = libraryAddressList[i]; - - int lastPosition = cur.lastIndexOf(":"); - if (-1 == lastPosition) { - throw new RuntimeException("libraryAddress delimit by ':'"); - } - String libraryName = cur.substring(0, lastPosition); - String addr = cur.substring(lastPosition + 1); - String libraryAddressHex; - try { - libraryAddressHex = (new String(Hex.encode(Wallet.decodeFromBase58Check(addr)), - "US-ASCII")).substring(2); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); // now ignore - } - - String beReplaced; - if (compilerVersion == null) { - //old version - String repeated = new String(new char[40 - libraryName.length() - 2]).replace("\0", "_"); - beReplaced = "__" + libraryName + repeated; - } else if (compilerVersion.equalsIgnoreCase("v5")) { - //0.5.4 version - String libraryNameKeccak256 = ByteArray - .toHexString(Hash.sha3(ByteArray.fromString(libraryName))).substring(0, 34); - beReplaced = "__\\$" + libraryNameKeccak256 + "\\$__"; - } else { - throw new RuntimeException("unknown compiler version."); - } - - Matcher m = Pattern.compile(beReplaced).matcher(code); - code = m.replaceAll(libraryAddressHex); - } - - return Hex.decode(code); - } - - /** - * constructor. - */ - - public static boolean updateSetting(byte[] contractAddress, long consumeUserResourcePercent, - String priKey, byte[] ownerAddress, WalletGrpc - .WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.UpdateSettingContract.Builder builder = Contract.UpdateSettingContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - - UpdateSettingContract updateSettingContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateSetting(updateSettingContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return false; - } - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean updateSettingDelay(byte[] contractAddress, - long consumeUserResourcePercent, long delaySeconds, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.UpdateSettingContract.Builder builder = Contract.UpdateSettingContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - - UpdateSettingContract updateSettingContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateSetting(updateSettingContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return false; - } - /* transactionExtention = TransactionUtils.setDelaySecondsToExtension( - transactionExtention, delaySeconds); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult();*/ - return false; - } - - /** - * constructor. - */ - - public static String updateSettingDelayGetTxid(byte[] contractAddress, - long consumeUserResourcePercent, long delaySeconds, - String priKey, byte[] ownerAddress, WalletGrpc - .WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.UpdateSettingContract.Builder builder = Contract.UpdateSettingContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - - UpdateSettingContract updateSettingContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateSetting(updateSettingContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - /* transactionExtention = TransactionUtils.setDelaySecondsToExtension( - transactionExtention, delaySeconds); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()));*/ - return null; - } - - /** - * constructor. - */ - public static String updateEnergyLimitDelayGetTxid(byte[] contractAddress, - long originEnergyLimit, long delaySeconds, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.UpdateEnergyLimitContract.Builder builder = Contract.UpdateEnergyLimitContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setOriginEnergyLimit(originEnergyLimit); - - UpdateEnergyLimitContract updateEnergyLimitContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateEnergyLimit(updateEnergyLimitContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - //transactionExtention = TransactionUtils.setDelaySecondsToExtension( - // transactionExtention, delaySeconds); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - - /** - * 61 constructor. - */ - - public static Optional getTransactionInfoById(String txId, WalletGrpc - .WalletBlockingStub blockingStubFull) { - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - TransactionInfo transactionInfo; - transactionInfo = blockingStubFull.getTransactionInfoById(request); - return Optional.ofNullable(transactionInfo); - } - - public static String triggerContract(byte[] contractAddress, String method, String argsStr, - Boolean isHex, long callValue, long feeLimit, byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - return triggerContract(contractAddress, method, argsStr, isHex, callValue, feeLimit, - "0", 0, ownerAddress, priKey, blockingStubFull); - } - - /** - * constructor. - */ - - public static String triggerContract(byte[] contractAddress, String method, String argsStr, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.triggerContract(triggerContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static String triggerParamListContract(byte[] contractAddress, String method, - List params, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, params)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.triggerContract(triggerContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - - } - - /** - * constructor. - */ - - public static Boolean exchangeCreate(byte[] firstTokenId, long firstTokenBalance, - byte[] secondTokenId, long secondTokenBalance, byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ExchangeCreateContract.Builder builder = Contract.ExchangeCreateContract.newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setFirstTokenId(ByteString.copyFrom(firstTokenId)) - .setFirstTokenBalance(firstTokenBalance) - .setSecondTokenId(ByteString.copyFrom(secondTokenId)) - .setSecondTokenBalance(secondTokenBalance); - Contract.ExchangeCreateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeCreate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - } - - /** - * constructor. - */ - - public static Boolean injectExchange(long exchangeId, byte[] tokenId, long quant, - byte[] ownerAddress, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ExchangeInjectContract.Builder builder = Contract.ExchangeInjectContract.newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant); - Contract.ExchangeInjectContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeInject(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response.getResult(); - } - - public static Optional getExchangeList(WalletGrpc.WalletBlockingStub - blockingStubFull) { - ExchangeList exchangeList = blockingStubFull.listExchanges(EmptyMessage.newBuilder().build()); - return Optional.ofNullable(exchangeList); - } - - /** - * constructor. - */ - - public static Optional getExchangeList(WalletSolidityGrpc - .WalletSolidityBlockingStub blockingStubSolidity) { - ExchangeList exchangeList = blockingStubSolidity.listExchanges(EmptyMessage.newBuilder() - .build()); - return Optional.ofNullable(exchangeList); - } - - - /** - * constructor. - */ - - public static Optional getExchange(String id, WalletSolidityGrpc - .WalletSolidityBlockingStub blockingStubSolidity) { - BytesMessage request = BytesMessage.newBuilder().setValue(ByteString.copyFrom( - ByteArray.fromLong(Long.parseLong(id)))) - .build(); - Exchange exchange = blockingStubSolidity.getExchangeById(request); - return Optional.ofNullable(exchange); - } - - /** - * constructor. - */ - - public static Optional getExchange(String id, WalletGrpc.WalletBlockingStub - blockingStubFull) { - BytesMessage request = BytesMessage.newBuilder().setValue(ByteString.copyFrom( - ByteArray.fromLong(Long.parseLong(id)))) - .build(); - Exchange exchange = blockingStubFull.getExchangeById(request); - return Optional.ofNullable(exchange); - } - - /** - * constructor. - */ - - public static boolean exchangeWithdraw(long exchangeId, byte[] tokenId, long quant, - byte[] ownerAddress, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - byte[] owner = ownerAddress; - - Contract.ExchangeWithdrawContract.Builder builder = Contract.ExchangeWithdrawContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant); - Contract.ExchangeWithdrawContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeWithdraw(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static boolean exchangeTransaction(long exchangeId, byte[] tokenId, long quant, - long expected, byte[] ownerAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - byte[] owner = ownerAddress; - - Contract.ExchangeTransactionContract.Builder builder = Contract.ExchangeTransactionContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant) - .setExpected(expected); - Contract.ExchangeTransactionContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeTransaction(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static String deployContractWithConstantParame(String contractName, String abiString, - String code, String constructorStr, String argsStr, String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - return deployContractWithConstantParame(contractName, abiString, code, constructorStr, argsStr, - data, feeLimit, value, consumeUserResourcePercent, 1000L, "0", 0L, - libraryAddress, priKey, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - - public static String deployContractWithConstantParame(String contractName, String abiString, - String code, String constructorStr, String argsStr, String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - - code += Hex.toHexString(AbiUtil.encodeInput(constructorStr, argsStr)); - byte[] owner = ownerAddress; - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder.setNewContract(builder.build()) - .build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - byte[] contractAddress = generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - //logger.info("brodacast succesfully"); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static Boolean freezeBalanceForReceiver(byte[] addRess, long freezeBalance, - long freezeDuration, int resourceCode, ByteString receiverAddressBytes, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration).setResourceValue(resourceCode); - builder.setReceiverAddress(receiverAddressBytes); - Contract.FreezeBalanceContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static Optional getDelegatedResource(byte[] fromAddress, - byte[] toAddress, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString fromAddressBs = ByteString.copyFrom(fromAddress); - ByteString toAddressBs = ByteString.copyFrom(toAddress); - - DelegatedResourceMessage request = DelegatedResourceMessage.newBuilder() - .setFromAddress(fromAddressBs) - .setToAddress(toAddressBs) - .build(); - DelegatedResourceList delegatedResource = blockingStubFull.getDelegatedResource(request); - return Optional.ofNullable(delegatedResource); - } - - /** - * constructor. - */ - - public static Optional getDelegatedResourceAccountIndex( - byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - - ByteString addressBs = ByteString.copyFrom(address); - - BytesMessage bytesMessage = BytesMessage.newBuilder().setValue(addressBs).build(); - - DelegatedResourceAccountIndex accountIndex = blockingStubFull - .getDelegatedResourceAccountIndex(bytesMessage); - return Optional.ofNullable(accountIndex); - } - - /** - * constructor. - */ - - public static Contract.AssetIssueContract getAssetIssueByName(String assetName, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString assetNameBs = ByteString.copyFrom(assetName.getBytes()); - BytesMessage request = BytesMessage.newBuilder().setValue(assetNameBs).build(); - return blockingStubFull.getAssetIssueByName(request); - } - - /** - * constructor. - */ - - public static Optional getAssetIssueListByName(String assetName, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString assetNameBs = ByteString.copyFrom(assetName.getBytes()); - BytesMessage request = BytesMessage.newBuilder().setValue(assetNameBs).build(); - AssetIssueList assetIssueList = blockingStubFull.getAssetIssueListByName(request); - return Optional.ofNullable(assetIssueList); - } - - /** - * constructor. - */ - - public static Contract.AssetIssueContract getAssetIssueById(String assetId, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString assetIdBs = ByteString.copyFrom(assetId.getBytes()); - BytesMessage request = BytesMessage.newBuilder().setValue(assetIdBs).build(); - return blockingStubFull.getAssetIssueById(request); - } - - private static Permission json2Permission(JSONObject json) { - Permission.Builder permissionBuilder = Permission.newBuilder(); - if (json.containsKey("type")) { - int type = json.getInteger("type"); - permissionBuilder.setTypeValue(type); - } - if (json.containsKey("permission_name")) { - String permissionName = json.getString("permission_name"); - permissionBuilder.setPermissionName(permissionName); - } - if (json.containsKey("threshold")) { - //long threshold = json.getLong("threshold"); - long threshold = Long.parseLong(json.getString("threshold")); - permissionBuilder.setThreshold(threshold); - } - if (json.containsKey("parent_id")) { - int parentId = json.getInteger("parent_id"); - permissionBuilder.setParentId(parentId); - } - if (json.containsKey("operations")) { - byte[] operations = ByteArray.fromHexString(json.getString("operations")); - permissionBuilder.setOperations(ByteString.copyFrom(operations)); - } - if (json.containsKey("keys")) { - JSONArray keys = json.getJSONArray("keys"); - List keyList = new ArrayList<>(); - for (int i = 0; i < keys.size(); i++) { - Key.Builder keyBuilder = Key.newBuilder(); - JSONObject key = keys.getJSONObject(i); - String address = key.getString("address"); - long weight = Long.parseLong(key.getString("weight")); - //long weight = key.getLong("weight"); - //keyBuilder.setAddress(ByteString.copyFrom(address.getBytes())); - keyBuilder.setAddress(ByteString.copyFrom(WalletClient.decodeFromBase58Check(address))); - keyBuilder.setWeight(weight); - keyList.add(keyBuilder.build()); - } - permissionBuilder.addAllKeys(keyList); - } - return permissionBuilder.build(); - } - - /** - * constructor. - */ - public static boolean accountPermissionUpdate(String permissionJson, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] priKeys) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownerpermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesspermission = permissions.getJSONObject("witness_permission"); - JSONArray activepermissions = permissions.getJSONArray("active_permissions"); - - if (ownerpermission != null) { - Permission ownerPermission = json2Permission(ownerpermission); - builder.setOwner(ownerPermission); - } - if (witnesspermission != null) { - Permission witnessPermission = json2Permission(witnesspermission); - builder.setWitness(witnessPermission); - } - if (activepermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activepermissions.size(); j++) { - JSONObject permission = activepermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.accountPermissionUpdate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - - /** - * constructor. - */ - public static long getFreezeBalanceCount(byte[] accountAddress, String ecKey, Long targetEnergy, - WalletGrpc.WalletBlockingStub blockingStubFull) { - //Precision change as the entire network freezes - AccountResourceMessage resourceInfo = getAccountResource(accountAddress, - blockingStubFull); - - Account info = queryAccount(accountAddress, blockingStubFull); - - Account getAccount = queryAccount(ecKey, blockingStubFull); - - long balance = info.getBalance(); - long frozenBalance = info.getAccountResource().getFrozenBalanceForEnergy().getFrozenBalance(); - long totalEnergyLimit = resourceInfo.getTotalEnergyLimit(); - long totalEnergyWeight = resourceInfo.getTotalEnergyWeight(); - long energyUsed = resourceInfo.getEnergyUsed(); - long energyLimit = resourceInfo.getEnergyLimit(); - - if (energyUsed > energyLimit) { - targetEnergy = energyUsed - energyLimit + targetEnergy; - } - - if (totalEnergyWeight == 0) { - return 1000_000L; - } - - // totalEnergyLimit / (totalEnergyWeight + needBalance) = needEnergy / needBalance - final BigInteger totalEnergyWeightBi = BigInteger.valueOf(totalEnergyWeight); - long needBalance = totalEnergyWeightBi.multiply(BigInteger.valueOf(1_000_000)) - .multiply(BigInteger.valueOf(targetEnergy)) - .divide(BigInteger.valueOf(totalEnergyLimit - targetEnergy)).longValue(); - - logger.info("getFreezeBalanceCount, needBalance: " + needBalance); - - if (needBalance < 1000000L) { - needBalance = 1000000L; - logger.info( - "getFreezeBalanceCount, needBalance less than 1 TRX, modify to: " + needBalance); - } - return needBalance; - } - - /** - * constructor. - */ - public static Long getAssetIssueValue(byte[] accountAddress, ByteString assetIssueId, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Long assetIssueCount = 0L; - Account contractAccount = queryAccount(accountAddress, blockingStubFull); - Map createAssetIssueMap = contractAccount.getAssetV2Map(); - for (Map.Entry entry : createAssetIssueMap.entrySet()) { - if (assetIssueId.toStringUtf8().equals(entry.getKey())) { - assetIssueCount = entry.getValue(); - } - } - return assetIssueCount; - } - - /** - * constructor. - */ - public static List getStrings(byte[] data) { - int index = 0; - List ret = new ArrayList<>(); - while (index < data.length) { - ret.add(byte2HexStr(data, index, 32)); - index += 32; - } - return ret; - } - - /** - * constructor. - */ - public static String byte2HexStr(byte[] b, int offset, int length) { - StringBuilder ssBuilder = new StringBuilder(); - for (int n = offset; n < offset + length && n < b.length; n++) { - String stmp = Integer.toHexString(b[n] & 0xFF); - ssBuilder.append((stmp.length() == 1) ? "0" + stmp : stmp); - } - return ssBuilder.toString().toUpperCase().trim(); - } - - - /** - * constructor. - */ - public static Transaction addTransactionSign(Transaction transaction, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Transaction.Builder transactionBuilderSigned = transaction.toBuilder(); - byte[] hash = Sha256Hash.hash(transaction.getRawData().toByteArray()); - - ECDSASignature signature = ecKey.sign(hash); - ByteString bsSign = ByteString.copyFrom(signature.toByteArray()); - transactionBuilderSigned.addSignature(bsSign); - transaction = transactionBuilderSigned.build(); - return transaction; - } - - /** - * constructor. - */ - public static GrpcAPI.Return deployContractAndGetResponse(String contractName, - String abiString, String code, String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - byte[] contractAddress = generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response; - } - - /** - * constructor. - */ - public static GrpcAPI.Return triggerContractAndGetResponse(byte[] contractAddress, String method, - String argsStr, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.triggerContract(triggerContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response; - } - - /** - * constructor. - */ - public static boolean updateEnergyLimit(byte[] contractAddress, long originEnergyLimit, - String priKey, byte[] ownerAddress, WalletGrpc - .WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.UpdateEnergyLimitContract.Builder builder = Contract.UpdateEnergyLimitContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setOriginEnergyLimit(originEnergyLimit); - - UpdateEnergyLimitContract updateEnergyLimitContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateEnergyLimit(updateEnergyLimitContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return false; - } - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - public static GrpcAPI.Return accountPermissionUpdateForResponse(String permissionJson, - byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownerpermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesspermission = permissions.getJSONObject("witness_permission"); - JSONArray activepermissions = permissions.getJSONArray("active_permissions"); - - if (ownerpermission != null) { - Permission ownerPermission = json2Permission(ownerpermission); - builder.setOwner(ownerPermission); - } - if (witnesspermission != null) { - Permission witnessPermission = json2Permission(witnesspermission); - builder.setWitness(witnessPermission); - } - if (activepermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activepermissions.size(); j++) { - JSONObject permission = activepermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.accountPermissionUpdate(contract); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return ret; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - - return response; - } - - public static TransactionApprovedList getTransactionApprovedList(Transaction transaction, - WalletGrpc - .WalletBlockingStub blockingStubFull) { - return blockingStubFull.getTransactionApprovedList(transaction); - } - - /** - * constructor. - */ - public static long getFreezeBalanceNetCount(byte[] accountAddress, String ecKey, Long targetNet, - WalletGrpc.WalletBlockingStub blockingStubFull) { - //Precision change as the entire network freezes - AccountResourceMessage resourceInfo = getAccountResource(accountAddress, - blockingStubFull); - - Account info = queryAccount(accountAddress, blockingStubFull); - - Account getAccount = queryAccount(ecKey, blockingStubFull); - - long balance = info.getBalance(); - long totalNetLimit = resourceInfo.getTotalNetLimit(); - long totalNetWeight = resourceInfo.getTotalNetWeight(); - long netUsed = resourceInfo.getNetUsed(); - long netLimit = resourceInfo.getNetLimit(); - - if (netUsed > netLimit) { - targetNet = netUsed - netLimit + targetNet; - } - - if (totalNetWeight == 0) { - return 1000_000L; - } - - // totalNetLimit / (totalNetWeight + needBalance) = needNet / needBalance - final BigInteger totalNetWeightBi = BigInteger.valueOf(totalNetWeight); - long needBalance = totalNetWeightBi.multiply(BigInteger.valueOf(1_000_000)) - .multiply(BigInteger.valueOf(targetNet)) - .divide(BigInteger.valueOf(totalNetLimit - targetNet)).longValue(); - - logger.info("getFreezeBalanceNetCount, needBalance: " + needBalance); - - if (needBalance < 1000000L) { - needBalance = 1000000L; - logger.info( - "getFreezeBalanceNetCount, needBalance less than 1 TRX, modify to: " + needBalance); - } - return needBalance; - } - - /** - * constructor. - */ - public static GrpcAPI.Return broadcastTransaction(Transaction transaction, - WalletGrpc.WalletBlockingStub blockingStubFull) { - int i = 10; - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY - && i > 0) { - try { - Thread.sleep(300); - } catch (InterruptedException e) { - e.printStackTrace(); - } - i--; - response = blockingStubFull.broadcastTransaction(transaction); - logger.info("repeate times = " + (10 - i)); - } - - if (response.getResult() == false) { - logger.info("Code = " + response.getCode()); - logger.info("Message = " + response.getMessage().toStringUtf8()); - } - return response; - } - - /** - * constructor. - */ - public static String exec(String command) throws InterruptedException { - String returnString = ""; - Process pro = null; - Runtime runTime = Runtime.getRuntime(); - if (runTime == null) { - logger.error("Create runtime false!"); - } - try { - pro = runTime.exec(command); - BufferedReader input = new BufferedReader(new InputStreamReader(pro.getInputStream())); - PrintWriter output = new PrintWriter(new OutputStreamWriter(pro.getOutputStream())); - String line; - while ((line = input.readLine()) != null) { - returnString = returnString + line + "\n"; - } - input.close(); - output.close(); - pro.destroy(); - } catch (IOException ex) { - logger.error(null, ex); - } - return returnString; - } - - /** - * constructor. - */ - public static HashMap getBycodeAbi(String solFile, String contractName) { - final String compile = Configuration.getByPath("testng.conf") - .getString("defaultParameter.solidityCompile"); - - String dirPath = solFile.substring(solFile.lastIndexOf("/"), solFile.lastIndexOf(".")); - String outputPath = "src/test/resources/soliditycode/output" + dirPath; - - File binFile = new File(outputPath + "/" + contractName + ".bin"); - File abiFile = new File(outputPath + "/" + contractName + ".abi"); - if (binFile.exists()) { - binFile.delete(); - } - if (abiFile.exists()) { - abiFile.delete(); - } - - HashMap retMap = new HashMap<>(); - String absolutePath = System.getProperty("user.dir"); - logger.debug("absolutePath: " + absolutePath); - logger.debug("solFile: " + solFile); - logger.debug("outputPath: " + outputPath); - String cmd = - compile + " --optimize --bin --abi --overwrite " + solFile + " -o " - + absolutePath + "/" + outputPath; - logger.debug("cmd: " + cmd); - - String byteCode = null; - String abI = null; - - // compile solidity file - try { - exec(cmd); - } catch (InterruptedException e) { - e.printStackTrace(); - } - // get byteCode and ABI - try { - byteCode = fileRead(outputPath + "/" + contractName + ".bin", false); - retMap.put("byteCode", byteCode); - logger.debug("byteCode: " + byteCode); - abI = fileRead(outputPath + "/" + contractName + ".abi", false); - retMap.put("abI", abI); - logger.debug("abI: " + abI); - } catch (Exception e) { - e.printStackTrace(); - } - return retMap; - } - - /** - * constructor. - */ - public static String fileRead(String filePath, boolean isLibrary) throws Exception { - File file = new File(filePath); - FileReader reader = new FileReader(file); - BufferedReader breader = new BufferedReader(reader); - StringBuilder sb = new StringBuilder(); - String s = ""; - if (!isLibrary) { - if ((s = breader.readLine()) != null) { - sb.append(s); - } - breader.close(); - } else { - String fistLine = breader.readLine(); - breader.readLine(); - if ((s = breader.readLine()) != null && !s.equals("")) { - s = s.substring(s.indexOf("-> ") + 3); - sb.append(s + ":"); - } else { - s = fistLine.substring(fistLine.indexOf("__") + 2, fistLine.lastIndexOf("__")); - sb.append(s + ":"); - } - breader.close(); - } - return sb.toString(); - } - - /** - * constructor. - */ - public static HashMap getBycodeAbiForLibrary(String solFile, - String contractName) { - HashMap retMap = null; - String dirPath = solFile.substring(solFile.lastIndexOf("/"), solFile.lastIndexOf(".")); - String outputPath = "src/test/resources/soliditycode/output" + dirPath; - try { - retMap = PublicMethed.getBycodeAbi(solFile, contractName); - String library = fileRead(outputPath + "/" + contractName + ".bin", true); - retMap.put("library", library); - logger.debug("library: " + library); - } catch (Exception e) { - e.printStackTrace(); - } - - return retMap; - } - - /** - * constructor. - */ - public static String triggerConstantContract(byte[] contractAddress, String method, - String argsStr, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .triggerConstantContract(triggerContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - public static String clearContractAbi(byte[] contractAddress, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ClearABIContract.Builder builder = Contract.ClearABIContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - - Contract.ClearABIContract clearAbiContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .clearContractABI(clearAbiContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - GrpcAPI.Return response = broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - public static TransactionExtention clearContractAbiForExtention(byte[] contractAddress, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ClearABIContract.Builder builder = Contract.ClearABIContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - - Contract.ClearABIContract clearAbiContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .clearContractABI(clearAbiContract); - return transactionExtention; - - } - - /** - * constructor. - */ - public static TransactionExtention triggerConstantContractForExtention(byte[] contractAddress, - String method, - String argsStr, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .triggerConstantContract(triggerContract); - return transactionExtention; - - } - - /** - * constructor. - */ - - public static TransactionExtention triggerContractForExtention(byte[] contractAddress, - String method, String argsStr, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.triggerContract(triggerContract); - return transactionExtention; - - } - - /** - * constructor. - */ - public static String create2(String[] parameters) { - if (parameters == null || parameters.length != 3) { - logger.error("create2 needs 3 parameter:\ncreate2 address code salt"); - return null; - } - - byte[] address = WalletClient.decodeFromBase58Check(parameters[0]); - if (!WalletClient.addressValid(address)) { - logger.error("length of address must be 21 bytes."); - return null; - } - - byte[] code = Hex.decode(parameters[1]); - byte[] temp = Longs.toByteArray(Long.parseLong(parameters[2])); - if (temp.length != 8) { - logger.error("Invalid salt!"); - return null; - } - byte[] salt = new byte[32]; - System.arraycopy(temp, 0, salt, 24, 8); - - byte[] mergedData = ByteUtil.merge(address, salt, Hash.sha3(code)); - String create2Address = Base58.encode58Check(Hash.sha3omit12(mergedData)); - - logger.info("create2 Address: " + create2Address); - - return create2Address; - } - - - /** - * constructor. - */ - public static boolean sendShieldCoin(byte[] publicZenTokenOwnerAddress, - long fromAmount,ShieldAddressInfo shieldAddressInfo, - NoteTx noteTx,List shieldOutputList, - byte[] publicZenTokenToAddress, - long toAmount, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - PrivateParameters.Builder builder = PrivateParameters.newBuilder(); - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - builder.setTransparentFromAddress(ByteString.copyFrom(publicZenTokenOwnerAddress)); - builder.setFromAmount(fromAmount); - } - if (!ByteUtil.isNullOrZeroArray(publicZenTokenToAddress)) { - builder.setTransparentToAddress(ByteString.copyFrom(publicZenTokenToAddress)); - builder.setToAmount(toAmount); - } - - if (shieldAddressInfo != null) { - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - outPointBuild.setIndex(noteTx.getIndex()); - request.addOutPoints(outPointBuild.build()); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - - //String shieldAddress = noteInfo.getPaymentAddress(); - //ShieldAddressInfo addressInfo = - // shieldWrapper.getShieldAddressInfoMap().get(shieldAddress); - SpendingKey spendingKey = new SpendingKey(shieldAddressInfo.getSk()); - try { - ExpandedSpendingKey expandedSpendingKey = spendingKey.expandedSpendingKey(); - builder.setAsk(ByteString.copyFrom(expandedSpendingKey.getAsk())); - builder.setNsk(ByteString.copyFrom(expandedSpendingKey.getNsk())); - builder.setOvk(ByteString.copyFrom(expandedSpendingKey.getOvk())); - } catch (Exception e) { - System.out.println(e); - } - - - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddressInfo.getAddress()); - noteBuild.setValue(noteTx.getNote().getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteTx.getNote().getRcm().toByteArray())); - noteBuild.setMemo(ByteString.copyFrom(noteTx.getNote().getMemo().toByteArray())); - - - - - //System.out.println("address " + noteInfo.getPaymentAddress()); - //System.out.println("value " + noteInfo.getValue()); - //System.out.println("rcm " + ByteArray.toHexString(noteInfo.getR())); - //System.out.println("trxId " + noteInfo.getTrxId()); - //System.out.println("index " + noteInfo.getIndex()); - //System.out.println("meno " + new String(noteInfo.getMemo())); - - SpendNote.Builder spendNoteBuilder = SpendNote.newBuilder(); - spendNoteBuilder.setNote(noteBuild.build()); - try { - spendNoteBuilder.setAlpha(ByteString.copyFrom(org.tron.core.zen.note.Note.generateR())); - } catch (Exception e) { - System.out.println(e); - } - - IncrementalMerkleVoucherInfo merkleVoucherInfo = blockingStubFull - .getMerkleTreeVoucherInfo(request.build()); - spendNoteBuilder.setVoucher(merkleVoucherInfo.getVouchers(0)); - spendNoteBuilder.setPath(merkleVoucherInfo.getPaths(0)); - - builder.addShieldedSpends(spendNoteBuilder.build()); - - } else { - byte[] ovk = ByteArray - .fromHexString("030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d"); - builder.setOvk(ByteString.copyFrom(ovk)); - } - - if (shieldOutputList.size() > 0) { - for (int i = 0; i < shieldOutputList.size(); ++i) { - builder - .addShieldedReceives(ReceiveNote.newBuilder().setNote(shieldOutputList.get(i)).build()); - } - } - - TransactionExtention transactionExtention = blockingStubFull - .createShieldedTransaction(builder.build()); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - Any any = transaction.getRawData().getContract(0).getParameter(); - - try { - Contract.ShieldedTransferContract shieldedTransferContract = - any.unpack(Contract.ShieldedTransferContract.class); - if (shieldedTransferContract.getFromAmount() > 0 || fromAmount == 321321) { - transaction = signTransactionForShield(ecKey, transaction); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - } else { - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - } - } catch (Exception e) { - System.out.println(e); - } - return broadcastTransaction(transaction, blockingStubFull).getResult(); - } - - /** - * constructor. - */ - public static boolean sendShieldCoinWithoutAsk(byte[] publicZenTokenOwnerAddress, - long fromAmount, ShieldAddressInfo shieldAddressInfo, - NoteTx noteTx, List shieldOutputList, - byte[] publicZenTokenToAddress, - long toAmount, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - PrivateParametersWithoutAsk.Builder builder = PrivateParametersWithoutAsk.newBuilder(); - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - builder.setTransparentFromAddress(ByteString.copyFrom(publicZenTokenOwnerAddress)); - builder.setFromAmount(fromAmount); - } - if (!ByteUtil.isNullOrZeroArray(publicZenTokenToAddress)) { - builder.setTransparentToAddress(ByteString.copyFrom(publicZenTokenToAddress)); - builder.setToAmount(toAmount); - } - - byte[] ask = new byte[32]; - if (shieldAddressInfo != null) { - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - outPointBuild.setIndex(noteTx.getIndex()); - request.addOutPoints(outPointBuild.build()); - IncrementalMerkleVoucherInfo merkleVoucherInfo - = blockingStubFull.getMerkleTreeVoucherInfo(request.build()); - if (merkleVoucherInfo.getVouchersCount() != 1) { - System.out.println("Can't get all merkel tree, please check the notes."); - return false; - } - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - - //String shieldAddress = noteInfo.getPaymentAddress(); - //ShieldAddressInfo addressInfo = - // shieldWrapper.getShieldAddressInfoMap().get(shieldAddress); - String shieldAddress = noteTx.getNote().getPaymentAddress(); - SpendingKey spendingKey = new SpendingKey(shieldAddressInfo.getSk()); - try { - ExpandedSpendingKey expandedSpendingKey = spendingKey.expandedSpendingKey(); - System.arraycopy(expandedSpendingKey.getAsk(), 0, ask, 0, 32); - builder.setAk(ByteString.copyFrom( - ExpandedSpendingKey.getAkFromAsk(expandedSpendingKey.getAsk()))); - builder.setNsk(ByteString.copyFrom(expandedSpendingKey.getNsk())); - builder.setOvk(ByteString.copyFrom(expandedSpendingKey.getOvk())); - } catch (Exception e) { - System.out.println(e); - } - - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddressInfo.getAddress()); - noteBuild.setValue(noteTx.getNote().getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteTx.getNote().getRcm().toByteArray())); - noteBuild.setMemo(ByteString.copyFrom(noteTx.getNote().getMemo().toByteArray())); - - //System.out.println("address " + noteInfo.getPaymentAddress()); - //System.out.println("value " + noteInfo.getValue()); - //System.out.println("rcm " + ByteArray.toHexString(noteInfo.getR())); - //System.out.println("trxId " + noteInfo.getTrxId()); - //System.out.println("index " + noteInfo.getIndex()); - //System.out.println("meno " + new String(noteInfo.getMemo())); - - SpendNote.Builder spendNoteBuilder = SpendNote.newBuilder(); - spendNoteBuilder.setNote(noteBuild.build()); - try { - spendNoteBuilder.setAlpha(ByteString.copyFrom(org.tron.core.zen.note.Note.generateR())); - } catch (Exception e) { - System.out.println(e); - } - - spendNoteBuilder.setVoucher(merkleVoucherInfo.getVouchers(0)); - spendNoteBuilder.setPath(merkleVoucherInfo.getPaths(0)); - - builder.addShieldedSpends(spendNoteBuilder.build()); - - } else { - byte[] ovk = ByteArray - .fromHexString("030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d"); - builder.setOvk(ByteString.copyFrom(ovk)); - } - - if (shieldOutputList.size() > 0) { - for (int i = 0; i < shieldOutputList.size(); ++i) { - builder - .addShieldedReceives(ReceiveNote.newBuilder().setNote(shieldOutputList.get(i)).build()); - } - } - - TransactionExtention transactionExtention = blockingStubFull - .createShieldedTransactionWithoutSpendAuthSig(builder.build()); - if (transactionExtention == null) { - System.out.println("sendShieldCoinWithoutAsk failure."); - return false; - } - BytesMessage trxHash = blockingStubFull - .getShieldTransactionHash(transactionExtention.getTransaction()); - if (trxHash == null || trxHash.getValue().toByteArray().length != 32) { - System.out.println("sendShieldCoinWithoutAsk get transaction hash failure."); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRawData().getContract(0).getType() - != ContractType.ShieldedTransferContract) { - System.out.println("This method only for ShieldedTransferContract, please check!"); - return false; - } - Any any = transaction.getRawData().getContract(0).getParameter(); - Transaction transaction1 = transactionExtention.getTransaction(); - try { - ShieldedTransferContract shieldContract = any.unpack(ShieldedTransferContract.class); - List spendDescList = shieldContract.getSpendDescriptionList(); - ShieldedTransferContract.Builder contractBuild - = shieldContract.toBuilder().clearSpendDescription(); - for (int i = 0; i < spendDescList.size(); i++) { - - SpendAuthSigParameters.Builder builder1 = SpendAuthSigParameters.newBuilder(); - builder1.setAsk(ByteString.copyFrom(ask)); - builder1.setTxHash(ByteString.copyFrom(trxHash.getValue().toByteArray())); - builder1.setAlpha(builder.getShieldedSpends(i).getAlpha()); - SpendDescription.Builder spendDescription = spendDescList.get(i).toBuilder(); - BytesMessage authSig = blockingStubFull.createSpendAuthSig(builder1.build()); - spendDescription.setSpendAuthoritySignature( - ByteString.copyFrom(authSig.getValue().toByteArray())); - - contractBuild.addSpendDescription(spendDescription.build()); - } - - Transaction.raw.Builder rawBuilder - = transaction.toBuilder().getRawDataBuilder().clearContract() - .addContract( - Transaction.Contract.newBuilder().setType(ContractType.ShieldedTransferContract) - .setParameter( - Any.pack(contractBuild.build())).build()); - - transaction = transaction.toBuilder().clearRawData().setRawData(rawBuilder).build(); - - transactionExtention = transactionExtention.toBuilder().setTransaction(transaction).build(); - - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - transaction1 = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - if (transaction1.getRawData().getContract(0).getType() - != ContractType.ShieldedTransferContract) { - transaction1 = signTransaction(ecKey, transaction1); - } else { - Any any1 = transaction1.getRawData().getContract(0).getParameter(); - Contract.ShieldedTransferContract shieldedTransferContract = - any1.unpack(Contract.ShieldedTransferContract.class); - if (shieldedTransferContract.getFromAmount() > 0) { - transaction1 = signTransactionForShield(ecKey, transaction1); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction1.getRawData() - .toByteArray()))); - } - } - } catch (Exception e) { - System.out.println(e); - } - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction1.getRawData() - .toByteArray()))); - return broadcastTransaction(transaction1, blockingStubFull).getResult(); - } - - - /** - * constructor. - */ - public static List addShieldOutputList(List shieldOutList,String shieldToAddress, - String toAmountString,String menoString) { - String shieldAddress = shieldToAddress; - String amountString = toAmountString; - if (menoString.equals("null")) { - menoString = ""; - } - long shieldAmount = 0; - if (!StringUtil.isNullOrEmpty(amountString)) { - shieldAmount = Long.valueOf(amountString); - } - - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddress); - noteBuild.setPaymentAddress(shieldAddress); - noteBuild.setValue(shieldAmount); - try { - noteBuild.setRcm(ByteString.copyFrom(org.tron.core.zen.note.Note.generateR())); - } catch (Exception e) { - System.out.println(e); - } - noteBuild.setMemo(ByteString.copyFrom(menoString.getBytes())); - shieldOutList.add(noteBuild.build()); - //logger.info(shieldOutList.toString()); - return shieldOutList; - } - - /** - * constructor. - */ - public static Optional generateShieldAddress() { - ShieldAddressInfo addressInfo = new ShieldAddressInfo(); - try { - DiversifierT diversifier = DiversifierT.random(); - SpendingKey spendingKey = SpendingKey.random(); - FullViewingKey fullViewingKey = spendingKey.fullViewingKey(); - IncomingViewingKey incomingViewingKey = fullViewingKey.inViewingKey(); - PaymentAddress paymentAddress = incomingViewingKey.address(diversifier).get(); - - addressInfo.setSk(spendingKey.getValue()); - addressInfo.setD(diversifier); - addressInfo.setIvk(incomingViewingKey.getValue()); - addressInfo.setOvk(fullViewingKey.getOvk()); - addressInfo.setPkD(paymentAddress.getPkD()); - - if (addressInfo.validateCheck()) { - return Optional.of(addressInfo); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return Optional.empty(); - } - - /** - * constructor. - */ - public static DecryptNotes listShieldNote(Optional shieldAddressInfo, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long startBlockNum = 0L; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - logger.info(ByteArray.toHexString(shieldAddressInfo.get().ivk)); - IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum); - builder.setEndBlockIndex(currentBlockNum + 1); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build()); - logger.info(notes.toString()); - return notes; - } - - /** - * constructor. - */ - public static DecryptNotes getShieldNotesByIvk(Optional shieldAddressInfo, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long startBlockNum = 0L; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - //startBlockNum = 0L; - logger.info("ivk:" + ByteArray.toHexString(shieldAddressInfo.get().ivk)); - IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum + 1); - builder.setEndBlockIndex(currentBlockNum + 1); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build()); - logger.info(notes.toString()); - return notes; - } - - /** - * constructor. - */ - public static DecryptNotesMarked getShieldNotesAndMarkByIvk( - Optional shieldAddressInfo, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long startBlockNum = 0L; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - //startBlockNum = 0L; - logger.info("ivk:" + ByteArray.toHexString(shieldAddressInfo.get().ivk)); - try { - IvkDecryptAndMarkParameters.Builder builder = IvkDecryptAndMarkParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum + 1); - builder.setEndBlockIndex(currentBlockNum + 1); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - builder.setAk(ByteString.copyFrom(shieldAddressInfo.get().getFullViewingKey().getAk())); - builder.setNk(ByteString.copyFrom(shieldAddressInfo.get().getFullViewingKey().getNk())); - DecryptNotesMarked decryptNotes = blockingStubFull.scanAndMarkNoteByIvk(builder.build()); - logger.info(decryptNotes.toString()); - return decryptNotes; - } catch (Exception e) { - logger.info(e.toString()); - return null; - } - } - - /** - * constructor. - */ - public static DecryptNotesMarked getShieldNotesAndMarkByIvkOnSolidity( - Optional shieldAddressInfo, - WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity) { - Block currentBlock = blockingStubSolidity - .getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long startBlockNum = 0L; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - //startBlockNum = 0L; - logger.info("ivk:" + ByteArray.toHexString(shieldAddressInfo.get().ivk)); - try { - IvkDecryptAndMarkParameters.Builder builder = IvkDecryptAndMarkParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum + 1); - builder.setEndBlockIndex(currentBlockNum + 1); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - builder.setAk(ByteString.copyFrom(shieldAddressInfo.get().getFullViewingKey().getAk())); - builder.setNk(ByteString.copyFrom(shieldAddressInfo.get().getFullViewingKey().getNk())); - DecryptNotesMarked decryptNotes = blockingStubSolidity.scanAndMarkNoteByIvk(builder.build()); - logger.info(decryptNotes.toString()); - return decryptNotes; - } catch (Exception e) { - logger.info(e.toString()); - return null; - } - } - - /** - * constructor. - */ - public static Integer getShieldNotesCount(Optional shieldAddressInfo, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - - - if (currentBlockNum < 100) { - IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(0); - builder.setEndBlockIndex(currentBlockNum); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build()); - logger.info(notes.toString()); - return notes.getNoteTxsCount(); - } - Integer count = 0; - Long startBlockNum = 0L; - while (startBlockNum + 100 < currentBlockNum) { - IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum); - builder.setEndBlockIndex(startBlockNum + 100); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build()); - count = count + notes.getNoteTxsCount(); - startBlockNum = startBlockNum + 100; - } - IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum); - builder.setEndBlockIndex(currentBlockNum); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build()); - count = count + notes.getNoteTxsCount(); - return count; - - } - - /** - * constructor. - */ - public static DecryptNotes getShieldNotesByIvkOnSolidity( - Optional shieldAddressInfo, - WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity) { - Block currentBlock = blockingStubSolidity - .getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long startBlockNum = 0L; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum); - builder.setEndBlockIndex(currentBlockNum); - builder.setIvk(ByteString.copyFrom(shieldAddressInfo.get().getIvk())); - DecryptNotes notes = blockingStubSolidity.scanNoteByIvk(builder.build()); - logger.info(notes.toString()); - return notes; - } - - - - /** - * constructor. - */ - public static DecryptNotes getShieldNotesByOvk(Optional shieldAddressInfo, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long startBlockNum = 0L; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - logger.info("ovk:" + ByteArray.toHexString(shieldAddressInfo.get().ovk)); - OvkDecryptParameters.Builder builder = OvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum + 1); - builder.setEndBlockIndex(currentBlockNum + 1); - builder.setOvk(ByteString.copyFrom(shieldAddressInfo.get().getOvk())); - DecryptNotes notes = blockingStubFull.scanNoteByOvk(builder.build()); - logger.info(notes.toString()); - return notes; - } - - /** - * constructor. - */ - public static DecryptNotes getShieldNotesByOvkOnSolidity( - Optional shieldAddressInfo, WalletSolidityGrpc - .WalletSolidityBlockingStub blockingStubSolidity) { - Block currentBlock = blockingStubSolidity - .getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long startBlockNum = 0L; - if (currentBlockNum > 100) { - startBlockNum = currentBlockNum - 100; - } - OvkDecryptParameters.Builder builder = OvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(startBlockNum); - builder.setEndBlockIndex(currentBlockNum); - builder.setOvk(ByteString.copyFrom(shieldAddressInfo.get().getOvk())); - DecryptNotes notes = blockingStubSolidity.scanNoteByOvk(builder.build()); - logger.info(notes.toString()); - return notes; - } - - - /** - * constructor. - */ - public static String getMemo(Note note) { - return ZenUtils.getMemo(note.getMemo().toByteArray()); - } - - /** - * constructor. - */ - public static SpendResult getSpendResult( - ShieldAddressInfo shieldAddressInfo, NoteTx noteTx, - WalletGrpc.WalletBlockingStub blockingStubFull) { - - - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - outPointBuild.setIndex(noteTx.getIndex()); - request.addOutPoints(outPointBuild.build()); - Optional merkleVoucherInfo = Optional.of(blockingStubFull - .getMerkleTreeVoucherInfo(request.build())); - - if (merkleVoucherInfo.isPresent() && merkleVoucherInfo.get().getVouchersCount() > 0) { - NoteParameters.Builder builder = NoteParameters.newBuilder(); - try { - builder.setAk(ByteString.copyFrom(shieldAddressInfo.getFullViewingKey().getAk())); - builder.setNk(ByteString.copyFrom(shieldAddressInfo.getFullViewingKey().getNk())); - logger.info("AK:" + ByteArray.toHexString(shieldAddressInfo.getFullViewingKey().getAk())); - logger.info("NK:" + ByteArray.toHexString(shieldAddressInfo.getFullViewingKey().getNk())); - } catch (Exception e) { - Assert.assertTrue(1 == 1); - } - - - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddressInfo.getAddress()); - noteBuild.setValue(noteTx.getNote().getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteTx.getNote().getRcm().toByteArray())); - noteBuild.setMemo(ByteString.copyFrom(noteTx.getNote().getMemo().toByteArray())); - builder.setNote(noteBuild.build()); - builder.setTxid(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - builder.setIndex(noteTx.getIndex()); - //builder.setVoucher(merkleVoucherInfo.getVouchers(0)); - - SpendResult result = blockingStubFull.isSpend(builder.build()); - return result; - - } - return null; - - } - - /** - * constructor. - */ - public static SpendResult getSpendResultOnSolidity( - ShieldAddressInfo shieldAddressInfo, NoteTx noteTx, WalletSolidityGrpc - .WalletSolidityBlockingStub blockingStubSolidity) { - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - outPointBuild.setIndex(noteTx.getIndex()); - request.addOutPoints(outPointBuild.build()); - Optional merkleVoucherInfo = Optional.of(blockingStubSolidity - .getMerkleTreeVoucherInfo(request.build())); - - if (merkleVoucherInfo.isPresent() && merkleVoucherInfo.get().getVouchersCount() > 0) { - NoteParameters.Builder builder = NoteParameters.newBuilder(); - try { - builder.setAk(ByteString.copyFrom(shieldAddressInfo.getFullViewingKey().getAk())); - builder.setNk(ByteString.copyFrom(shieldAddressInfo.getFullViewingKey().getNk())); - } catch (Exception e) { - Assert.assertTrue(1 == 1); - } - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddressInfo.getAddress()); - noteBuild.setValue(noteTx.getNote().getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteTx.getNote().getRcm().toByteArray())); - noteBuild.setMemo(ByteString.copyFrom(noteTx.getNote().getMemo().toByteArray())); - builder.setNote(noteBuild.build()); - builder.setTxid(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - builder.setIndex(noteTx.getIndex()); - //builder.setVoucher(merkleVoucherInfo.getVouchers(0)); - - SpendResult result = blockingStubSolidity.isSpend(builder.build()); - return result; - } - return null; - } - - /** - * constructor. - */ - public static String getShieldNullifier(ShieldAddressInfo shieldAddressInfo, - NoteTx noteTx,WalletGrpc.WalletBlockingStub blockingStubFull) { - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - outPointBuild.setIndex(noteTx.getIndex()); - request.addOutPoints(outPointBuild.build()); - IncrementalMerkleVoucherInfo merkleVoucherInfo - = blockingStubFull.getMerkleTreeVoucherInfo(request.build()); - if (merkleVoucherInfo.getVouchersCount() < 1) { - System.out.println("get merkleVoucherInfo failure."); - return null; - } - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddressInfo.getAddress()); - noteBuild.setValue(noteTx.getNote().getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteTx.getNote().getRcm().toByteArray())); - noteBuild.setMemo(ByteString.copyFrom(noteTx.getNote().getMemo().toByteArray())); - - String shieldAddress = noteTx.getNote().getPaymentAddress(); - SpendingKey spendingKey = new SpendingKey(shieldAddressInfo.getSk()); - try { - //TODO - FullViewingKey fullViewingKey = spendingKey.fullViewingKey(); - NfParameters.Builder builder = NfParameters.newBuilder(); - builder.setNote(noteBuild.build()); - builder.setVoucher(merkleVoucherInfo.getVouchers(0)); - builder.setAk(ByteString.copyFrom(fullViewingKey.getAk())); - builder.setNk(ByteString.copyFrom(fullViewingKey.getNk())); - - BytesMessage nullifier = blockingStubFull.createShieldNullifier(builder.build()); - return ByteArray.toHexString(nullifier.getValue().toByteArray()); - - } catch (Exception e) { - e.printStackTrace(); - } - return null; - - } - - - /** - * constructor. - */ - public static String sendShieldCoinGetTxid(byte[] publicZenTokenOwnerAddress, - long fromAmount,ShieldAddressInfo shieldAddressInfo, - NoteTx noteTx,List shieldOutputList, - byte[] publicZenTokenToAddress, - long toAmount, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - PrivateParameters.Builder builder = PrivateParameters.newBuilder(); - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - builder.setTransparentFromAddress(ByteString.copyFrom(publicZenTokenOwnerAddress)); - builder.setFromAmount(fromAmount); - } - if (!ByteUtil.isNullOrZeroArray(publicZenTokenToAddress)) { - builder.setTransparentToAddress(ByteString.copyFrom(publicZenTokenToAddress)); - builder.setToAmount(toAmount); - } - - if (shieldAddressInfo != null) { - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - outPointBuild.setIndex(noteTx.getIndex()); - request.addOutPoints(outPointBuild.build()); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - - //String shieldAddress = noteInfo.getPaymentAddress(); - //ShieldAddressInfo addressInfo = - // shieldWrapper.getShieldAddressInfoMap().get(shieldAddress); - SpendingKey spendingKey = new SpendingKey(shieldAddressInfo.getSk()); - try { - ExpandedSpendingKey expandedSpendingKey = spendingKey.expandedSpendingKey(); - builder.setAsk(ByteString.copyFrom(expandedSpendingKey.getAsk())); - builder.setNsk(ByteString.copyFrom(expandedSpendingKey.getNsk())); - builder.setOvk(ByteString.copyFrom(expandedSpendingKey.getOvk())); - } catch (Exception e) { - System.out.println(e); - } - - - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddressInfo.getAddress()); - noteBuild.setValue(noteTx.getNote().getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteTx.getNote().getRcm().toByteArray())); - noteBuild.setMemo(ByteString.copyFrom(noteTx.getNote().getMemo().toByteArray())); - - - - //System.out.println("address " + noteInfo.getPaymentAddress()); - //System.out.println("value " + noteInfo.getValue()); - //System.out.println("rcm " + ByteArray.toHexString(noteInfo.getR())); - //System.out.println("trxId " + noteInfo.getTrxId()); - //System.out.println("index " + noteInfo.getIndex()); - //System.out.println("meno " + new String(noteInfo.getMemo())); - - SpendNote.Builder spendNoteBuilder = SpendNote.newBuilder(); - spendNoteBuilder.setNote(noteBuild.build()); - try { - spendNoteBuilder.setAlpha(ByteString.copyFrom(org.tron.core.zen.note.Note.generateR())); - } catch (Exception e) { - System.out.println(e); - } - - IncrementalMerkleVoucherInfo merkleVoucherInfo = blockingStubFull - .getMerkleTreeVoucherInfo(request.build()); - spendNoteBuilder.setVoucher(merkleVoucherInfo.getVouchers(0)); - spendNoteBuilder.setPath(merkleVoucherInfo.getPaths(0)); - - builder.addShieldedSpends(spendNoteBuilder.build()); - - } else { - byte[] ovk = ByteArray - .fromHexString("030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d"); - builder.setOvk(ByteString.copyFrom(ovk)); - } - - if (shieldOutputList.size() > 0) { - for (int i = 0; i < shieldOutputList.size(); ++i) { - builder - .addShieldedReceives(ReceiveNote.newBuilder().setNote(shieldOutputList.get(i)).build()); - } - } - - TransactionExtention transactionExtention = blockingStubFull - .createShieldedTransaction(builder.build()); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - Any any = transaction.getRawData().getContract(0).getParameter(); - - try { - Contract.ShieldedTransferContract shieldedTransferContract = - any.unpack(Contract.ShieldedTransferContract.class); - if (shieldedTransferContract.getFromAmount() > 0) { - transaction = signTransactionForShield(ecKey, transaction); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - } else { - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - } - } catch (Exception e) { - System.out.println(e); - } - broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray())); - } - - - - - -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/PublicMethedForMutiSign.java b/src/test/java/stest/tron/wallet/common/client/utils/PublicMethedForMutiSign.java deleted file mode 100644 index 22298e233a6..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/PublicMethedForMutiSign.java +++ /dev/null @@ -1,4838 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.protobuf.Any; -import com.google.protobuf.ByteString; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicLong; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.spongycastle.util.encoders.Hex; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.DecryptNotes.NoteTx; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ExchangeList; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.GrpcAPI.PrivateParameters; -import org.tron.api.GrpcAPI.ReceiveNote; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.SpendNote; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.ECKey.ECDSASignature; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.Base58; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.ByteUtil; -import org.tron.core.Wallet; -import org.tron.core.exception.CancelException; -import org.tron.core.zen.address.ExpandedSpendingKey; -import org.tron.core.zen.address.SpendingKey; -import org.tron.protos.Contract; -import org.tron.protos.Contract.CreateSmartContract; -import org.tron.protos.Contract.CreateSmartContract.Builder; -import org.tron.protos.Contract.IncrementalMerkleVoucherInfo; -import org.tron.protos.Contract.OutputPoint; -import org.tron.protos.Contract.OutputPointInfo; -import org.tron.protos.Contract.UpdateEnergyLimitContract; -import org.tron.protos.Contract.UpdateSettingContract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Key; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import org.tron.protos.Protocol.Transaction.Result; -import org.tron.protos.Protocol.Transaction.raw; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; - - -public class PublicMethedForMutiSign { - - Wallet wallet = new Wallet(); - private static final Logger logger = LoggerFactory.getLogger("TestLogger"); - - /** - * constructor. - */ - - public static Boolean createAssetIssue(byte[] address, String name, Long totalSupply, - Integer trxNum, Integer icoNum, Long startTime, Long endTime, Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public static String createAssetIssueForTransactionId(byte[] address, String name, - Long totalSupply, - Integer trxNum, Integer icoNum, Long startTime, Long endTime, Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return null; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - boolean result = broadcastTransaction(transaction, blockingStubFull); - if (result == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } - - /** - * constructor. - */ - public static boolean broadcastTransaction(Transaction transaction, - WalletGrpc.WalletBlockingStub blockingStubFull) { - - Return response = PublicMethed.broadcastTransaction(transaction, blockingStubFull); - return response.getResult(); - } - - - /** - * constructor. - */ - public static Account queryAccount(byte[] address, WalletGrpc - .WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public static Account queryAccount(byte[] address, WalletSolidityGrpc - .WalletSolidityBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - - /** - * constructor. - */ - - public static Account queryAccount(String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - /** - * constructor. - */ - - public static String loadPubKey() { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - /** - * constructor. - */ - - public static byte[] getAddress(ECKey ecKey) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public static Account grpcQueryAccount(byte[] address, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public static Block getBlock(long blockNum, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - GrpcAPI.NumberMessage.Builder builder = GrpcAPI.NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - /** - * constructor. - */ - - public static Transaction signTransaction(ECKey ecKey, - Transaction transaction) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - if (ecKey == null || ecKey.getPrivKey() == null) { - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - private static Transaction signTransaction(Transaction transaction, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] priKeys) { - if (transaction.getRawData().getTimestamp() == 0) { - transaction = TransactionUtils.setTimestamp(transaction); - } - - long currentTime = System.currentTimeMillis();//*1000000 + System.nanoTime()%1000000; - Transaction.Builder builder = transaction.toBuilder(); - org.tron.protos.Protocol.Transaction.raw.Builder rowBuilder = transaction.getRawData() - .toBuilder(); - rowBuilder.setTimestamp(currentTime); - builder.setRawData(rowBuilder.build()); - transaction = builder.build(); - - for (int i = 0; i < priKeys.length; i += 1) { - String priKey = priKeys[i]; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - transaction = TransactionUtils.sign(transaction, ecKey); - TransactionSignWeight weight = blockingStubFull.getTransactionSignWeight(transaction); - if (weight.getResult().getCode() - == TransactionSignWeight.Result.response_code.ENOUGH_PERMISSION) { - break; - } - if (weight.getResult().getCode() - == TransactionSignWeight.Result.response_code.NOT_ENOUGH_PERMISSION) { - continue; - } - } - return transaction; - } - - - /** - * constructor. - */ - public static boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, - byte[] from, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static boolean participateAssetIssueWithPermissionId(byte[] to, byte[] assertName, - long amount, byte[] from, String priKey, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static String participateAssetIssueForTransactionId(byte[] to, byte[] assertName, - long amount, byte[] from, String priKey, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - boolean result = broadcastTransaction(transaction, blockingStubFull); - if (result == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Block currentBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Account beforeFronzen = queryAccount(priKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return null; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - - } - - /** - * constructor. - */ - - public static Boolean freezeBalanceWithPermissionId(byte[] addRess, long freezeBalance, - long freezeDuration, - int permissionId, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Block currentBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Account beforeFronzen = queryAccount(priKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return null; - } - - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - - } - - /** - * constructor. - */ - - public static Boolean unFreezeBalanceWithPermissionId(byte[] address, String priKey, - int resourceCode, byte[] receiverAddress, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UnfreezeBalanceContract.Builder builder = Contract.UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess).setResourceValue(resourceCode); - if (receiverAddress != null) { - ByteString receiverAddressBytes = ByteString.copyFrom(receiverAddress); - builder.setReceiverAddress(receiverAddressBytes); - } - - Contract.UnfreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static Boolean unFreezeBalance(byte[] address, String priKey, int resourceCode, - byte[] receiverAddress, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UnfreezeBalanceContract.Builder builder = Contract.UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess).setResourceValue(resourceCode); - if (receiverAddress != null) { - ByteString receiverAddressBytes = ByteString.copyFrom(receiverAddress); - builder.setReceiverAddress(receiverAddressBytes); - } - - Contract.UnfreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return null; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - - } - - /** - * constructor. - */ - - public static String sendcoinGetTransactionHex(byte[] to, long amount, byte[] owner, - String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return null; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - logger.info("HEX transaction is : " + "transaction hex string is " + ByteArray - .toHexString(transaction.toByteArray())); - return ByteArray.toHexString(transaction.toByteArray()); - - } - - - - /** - * constructor. - */ - public static boolean updateAsset(byte[] address, byte[] description, byte[] url, long newLimit, - long newPublicLimit, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UpdateAssetContract.Builder builder = - Contract.UpdateAssetContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(address); - builder.setDescription(ByteString.copyFrom(description)); - builder.setUrl(ByteString.copyFrom(url)); - builder.setNewLimit(newLimit); - builder.setNewPublicLimit(newPublicLimit); - builder.setOwnerAddress(basAddreess); - - Contract.UpdateAssetContract contract - = builder.build(); - Transaction transaction = blockingStubFull.updateAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static boolean updateAssetWithPermissionId(byte[] address, byte[] description, byte[] url, - long newLimit, long newPublicLimit, String priKey, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UpdateAssetContract.Builder builder = - Contract.UpdateAssetContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(address); - builder.setDescription(ByteString.copyFrom(description)); - builder.setUrl(ByteString.copyFrom(url)); - builder.setNewLimit(newLimit); - builder.setNewPublicLimit(newPublicLimit); - builder.setOwnerAddress(basAddreess); - - Contract.UpdateAssetContract contract - = builder.build(); - Transaction transaction = blockingStubFull.updateAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static String updateAssetForTransactionId(byte[] address, byte[] description, byte[] url, - long newLimit, long newPublicLimit, String priKey, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UpdateAssetContract.Builder builder = - Contract.UpdateAssetContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(address); - builder.setDescription(ByteString.copyFrom(description)); - builder.setUrl(ByteString.copyFrom(url)); - builder.setNewLimit(newLimit); - builder.setNewPublicLimit(newPublicLimit); - builder.setOwnerAddress(basAddreess); - - Contract.UpdateAssetContract contract - = builder.build(); - Transaction transaction = blockingStubFull.updateAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return null; - } - - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - boolean result = broadcastTransaction(transaction, blockingStubFull); - if (result == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - logger.info("transaction == null"); - } else { - logger.info("transaction.getRawData().getContractCount() == 0"); - } - return false; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static String transferAssetForTransactionId(byte[] to, byte[] assertName, long amount, - byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - logger.info("transaction == null"); - } else { - logger.info("transaction.getRawData().getContractCount() == 0"); - } - return null; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - boolean result = broadcastTransaction(transaction, blockingStubFull); - if (result == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static boolean updateAccount(byte[] addressBytes, byte[] accountNameBytes, String - priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(addressBytes); - ByteString bsAccountName = ByteString.copyFrom(accountNameBytes); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - Contract.AccountUpdateContract contract = builder.build(); - Transaction transaction = blockingStubFull.updateAccount(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return false; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean waitProduceNextBlock(WalletGrpc.WalletBlockingStub - blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - Block currentBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - final Long currentNum = currentBlock.getBlockHeader().getRawData().getNumber(); - - Block nextBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - Long nextNum = nextBlock.getBlockHeader().getRawData().getNumber(); - - Integer wait = 0; - logger.info("Block num is " + Long.toString(currentBlock - .getBlockHeader().getRawData().getNumber())); - while (nextNum <= currentNum + 1 && wait <= 15) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("Wait to produce next block"); - nextBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - nextNum = nextBlock.getBlockHeader().getRawData().getNumber(); - if (wait == 15) { - logger.info("These 45 second didn't produce a block,please check."); - return false; - } - wait++; - } - logger.info("quit normally"); - return true; - } - - /** - * constructor. - */ - - public static boolean createAccount(byte[] ownerAddress, byte[] newAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setAccountAddress(ByteString.copyFrom(newAddress)); - Contract.AccountCreateContract contract = builder.build(); - Transaction transaction = blockingStubFull.createAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - - } - - /** - * constructor. - */ - - public static boolean createProposal(byte[] ownerAddress, String priKey, - HashMap parametersMap, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalCreateContract.Builder builder = Contract.ProposalCreateContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.putAllParameters(parametersMap); - - Contract.ProposalCreateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalCreate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean createProposalWithPermissionId(byte[] ownerAddress, String priKey, - HashMap parametersMap, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalCreateContract.Builder builder = Contract.ProposalCreateContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.putAllParameters(parametersMap); - - Contract.ProposalCreateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalCreate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean approveProposal(byte[] ownerAddress, String priKey, long id, - boolean isAddApproval, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalApproveContract.Builder builder = Contract.ProposalApproveContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setProposalId(id); - builder.setIsAddApproval(isAddApproval); - Contract.ProposalApproveContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalApprove(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean approveProposalWithPermission(byte[] ownerAddress, String priKey, - long id, - boolean isAddApproval, int permissionId, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalApproveContract.Builder builder = Contract.ProposalApproveContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setProposalId(id); - builder.setIsAddApproval(isAddApproval); - Contract.ProposalApproveContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalApprove(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean deleteProposal(byte[] ownerAddress, String priKey, long id, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalDeleteContract.Builder builder = Contract.ProposalDeleteContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setProposalId(id); - - Contract.ProposalDeleteContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalDelete(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean deleteProposalWithPermissionId(byte[] ownerAddress, String priKey, - long id, - int permissionId, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.ProposalDeleteContract.Builder builder = Contract.ProposalDeleteContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setProposalId(id); - - Contract.ProposalDeleteContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.proposalDelete(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean setAccountId(byte[] accountIdBytes, byte[] ownerAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.SetAccountIdContract.Builder builder = Contract.SetAccountIdContract.newBuilder(); - ByteString bsAddress = ByteString.copyFrom(owner); - ByteString bsAccountId = ByteString.copyFrom(accountIdBytes); - builder.setAccountId(bsAccountId); - builder.setOwnerAddress(bsAddress); - Contract.SetAccountIdContract contract = builder.build(); - Transaction transaction = blockingStubFull.setAccountId(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - transaction = signTransaction(ecKey, transaction); - Return response = broadcastTransaction1(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - - public static Boolean freezeBalanceGetEnergy(byte[] addRess, long freezeBalance, - long freezeDuration, int resourceCode, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration).setResourceValue(resourceCode); - - Contract.FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - transaction = TransactionUtils.setTimestamp(transaction); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static byte[] deployContract(String contractName, String abiString, String code, - String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - return deployContract(contractName, abiString, code, data, feeLimit, value, - consumeUserResourcePercent, 1000L, "0", 0L, libraryAddress, - priKey, ownerAddress, blockingStubFull, permissionKeyString); - } - - /** - * constructor. - */ - - public static byte[] deployContract(String contractName, String abiString, String code, - String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - byte[] contractAddress = PublicMethed.generateContractAddress( - transactionExtention.getTransaction(), owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - System.out.println( - "txid = " + ByteArray - .toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - contractAddress = PublicMethed.generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - broadcastTransaction(transaction, blockingStubFull); - return contractAddress; - } - - /** - * constructor. - */ - - public static String deployContractAndGetTransactionInfoById(String contractName, - String abiString, String code, String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - return deployContractAndGetTransactionInfoById(contractName, abiString, code, data, feeLimit, - value, consumeUserResourcePercent, 1000L, "0", 0L, libraryAddress, - priKey, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - - public static String deployContractAndGetTransactionInfoById(String contractName, - String abiString, String code, String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray - .toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - byte[] contractAddress = PublicMethed.generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - Return response = broadcastTransaction1(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static SmartContract.ABI jsonStr2Abi(String jsonStr) { - if (jsonStr == null) { - return null; - } - - JsonParser jsonParser = new JsonParser(); - JsonElement jsonElementRoot = jsonParser.parse(jsonStr); - JsonArray jsonRoot = jsonElementRoot.getAsJsonArray(); - SmartContract.ABI.Builder abiBuilder = SmartContract.ABI.newBuilder(); - for (int index = 0; index < jsonRoot.size(); index++) { - JsonElement abiItem = jsonRoot.get(index); - boolean anonymous = abiItem.getAsJsonObject().get("anonymous") != null - ? abiItem.getAsJsonObject().get("anonymous").getAsBoolean() : false; - final boolean constant = abiItem.getAsJsonObject().get("constant") != null - ? abiItem.getAsJsonObject().get("constant").getAsBoolean() : false; - final String name = abiItem.getAsJsonObject().get("name") != null - ? abiItem.getAsJsonObject().get("name").getAsString() : null; - JsonArray inputs = abiItem.getAsJsonObject().get("inputs") != null - ? abiItem.getAsJsonObject().get("inputs").getAsJsonArray() : null; - final JsonArray outputs = abiItem.getAsJsonObject().get("outputs") != null - ? abiItem.getAsJsonObject().get("outputs").getAsJsonArray() : null; - String type = abiItem.getAsJsonObject().get("type") != null - ? abiItem.getAsJsonObject().get("type").getAsString() : null; - final boolean payable = abiItem.getAsJsonObject().get("payable") != null - ? abiItem.getAsJsonObject().get("payable").getAsBoolean() : false; - final String stateMutability = abiItem.getAsJsonObject().get("stateMutability") != null - ? abiItem.getAsJsonObject().get("stateMutability").getAsString() : null; - if (type == null) { - logger.error("No type!"); - return null; - } - if (!type.equalsIgnoreCase("fallback") && null == inputs) { - logger.error("No inputs!"); - return null; - } - - SmartContract.ABI.Entry.Builder entryBuilder = SmartContract.ABI.Entry.newBuilder(); - entryBuilder.setAnonymous(anonymous); - entryBuilder.setConstant(constant); - if (name != null) { - entryBuilder.setName(name); - } - - /* { inputs : optional } since fallback function not requires inputs*/ - if (inputs != null) { - for (int j = 0; j < inputs.size(); j++) { - JsonElement inputItem = inputs.get(j); - if (inputItem.getAsJsonObject().get("name") == null - || inputItem.getAsJsonObject().get("type") == null) { - logger.error("Input argument invalid due to no name or no type!"); - return null; - } - String inputName = inputItem.getAsJsonObject().get("name").getAsString(); - String inputType = inputItem.getAsJsonObject().get("type").getAsString(); - SmartContract.ABI.Entry.Param.Builder paramBuilder = SmartContract.ABI.Entry.Param - .newBuilder(); - paramBuilder.setIndexed(false); - paramBuilder.setName(inputName); - paramBuilder.setType(inputType); - entryBuilder.addInputs(paramBuilder.build()); - } - } - - /* { outputs : optional } */ - if (outputs != null) { - for (int k = 0; k < outputs.size(); k++) { - JsonElement outputItem = outputs.get(k); - if (outputItem.getAsJsonObject().get("name") == null - || outputItem.getAsJsonObject().get("type") == null) { - logger.error("Output argument invalid due to no name or no type!"); - return null; - } - String outputName = outputItem.getAsJsonObject().get("name").getAsString(); - String outputType = outputItem.getAsJsonObject().get("type").getAsString(); - SmartContract.ABI.Entry.Param.Builder paramBuilder = SmartContract.ABI.Entry.Param - .newBuilder(); - paramBuilder.setIndexed(false); - paramBuilder.setName(outputName); - paramBuilder.setType(outputType); - entryBuilder.addOutputs(paramBuilder.build()); - } - } - - entryBuilder.setType(getEntryType(type)); - entryBuilder.setPayable(payable); - if (stateMutability != null) { - entryBuilder.setStateMutability(getStateMutability(stateMutability)); - } - - abiBuilder.addEntrys(entryBuilder.build()); - } - - return abiBuilder.build(); - } - - /** - * constructor. - */ - - public static SmartContract.ABI.Entry.EntryType getEntryType(String type) { - switch (type) { - case "constructor": - return SmartContract.ABI.Entry.EntryType.Constructor; - case "function": - return SmartContract.ABI.Entry.EntryType.Function; - case "event": - return SmartContract.ABI.Entry.EntryType.Event; - case "fallback": - return SmartContract.ABI.Entry.EntryType.Fallback; - default: - return SmartContract.ABI.Entry.EntryType.UNRECOGNIZED; - } - } - - /** - * constructor. - */ - - public static SmartContract.ABI.Entry.StateMutabilityType getStateMutability( - String stateMutability) { - switch (stateMutability) { - case "pure": - return SmartContract.ABI.Entry.StateMutabilityType.Pure; - case "view": - return SmartContract.ABI.Entry.StateMutabilityType.View; - case "nonpayable": - return SmartContract.ABI.Entry.StateMutabilityType.Nonpayable; - case "payable": - return SmartContract.ABI.Entry.StateMutabilityType.Payable; - default: - return SmartContract.ABI.Entry.StateMutabilityType.UNRECOGNIZED; - } - } - - /** - * constructor. - */ - - public static SmartContract getContract(byte[] address, WalletGrpc - .WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ByteString byteString = ByteString.copyFrom(address); - BytesMessage bytesMessage = BytesMessage.newBuilder().setValue(byteString).build(); - Integer i = 0; - while (blockingStubFull.getContract(bytesMessage).getName().isEmpty() && i++ < 4) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - logger.info("contract name is " + blockingStubFull.getContract(bytesMessage).getName()); - logger.info("contract address is " + WalletClient.encode58Check(address)); - return blockingStubFull.getContract(bytesMessage); - } - - private static byte[] replaceLibraryAddress(String code, String libraryAddressPair) { - - String[] libraryAddressList = libraryAddressPair.split("[,]"); - - for (int i = 0; i < libraryAddressList.length; i++) { - String cur = libraryAddressList[i]; - - int lastPosition = cur.lastIndexOf(":"); - if (-1 == lastPosition) { - throw new RuntimeException("libraryAddress delimit by ':'"); - } - String libraryName = cur.substring(0, lastPosition); - String addr = cur.substring(lastPosition + 1); - String libraryAddressHex = ByteArray.toHexString(Wallet.decodeFromBase58Check(addr)) - .substring(2); - - String repeated = new String(new char[40 - libraryName.length() - 2]).replace("\0", "_"); - String beReplaced = "__" + libraryName + repeated; - Matcher m = Pattern.compile(beReplaced).matcher(code); - code = m.replaceAll(libraryAddressHex); - } - - return Hex.decode(code); - } - - private static byte[] replaceLibraryAddress_1(String code, byte[] libraryAddress) { - - String libraryAddressHex = ByteArray.toHexString(libraryAddress).substring(2); - - Matcher m = Pattern.compile("__.*__").matcher(code); - code = m.replaceAll(libraryAddressHex); - return Hex.decode(code); - } - - /** - * constructor. - */ - - public static boolean updateSetting(byte[] contractAddress, long consumeUserResourcePercent, - String priKey, byte[] ownerAddress, WalletGrpc - .WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - UpdateSettingContract.Builder builder = UpdateSettingContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - - UpdateSettingContract updateSettingContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateSetting(updateSettingContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return false; - } - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean updateSettingWithPermissionId(byte[] contractAddress, - long consumeUserResourcePercent, String priKey, byte[] ownerAddress, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - UpdateSettingContract.Builder builder = UpdateSettingContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - - UpdateSettingContract updateSettingContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateSetting(updateSettingContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return false; - } - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean updateEnergyLimitWithPermissionId(byte[] contractAddress, - long originEnergyLimit, String priKey, byte[] ownerAddress, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - UpdateEnergyLimitContract.Builder builder = UpdateEnergyLimitContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setOriginEnergyLimit(originEnergyLimit); - - UpdateEnergyLimitContract updateEnergyLimitContract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull - .updateEnergyLimit(updateEnergyLimitContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return false; - } - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static String triggerContract(byte[] contractAddress, String method, String argsStr, - Boolean isHex, long callValue, long feeLimit, byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - return triggerContract(contractAddress, method, argsStr, isHex, callValue, feeLimit, - "0", 0, ownerAddress, priKey, blockingStubFull, permissionKeyString); - } - - /** - * constructor. - */ - - public static String triggerContract(byte[] contractAddress, String method, String argsStr, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.triggerContract(triggerContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - /** - * constructor. - */ - - public static Boolean exchangeCreate(byte[] firstTokenId, long firstTokenBalance, - byte[] secondTokenId, long secondTokenBalance, byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ExchangeCreateContract.Builder builder = Contract.ExchangeCreateContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setFirstTokenId(ByteString.copyFrom(firstTokenId)) - .setFirstTokenBalance(firstTokenBalance) - .setSecondTokenId(ByteString.copyFrom(secondTokenId)) - .setSecondTokenBalance(secondTokenBalance); - Contract.ExchangeCreateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeCreate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static Boolean injectExchange(long exchangeId, byte[] tokenId, long quant, - byte[] ownerAddress, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ExchangeInjectContract.Builder builder = Contract.ExchangeInjectContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant); - Contract.ExchangeInjectContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeInject(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - public static Optional getExchangeList(WalletGrpc.WalletBlockingStub - blockingStubFull) { - ExchangeList exchangeList = blockingStubFull.listExchanges(EmptyMessage.newBuilder().build()); - return Optional.ofNullable(exchangeList); - } - - /** - * constructor. - */ - - public static boolean exchangeWithdraw(long exchangeId, byte[] tokenId, long quant, - byte[] ownerAddress, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - byte[] owner = ownerAddress; - - Contract.ExchangeWithdrawContract.Builder builder = Contract.ExchangeWithdrawContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant); - Contract.ExchangeWithdrawContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeWithdraw(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static boolean exchangeTransaction(long exchangeId, byte[] tokenId, long quant, - long expected, byte[] ownerAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - byte[] owner = ownerAddress; - - Contract.ExchangeTransactionContract.Builder builder = Contract.ExchangeTransactionContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant) - .setExpected(expected); - Contract.ExchangeTransactionContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeTransaction(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static String deployContractWithConstantParame(String contractName, String abiString, - String code, String constructorStr, String argsStr, String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - return deployContractWithConstantParame(contractName, abiString, code, constructorStr, - argsStr, - data, feeLimit, value, consumeUserResourcePercent, 1000L, "0", 0L, - libraryAddress, priKey, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - - public static String deployContractWithConstantParame(String contractName, String abiString, - String code, String constructorStr, String argsStr, String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - - code += Hex.toHexString(AbiUtil.encodeInput(constructorStr, argsStr)); - byte[] owner = ownerAddress; - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder.setNewContract(builder.build()) - .build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - transaction = signTransaction(ecKey, transaction); - System.out.println( - "txid = " + ByteArray - .toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - byte[] contractAddress = PublicMethed.generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - Return response = broadcastTransaction1(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - //logger.info("brodacast succesfully"); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - - public static Boolean freezeBalanceForReceiver(byte[] addRess, long freezeBalance, - long freezeDuration, int resourceCode, ByteString receiverAddressBytes, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration).setResourceValue(resourceCode); - builder.setReceiverAddress(receiverAddressBytes); - Contract.FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - transaction = TransactionUtils.setTimestamp(transaction); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - private static Permission json2Permission(JSONObject json) { - Permission.Builder permissionBuilder = Permission.newBuilder(); - if (json.containsKey("type")) { - int type = json.getInteger("type"); - permissionBuilder.setTypeValue(type); - } - if (json.containsKey("permission_name")) { - String permissionName = json.getString("permission_name"); - permissionBuilder.setPermissionName(permissionName); - } - if (json.containsKey("threshold")) { - // long threshold = json.getLong("threshold"); - long threshold = Long.parseLong(json.getString("threshold")); - permissionBuilder.setThreshold(threshold); - } - if (json.containsKey("parent_id")) { - int parentId = json.getInteger("parent_id"); - permissionBuilder.setParentId(parentId); - } - if (json.containsKey("operations")) { - byte[] operations = ByteArray.fromHexString(json.getString("operations")); - permissionBuilder.setOperations(ByteString.copyFrom(operations)); - } - if (json.containsKey("keys")) { - JSONArray keys = json.getJSONArray("keys"); - List keyList = new ArrayList<>(); - for (int i = 0; i < keys.size(); i++) { - Key.Builder keyBuilder = Key.newBuilder(); - JSONObject key = keys.getJSONObject(i); - String address = key.getString("address"); - // long weight = key.getLong("weight"); - long weight = Long.parseLong(key.getString("weight")); - keyBuilder.setAddress(ByteString.copyFrom(WalletClient.decodeFromBase58Check(address))); - keyBuilder.setWeight(weight); - keyList.add(keyBuilder.build()); - } - permissionBuilder.addAllKeys(keyList); - } - return permissionBuilder.build(); - } - - /** - * constructor. - */ - - public static boolean accountPermissionUpdate(String permissionJson, byte[] owner, String - priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] priKeys) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownersPermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesssPermission = permissions.getJSONObject("witness_permission"); - JSONArray activesPermissions = permissions.getJSONArray("active_permissions"); - - if (ownersPermission != null) { - Permission ownerPermission = json2Permission(ownersPermission); - builder.setOwner(ownerPermission); - } - if (witnesssPermission != null) { - Permission witnessPermission = json2Permission(witnesssPermission); - builder.setWitness(witnessPermission); - } - if (activesPermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activesPermissions.size(); j++) { - JSONObject permission = activesPermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .accountPermissionUpdate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(transaction, blockingStubFull, priKeys); - Return response = broadcastTransaction1(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - public static String accountPermissionUpdateForTransactionId(String permissionJson, - byte[] owner, - String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] priKeys) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownerpermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesspermission = permissions.getJSONObject("witness_permission"); - JSONArray activepermissions = permissions.getJSONArray("active_permissions"); - - if (ownerpermission != null) { - Permission ownerPermission = json2Permission(ownerpermission); - builder.setOwner(ownerPermission); - } - if (witnesspermission != null) { - Permission witnessPermission = json2Permission(witnesspermission); - builder.setWitness(witnessPermission); - } - if (activepermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activepermissions.size(); j++) { - JSONObject permission = activepermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .accountPermissionUpdate(contract); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(transaction, blockingStubFull, priKeys); - Return response = broadcastTransaction1(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - - /** - * constructor. - */ - public static String accountPermissionUpdateForTransactionId1(String permissionJson, - byte[] owner, - String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, String[] priKeys) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownerpermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesspermission = permissions.getJSONObject("witness_permission"); - JSONArray activepermissions = permissions.getJSONArray("active_permissions"); - - if (ownerpermission != null) { - Permission ownerPermission = json2Permission(ownerpermission); - builder.setOwner(ownerPermission); - } - if (witnesspermission != null) { - Permission witnessPermission = json2Permission(witnesspermission); - builder.setWitness(witnessPermission); - } - if (activepermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activepermissions.size(); j++) { - JSONObject permission = activepermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .accountPermissionUpdate(contract); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(transaction, blockingStubFull, priKeys); - Return response = broadcastTransaction1(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - /** - * constructor. - */ - public static Transaction addTransactionSign(Transaction transaction, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Transaction.Builder transactionBuilderSigned = transaction.toBuilder(); - byte[] hash = Sha256Hash.hash(transaction.getRawData().toByteArray()); - - ECDSASignature signature = ecKey.sign(hash); - ByteString bsSign = ByteString.copyFrom(signature.toByteArray()); - transactionBuilderSigned.addSignature(bsSign); - transaction = transactionBuilderSigned.build(); - return transaction; - } - - /** - * constructor. - */ - public static Boolean voteWitness(HashMap witness, byte[] addRess, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - final long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static void printPermissionList(List permissionList) { - String result = "\n"; - result += "["; - result += "\n"; - int i = 0; - for (Permission permission : permissionList) { - result += "permission " + i + " :::"; - result += "\n"; - result += "{"; - result += "\n"; - result += printPermission(permission); - result += "\n"; - result += "}"; - result += "\n"; - i++; - } - result += "]"; - System.out.println(result); - } - - /** - * constructor. - */ - public static String printPermission(Permission permission) { - StringBuffer result = new StringBuffer(); - result.append("permission_type: "); - result.append(permission.getType()); - result.append("\n"); - result.append("permission_id: "); - result.append(permission.getId()); - result.append("\n"); - result.append("permission_name: "); - result.append(permission.getPermissionName()); - result.append("\n"); - result.append("threshold: "); - result.append(permission.getThreshold()); - result.append("\n"); - result.append("parent_id: "); - result.append(permission.getParentId()); - result.append("\n"); - result.append("operations: "); - result.append(ByteArray.toHexString(permission.getOperations().toByteArray())); - result.append("\n"); - if (permission.getKeysCount() > 0) { - result.append("keys:"); - result.append("\n"); - result.append("["); - result.append("\n"); - for (Key key : permission.getKeysList()) { - result.append(printKey(key)); - } - result.append("]"); - result.append("\n"); - } - return result.toString(); - } - - /** - * constructor. - */ - public static String printKey(Key key) { - StringBuffer result = new StringBuffer(); - result.append("address: "); - result.append(encode58Check(key.getAddress().toByteArray())); - result.append("\n"); - result.append("weight: "); - result.append(key.getWeight()); - result.append("\n"); - return result.toString(); - } - - /** - * constructor. - */ - public static String encode58Check(byte[] input) { - byte[] hash0 = Sha256Hash.hash(input); - byte[] hash1 = Sha256Hash.hash(hash0); - byte[] inputCheck = new byte[input.length + 4]; - System.arraycopy(input, 0, inputCheck, 0, input.length); - System.arraycopy(hash1, 0, inputCheck, input.length, 4); - return Base58.encode(inputCheck); - } - - /** - * constructor. - */ - public static Transaction sendcoinWithPermissionIdNotSign(byte[] to, long amount, - byte[] owner, - int permissionId, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.createTransaction2(contract); - - Transaction transaction = transactionExtention.getTransaction(); - raw rawData = transaction.getRawData(); - Transaction.Contract contract1 = transactionExtention.getTransaction().getRawData() - .getContractList().get(0); - contract1 = contract1.toBuilder().setPermissionId(permissionId).build(); - rawData = rawData.toBuilder().clearContract().addContract(contract1).build(); - transaction = transaction.toBuilder().setRawData(rawData).build(); - - return transaction; - - } - - /** - * constructor. - */ - public static TransactionSignWeight getTransactionSignWeight(Transaction transaction, - WalletGrpc.WalletBlockingStub blockingStubFull) { - return blockingStubFull.getTransactionSignWeight(transaction); - } - - /** - * constructor. - */ - public static Return broadcastTransaction1(Transaction transaction, - WalletGrpc.WalletBlockingStub blockingStubFull) { - - return PublicMethed.broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static boolean accountPermissionUpdateWithPermissionId(String permissionJson, - byte[] owner, - String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, String[] priKeys) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownersPermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesssPermission = permissions.getJSONObject("witness_permission"); - JSONArray activesPermissions = permissions.getJSONArray("active_permissions"); - - if (ownersPermission != null) { - Permission ownerPermission = json2Permission(ownersPermission); - builder.setOwner(ownerPermission); - } - if (witnesssPermission != null) { - Permission witnessPermission = json2Permission(witnesssPermission); - builder.setWitness(witnessPermission); - } - if (activesPermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activesPermissions.size(); j++) { - JSONObject permission = activesPermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .accountPermissionUpdate(contract); - - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - - Transaction transaction = transactionExtention.getTransaction(); - raw rawData = transaction.getRawData(); - Transaction.Contract contract1 = transactionExtention.getTransaction().getRawData() - .getContractList().get(0); - contract1 = contract1.toBuilder().setPermissionId(permissionId).build(); - rawData = rawData.toBuilder().clearContract().addContract(contract1).build(); - transaction = transaction.toBuilder().setRawData(rawData).build(); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(transaction, blockingStubFull, priKeys); - Return response = broadcastTransaction1(transaction, blockingStubFull); - return response.getResult(); - } - - /** - * constructor. - */ - public static Transaction accountPermissionUpdateWithoutSign(String permissionJson, - byte[] owner, - String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] priKeys) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownersPermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesssPermission = permissions.getJSONObject("witness_permission"); - JSONArray activesPermissions = permissions.getJSONArray("active_permissions"); - - if (ownersPermission != null) { - Permission ownerPermission = json2Permission(ownersPermission); - builder.setOwner(ownerPermission); - } - if (witnesssPermission != null) { - Permission witnessPermission = json2Permission(witnesssPermission); - builder.setWitness(witnessPermission); - } - if (activesPermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activesPermissions.size(); j++) { - JSONObject permission = activesPermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .accountPermissionUpdate(contract); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transaction; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - return transaction; - } - - /** - * constructor. - */ - public static Transaction addTransactionSignWithPermissionId(Transaction transaction, - String priKey, int permissionId, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - - //transaction = setPermissionId(transaction, permissionId); - Transaction.raw.Builder raw = transaction.getRawData().toBuilder(); - Transaction.Contract.Builder contract = raw.getContract(0).toBuilder() - .setPermissionId(permissionId); - raw.clearContract(); - raw.addContract(contract); - transaction = transaction.toBuilder().setRawData(raw).build(); - - Transaction.Builder transactionBuilderSigned = transaction.toBuilder(); - byte[] hash = Sha256Hash.hash(transaction.getRawData().toByteArray()); - ECKey ecKey = temKey; - ECDSASignature signature = ecKey.sign(hash); - ByteString bsSign = ByteString.copyFrom(signature.toByteArray()); - transactionBuilderSigned.addSignature(bsSign); - transaction = transactionBuilderSigned.build(); - return transaction; - } - - /** - * constructor. - */ - public static Transaction setPermissionId(Transaction transaction, int permissionId) - throws CancelException { - if (transaction.getSignatureCount() != 0 - || transaction.getRawData().getContract(0).getPermissionId() != 0) { - return transaction; - } - if (permissionId < 0) { - throw new CancelException("User cancelled"); - } - if (permissionId != 0) { - Transaction.raw.Builder raw = transaction.getRawData().toBuilder(); - Transaction.Contract.Builder contract = raw.getContract(0).toBuilder() - .setPermissionId(permissionId); - raw.clearContract(); - raw.addContract(contract); - transaction = transaction.toBuilder().setRawData(raw).build(); - } - return transaction; - } - - /** - * constructor. - */ - public static int getActivePermissionKeyCount(List permissionList) { - int permissionCount = 0; - for (Permission permission : permissionList) { - permissionCount += permission.getKeysCount(); - } - return permissionCount; - } - - /** - * constructor. - */ - public static Boolean sendcoinWithPermissionId(byte[] to, long amount, byte[] owner, - int permissionId, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.createTransaction2(contract); - - Transaction transaction = transactionExtention.getTransaction(); - raw rawData = transaction.getRawData(); - Transaction.Contract contract1 = transactionExtention.getTransaction().getRawData() - .getContractList().get(0); - contract1 = contract1.toBuilder().setPermissionId(permissionId).build(); - rawData = rawData.toBuilder().clearContract().addContract(contract1).build(); - transaction = transaction.toBuilder().setRawData(rawData).build(); - transactionExtention = transactionExtention.toBuilder().setTransaction(transaction).build(); - - if (transactionExtention == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return null; - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - - } - - /** - * constructor. - */ - public static void recoverWitnessPermission(String - ownerKey, List ownerPermissionKeys, - WalletGrpc.WalletBlockingStub blockingStubFull) { - - PublicMethed.printAddress(ownerKey); - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - } - - /** - * constructor. - */ - public static String getOperations(Integer[] ints) { - List list = new ArrayList<>(Arrays.asList(ints)); - byte[] operations = new byte[32]; - list.forEach(e -> { - operations[e / 8] |= (1 << e % 8); - }); - - System.out.println(ByteArray.toHexString(operations)); - return ByteArray.toHexString(operations); - } - - /** - * constructor. - */ - public static GrpcAPI.Return accountPermissionUpdateForResponse(String permissionJson, - byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] priKeys) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - JSONObject permissions = JSONObject.parseObject(permissionJson); - JSONObject ownersPermission = permissions.getJSONObject("owner_permission"); - JSONObject witnesssPermission = permissions.getJSONObject("witness_permission"); - JSONArray activesPermissions = permissions.getJSONArray("active_permissions"); - - if (ownersPermission != null) { - Permission ownerPermission = json2Permission(ownersPermission); - builder.setOwner(ownerPermission); - } - if (witnesssPermission != null) { - Permission witnessPermission = json2Permission(witnesssPermission); - builder.setWitness(witnessPermission); - } - if (activesPermissions != null) { - List activePermissionList = new ArrayList<>(); - for (int j = 0; j < activesPermissions.size(); j++) { - JSONObject permission = activesPermissions.getJSONObject(j); - activePermissionList.add(json2Permission(permission)); - } - builder.addAllActives(activePermissionList); - } - builder.setOwnerAddress(ByteString.copyFrom(owner)); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .accountPermissionUpdate(contract); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return ret; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(transaction, blockingStubFull, priKeys); - Return response = broadcastTransaction1(transaction, blockingStubFull); - return response; - } - - /** - * constructor. - */ - public static void recoverAccountPermission(String - ownerKey, List ownerPermissionKeys, - WalletGrpc.WalletBlockingStub blockingStubFull) { - - PublicMethed.printAddress(ownerKey); - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - } - - /** - * constructor. - */ - public static Transaction sendcoin2(byte[] to, long amount, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - return null; - } - return transaction; - - } - - /** - * constructor. - */ - public static Protocol.Transaction createFakeTransaction(byte[] toAddrss, Long amount, - byte[] fromAddress) { - - Contract.TransferContract contract = Contract.TransferContract.newBuilder() - .setOwnerAddress(ByteString.copyFrom(fromAddress)) - .setToAddress(ByteString.copyFrom(toAddrss)) - .setAmount(amount) - .build(); - Protocol.Transaction transaction = createTransaction(contract, ContractType.TransferContract); - - return transaction; - } - - /** - * constructor. - */ - private static Transaction setReference(Transaction transaction, long blockNum, - byte[] blockHash) { - byte[] refBlockNum = ByteArray.fromLong(blockNum); - Transaction.raw rawData = transaction.getRawData().toBuilder() - .setRefBlockHash(ByteString.copyFrom(blockHash)) - .setRefBlockBytes(ByteString.copyFrom(refBlockNum)) - .build(); - return transaction.toBuilder().setRawData(rawData).build(); - } - - /** - * constructor. - */ - public static Transaction setExpiration(Transaction transaction, long expiration) { - Transaction.raw rawData = transaction.getRawData().toBuilder().setExpiration(expiration) - .build(); - return transaction.toBuilder().setRawData(rawData).build(); - } - - /** - * constructor. - */ - public static Transaction createTransaction(com.google.protobuf.Message message, - ContractType contractType) { - Transaction.raw.Builder transactionBuilder = Transaction.raw.newBuilder().addContract( - Transaction.Contract.newBuilder().setType(contractType).setParameter( - Any.pack(message)).build()); - - Transaction transaction = Transaction.newBuilder().setRawData(transactionBuilder.build()) - .build(); - - long time = System.currentTimeMillis(); - AtomicLong count = new AtomicLong(); - long geTime = count.incrementAndGet() + time; - String ref = "" + geTime; - - transaction = setReference(transaction, geTime, ByteArray.fromString(ref)); - - transaction = setExpiration(transaction, geTime); - - return transaction; - } - - /** - * constructor. - */ - - public static String triggerContractWithPermissionId(byte[] contractAddress, String method, - String argsStr, - Boolean isHex, long callValue, long feeLimit, String tokenId, long tokenValue, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString, - int permissionId) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong(tokenId)); - builder.setCallTokenValue(tokenValue); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.triggerContract(triggerContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - /** - * constructor. - */ - - public static byte[] generateContractAddress(Transaction trx, byte[] owneraddress) { - - // get owner address - // this address should be as same as the onweraddress in trx, DONNOT modify it - byte[] ownerAddress = owneraddress; - - // get tx hash - byte[] txRawDataHash = Sha256Hash.of(trx.getRawData().toByteArray()).getBytes(); - - // combine - byte[] combined = new byte[txRawDataHash.length + ownerAddress.length]; - System.arraycopy(txRawDataHash, 0, combined, 0, txRawDataHash.length); - System.arraycopy(ownerAddress, 0, combined, txRawDataHash.length, ownerAddress.length); - - return Hash.sha3omit12(combined); - - } - - /** - * constructor. - */ - - public static byte[] deployContractWithPermissionId(String contractName, String abiString, - String code, - String data, Long feeLimit, long value, - long consumeUserResourcePercent, long originEnergyLimit, String tokenId, long tokenValue, - String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString, - int permissionId) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(originEnergyLimit); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(tokenValue); - contractBuilder.setTokenId(Long.parseLong(tokenId)); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - byte[] contractAddress = generateContractAddress(transactionExtention.getTransaction(), owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - System.out.println( - "txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - contractAddress = generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - - GrpcAPI.Return response = broadcastTransaction1(transaction, blockingStubFull); - if (response.getResult() == false) { - return null; - } else { - //logger.info("brodacast succesfully"); - return contractAddress; - } - } - - - /** - * constructor. - */ - public static byte[] deployContract1(String contractName, String abiString, String code, - String data, Long feeLimit, long value, - long consumeUserResourcePercent, String libraryAddress, String priKey, byte[] ownerAddress, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - SmartContract.ABI abi = jsonStr2Abi(abiString); - if (abi == null) { - logger.error("abi is null"); - return null; - } - //byte[] codeBytes = Hex.decode(code); - SmartContract.Builder builder = SmartContract.newBuilder(); - builder.setName(contractName); - builder.setOriginAddress(ByteString.copyFrom(owner)); - builder.setAbi(abi); - builder.setConsumeUserResourcePercent(consumeUserResourcePercent); - builder.setOriginEnergyLimit(1000L); - - if (value != 0) { - - builder.setCallValue(value); - } - - byte[] byteCode; - if (null != libraryAddress) { - byteCode = replaceLibraryAddress(code, libraryAddress); - } else { - byteCode = Hex.decode(code); - } - builder.setBytecode(ByteString.copyFrom(byteCode)); - - Builder contractBuilder = CreateSmartContract.newBuilder(); - contractBuilder.setOwnerAddress(ByteString.copyFrom(owner)); - contractBuilder.setCallTokenValue(0L); - contractBuilder.setTokenId(Long.parseLong("0")); - CreateSmartContract contractDeployContract = contractBuilder - .setNewContract(builder.build()).build(); - - TransactionExtention transactionExtention = blockingStubFull - .deployContract(contractDeployContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create trx failed!"); - if (transactionExtention != null) { - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - } - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - - byte[] contractAddress = PublicMethed.generateContractAddress( - transactionExtention.getTransaction(), owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - System.out.println( - "txid = " + ByteArray - .toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray()))); - contractAddress = PublicMethed.generateContractAddress(transaction, owner); - System.out.println( - "Your smart contract address will be: " + WalletClient.encode58Check(contractAddress)); - broadcastTransaction(transaction, blockingStubFull); - return contractAddress; - } - - /** - * constructor. - */ - public static String triggerContract1(byte[] contractAddress, String method, String argsStr, - Boolean isHex, long callValue, long feeLimit, byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - if (argsStr.equalsIgnoreCase("#")) { - logger.info("argsstr is #"); - argsStr = ""; - } - - byte[] owner = ownerAddress; - byte[] input = Hex.decode(AbiUtil.parseMethod(method, argsStr, isHex)); - - Contract.TriggerSmartContract.Builder builder = Contract.TriggerSmartContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - builder.setData(ByteString.copyFrom(input)); - builder.setCallValue(callValue); - builder.setTokenId(Long.parseLong("0")); - builder.setCallTokenValue(0L); - Contract.TriggerSmartContract triggerContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull.triggerContract(triggerContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return null; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return null; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - rawBuilder.setFeeLimit(feeLimit); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return null; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return null; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return null; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - broadcastTransaction(transaction, blockingStubFull); - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - - /** - * constructor. - */ - - public static boolean updateAccountWithPermissionId(byte[] addressBytes, byte[] accountNameBytes, - String - priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(addressBytes); - ByteString bsAccountName = ByteString.copyFrom(accountNameBytes); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - Contract.AccountUpdateContract contract = builder.build(); - Transaction transaction = blockingStubFull.updateAccount(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - - /** - * constructor. - */ - - public static String transferAssetForTransactionId1(byte[] to, byte[] assertName, long amount, - byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - logger.info("transaction == null"); - } else { - logger.info("transaction.getRawData().getContractCount() == 0"); - } - return null; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - boolean result = broadcastTransaction(transaction, blockingStubFull); - if (result == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } - - - /** - * constructor. - */ - - public static Boolean freezeBalanceGetEnergyWithPermissionId(byte[] addRess, long freezeBalance, - long freezeDuration, int resourceCode, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration).setResourceValue(resourceCode); - - Contract.FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = TransactionUtils.setTimestamp(transaction); - - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - - /** - * constructor. - */ - - public static Boolean freezeBalanceForReceiverWithPermissionId(byte[] addRess, long freezeBalance, - long freezeDuration, int resourceCode, ByteString receiverAddressBytes, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration).setResourceValue(resourceCode); - builder.setReceiverAddress(receiverAddressBytes); - Contract.FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = TransactionUtils.setTimestamp(transaction); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - - /** - * constructor. - */ - - public static boolean createAccount1(byte[] ownerAddress, byte[] newAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.AccountCreateContract.Builder builder = Contract.AccountCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setAccountAddress(ByteString.copyFrom(newAddress)); - Contract.AccountCreateContract contract = builder.build(); - Transaction transaction = blockingStubFull.createAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - - } - - /** - * constructor. - */ - - public static boolean setAccountId1(byte[] accountIdBytes, byte[] ownerAddress, String priKey, - int permissionId, WalletGrpc.WalletBlockingStub blockingStubFull, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - Contract.SetAccountIdContract.Builder builder = Contract.SetAccountIdContract.newBuilder(); - ByteString bsAddress = ByteString.copyFrom(owner); - ByteString bsAccountId = ByteString.copyFrom(accountIdBytes); - builder.setAccountId(bsAccountId); - builder.setOwnerAddress(bsAddress); - Contract.SetAccountIdContract contract = builder.build(); - Transaction transaction = blockingStubFull.setAccountId(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - return broadcastTransaction(transaction, blockingStubFull); - //Return response = broadcastTransaction1(transaction, blockingStubFull); - //if (response.getResult() == false) { - // logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - // return false; - //} else { - // return true; - //} - //return response.getResult(); - } - - - /** - * constructor. - */ - public static Boolean voteWitnessWithPermissionId(HashMap witness, byte[] addRess, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - final long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static String createAssetIssueForTransactionId1(byte[] address, String name, - Long totalSupply, - Integer trxNum, Integer icoNum, Long startTime, Long endTime, Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return null; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - boolean result = broadcastTransaction(transaction, blockingStubFull); - if (result == false) { - return null; - } else { - return ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData().toByteArray())); - } - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } - - /** - * constructor. - */ - - public static Boolean injectExchange1(long exchangeId, byte[] tokenId, long quant, - byte[] ownerAddress, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, - int permissionId, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ExchangeInjectContract.Builder builder = Contract.ExchangeInjectContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant); - Contract.ExchangeInjectContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeInject(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - - /** - * constructor. - */ - - public static boolean exchangeWithdraw1(long exchangeId, byte[] tokenId, long quant, - byte[] ownerAddress, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, - int permissionId, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - byte[] owner = ownerAddress; - - Contract.ExchangeWithdrawContract.Builder builder = Contract.ExchangeWithdrawContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant); - Contract.ExchangeWithdrawContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeWithdraw(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - - /** - * constructor. - */ - - public static boolean exchangeTransaction1(long exchangeId, byte[] tokenId, long quant, - long expected, byte[] ownerAddress, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - byte[] owner = ownerAddress; - - Contract.ExchangeTransactionContract.Builder builder = Contract.ExchangeTransactionContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setExchangeId(exchangeId) - .setTokenId(ByteString.copyFrom(tokenId)) - .setQuant(quant) - .setExpected(expected); - Contract.ExchangeTransactionContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeTransaction(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - - public static Boolean exchangeCreate1(byte[] firstTokenId, long firstTokenBalance, - byte[] secondTokenId, long secondTokenBalance, byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ExchangeCreateContract.Builder builder = Contract.ExchangeCreateContract - .newBuilder(); - builder - .setOwnerAddress(ByteString.copyFrom(owner)) - .setFirstTokenId(ByteString.copyFrom(firstTokenId)) - .setFirstTokenBalance(firstTokenBalance) - .setSecondTokenId(ByteString.copyFrom(secondTokenId)) - .setSecondTokenBalance(secondTokenBalance); - Contract.ExchangeCreateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.exchangeCreate(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static boolean clearContractAbi(byte[] contractAddress, - byte[] ownerAddress, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull, int permissionId, - String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - byte[] owner = ownerAddress; - - Contract.ClearABIContract.Builder builder = Contract.ClearABIContract - .newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setContractAddress(ByteString.copyFrom(contractAddress)); - - Contract.ClearABIContract clearABIContract = builder.build(); - - TransactionExtention transactionExtention = blockingStubFull - .clearContractABI(clearABIContract); - if (transactionExtention == null || !transactionExtention.getResult().getResult()) { - System.out.println("RPC create call trx failed!"); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction.getRetCount() != 0 - && transactionExtention.getConstantResult(0) != null - && transactionExtention.getResult() != null) { - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - return false; - } - - final TransactionExtention.Builder texBuilder = TransactionExtention.newBuilder(); - Transaction.Builder transBuilder = Transaction.newBuilder(); - Transaction.raw.Builder rawBuilder = transactionExtention.getTransaction().getRawData() - .toBuilder(); - transBuilder.setRawData(rawBuilder); - for (int i = 0; i < transactionExtention.getTransaction().getSignatureCount(); i++) { - ByteString s = transactionExtention.getTransaction().getSignature(i); - transBuilder.setSignature(i, s); - } - for (int i = 0; i < transactionExtention.getTransaction().getRetCount(); i++) { - Result r = transactionExtention.getTransaction().getRet(i); - transBuilder.setRet(i, r); - } - texBuilder.setTransaction(transBuilder); - texBuilder.setResult(transactionExtention.getResult()); - texBuilder.setTxid(transactionExtention.getTxid()); - transactionExtention = texBuilder.build(); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - try { - transaction = setPermissionId(transaction, permissionId); - } catch (CancelException e) { - e.printStackTrace(); - } - transaction = signTransaction(transaction, blockingStubFull, permissionKeyString); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - return broadcastTransaction(transaction, blockingStubFull); - } - - /** - * constructor. - */ - public static boolean sendShieldCoin(byte[] publicZenTokenOwnerAddress, - long fromAmount,ShieldAddressInfo shieldAddressInfo, - NoteTx noteTx,List shieldOutputList, - byte[] publicZenTokenToAddress, long toAmount, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] permissionKeyString) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - PrivateParameters.Builder builder = PrivateParameters.newBuilder(); - if (!ByteUtil.isNullOrZeroArray(publicZenTokenOwnerAddress)) { - builder.setTransparentFromAddress(ByteString.copyFrom(publicZenTokenOwnerAddress)); - builder.setFromAmount(fromAmount); - } - if (!ByteUtil.isNullOrZeroArray(publicZenTokenToAddress)) { - builder.setTransparentToAddress(ByteString.copyFrom(publicZenTokenToAddress)); - builder.setToAmount(toAmount); - } - - if (shieldAddressInfo != null) { - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(noteTx.getTxid().toByteArray())); - outPointBuild.setIndex(noteTx.getIndex()); - request.addOutPoints(outPointBuild.build()); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - - //String shieldAddress = noteInfo.getPaymentAddress(); - //ShieldAddressInfo addressInfo = - // shieldWrapper.getShieldAddressInfoMap().get(shieldAddress); - SpendingKey spendingKey = new SpendingKey(shieldAddressInfo.getSk()); - try { - ExpandedSpendingKey expandedSpendingKey = spendingKey.expandedSpendingKey(); - builder.setAsk(ByteString.copyFrom(expandedSpendingKey.getAsk())); - builder.setNsk(ByteString.copyFrom(expandedSpendingKey.getNsk())); - builder.setOvk(ByteString.copyFrom(expandedSpendingKey.getOvk())); - } catch (Exception e) { - System.out.println(e); - } - - - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(shieldAddressInfo.getAddress()); - noteBuild.setValue(noteTx.getNote().getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteTx.getNote().getRcm().toByteArray())); - noteBuild.setMemo(ByteString.copyFrom(noteTx.getNote().getMemo().toByteArray())); - - - - //System.out.println("address " + noteInfo.getPaymentAddress()); - //System.out.println("value " + noteInfo.getValue()); - //System.out.println("rcm " + ByteArray.toHexString(noteInfo.getR())); - //System.out.println("trxId " + noteInfo.getTrxId()); - //System.out.println("index " + noteInfo.getIndex()); - //System.out.println("meno " + new String(noteInfo.getMemo())); - - SpendNote.Builder spendNoteBuilder = SpendNote.newBuilder(); - spendNoteBuilder.setNote(noteBuild.build()); - try { - spendNoteBuilder.setAlpha(ByteString.copyFrom(org.tron.core.zen.note.Note.generateR())); - } catch (Exception e) { - System.out.println(e); - } - - IncrementalMerkleVoucherInfo merkleVoucherInfo = blockingStubFull - .getMerkleTreeVoucherInfo(request.build()); - spendNoteBuilder.setVoucher(merkleVoucherInfo.getVouchers(0)); - spendNoteBuilder.setPath(merkleVoucherInfo.getPaths(0)); - - builder.addShieldedSpends(spendNoteBuilder.build()); - - } else { - byte[] ovk = ByteArray - .fromHexString("030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d"); - builder.setOvk(ByteString.copyFrom(ovk)); - } - - if (shieldOutputList.size() > 0) { - for (int i = 0; i < shieldOutputList.size(); ++i) { - builder - .addShieldedReceives(ReceiveNote.newBuilder().setNote(shieldOutputList.get(i)).build()); - } - } - - TransactionExtention transactionExtention = blockingStubFull - .createShieldedTransaction(builder.build()); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - Any any = transaction.getRawData().getContract(0).getParameter(); - - try { - Contract.ShieldedTransferContract shieldedTransferContract = - any.unpack(Contract.ShieldedTransferContract.class); - if (shieldedTransferContract.getFromAmount() > 0 - || fromAmount == 321321) { - transaction = signTransactionForShield(transaction,blockingStubFull,permissionKeyString); - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - } else { - System.out.println( - "trigger txid = " + ByteArray.toHexString(Sha256Hash.hash(transaction.getRawData() - .toByteArray()))); - } - } catch (Exception e) { - System.out.println(e); - } - return broadcastTransaction(transaction, blockingStubFull); - } - - - /** - * constructor. - */ - private static Transaction signTransactionForShield(Transaction transaction, - WalletGrpc.WalletBlockingStub blockingStubFull, String[] priKeys) { - /* if (transaction.getRawData().getTimestamp() == 0) { - transaction = TransactionUtils.setTimestamp(transaction); - } - - long currentTime = System.currentTimeMillis();//*1000000 + System.nanoTime()%1000000; - Transaction.Builder builder = transaction.toBuilder(); - org.tron.protos.Protocol.Transaction.raw.Builder rowBuilder = transaction.getRawData() - .toBuilder(); - rowBuilder.setTimestamp(currentTime); - builder.setRawData(rowBuilder.build()); - transaction = builder.build();*/ - - for (int i = 0; i < priKeys.length; i += 1) { - String priKey = priKeys[i]; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - transaction = TransactionUtils.sign(transaction, ecKey); - TransactionSignWeight weight = blockingStubFull.getTransactionSignWeight(transaction); - if (weight.getResult().getCode() - == TransactionSignWeight.Result.response_code.ENOUGH_PERMISSION) { - break; - } - if (weight.getResult().getCode() - == TransactionSignWeight.Result.response_code.NOT_ENOUGH_PERMISSION) { - continue; - } - } - logger.info("Sign transaction:" + transaction.toString()); - return transaction; - } - - -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/Retry.java b/src/test/java/stest/tron/wallet/common/client/utils/Retry.java deleted file mode 100644 index 8c9779504f9..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/Retry.java +++ /dev/null @@ -1,50 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import org.testng.IRetryAnalyzer; -import org.testng.ITestResult; - -public class Retry implements IRetryAnalyzer { - - private int retryCount = 0; - private int maxRetryCount = 2; - - // Below method returns 'true' if the test method has to be retried else 'false' - //and it takes the 'Result' as parameter of the test method that just ran - - /** - * constructor. - */ - - public boolean retry(ITestResult result) { - if (retryCount < maxRetryCount) { - System.out.println("Retrying test " + result.getName() + " with status " - + getResultStatusName(result.getStatus()) + " for the " + (retryCount + 1) + " time(s)."); - retryCount++; - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return true; - } - return false; - } - - /** - * constructor. - */ - - public String getResultStatusName(int status) { - String resultName = null; - if (status == 1) { - resultName = "SUCCESS"; - } - if (status == 2) { - resultName = "FAILURE"; - } - if (status == 3) { - resultName = "SKIP"; - } - return resultName; - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/common/client/utils/RetryListener.java b/src/test/java/stest/tron/wallet/common/client/utils/RetryListener.java deleted file mode 100644 index 1fb49d3ec68..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/RetryListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.testng.IAnnotationTransformer; -import org.testng.IRetryAnalyzer; -import org.testng.annotations.ITestAnnotation; - -public class RetryListener implements IAnnotationTransformer { - - @Override - public void transform(ITestAnnotation testannotation, Class testClass, - Constructor testConstructor, Method testMethod) { - IRetryAnalyzer retry = testannotation.getRetryAnalyzer(); - - if (retry == null) { - testannotation.setRetryAnalyzer(Retry.class); - } - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/Sha256Hash.java b/src/test/java/stest/tron/wallet/common/client/utils/Sha256Hash.java deleted file mode 100644 index d5a87d05c7e..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/Sha256Hash.java +++ /dev/null @@ -1,307 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -/* - * Copyright 2011 Google Inc. - * Copyright 2014 Andreas Schildbach - * - * 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. - */ - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.io.ByteStreams; -import com.google.common.primitives.Ints; -import com.google.common.primitives.Longs; -import com.google.protobuf.ByteString; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.Serializable; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import org.tron.common.utils.ByteArray; - - -/** - * A Sha256Hash just wraps a byte[] so that equals and hashcode work correctly, allowing it to be - * used as keys in a map. It also checks that the length is correct and provides a bit more type - * safety. - */ -public class Sha256Hash implements Serializable, Comparable { - - public static final int LENGTH = 32; // bytes - public static final Sha256Hash ZERO_HASH = wrap(new byte[LENGTH]); - - private final byte[] bytes; - - private long blockNum; - - - private byte[] generateBlockId(long blockNum, Sha256Hash blockHash) { - byte[] numBytes = Longs.toByteArray(blockNum); - byte[] hash = blockHash.getBytes(); - System.arraycopy(numBytes, 0, hash, 0, 8); - return hash; - } - - private byte[] generateBlockId(long blockNum, byte[] blockHash) { - byte[] numBytes = Longs.toByteArray(blockNum); - byte[] hash = blockHash; - System.arraycopy(numBytes, 0, hash, 0, 8); - return hash; - } - - public long getBlockNum() { - return blockNum; - } - - /** - * constructor. - */ - - public Sha256Hash(long num, byte[] hash) { - byte[] rawHashBytes = this.generateBlockId(num, hash); - checkArgument(rawHashBytes.length == LENGTH); - this.bytes = rawHashBytes; - this.blockNum = num; - } - - /** - * constructor. - */ - - public Sha256Hash(long num, Sha256Hash hash) { - byte[] rawHashBytes = this.generateBlockId(num, hash); - checkArgument(rawHashBytes.length == LENGTH); - this.bytes = rawHashBytes; - this.blockNum = num; - } - - /** - * Use {@link #wrap(byte[])} instead. - */ - @Deprecated - public Sha256Hash(byte[] rawHashBytes) { - checkArgument(rawHashBytes.length == LENGTH); - this.bytes = rawHashBytes; - } - - /** - * Creates a new instance that wraps the given hash value. - * - * @param rawHashBytes the raw hash bytes to wrap - * @return a new instance - * @throws IllegalArgumentException if the given array length is not exactly 32 - */ - @SuppressWarnings("deprecation") // the constructor will be made private in the future - public static Sha256Hash wrap(byte[] rawHashBytes) { - return new Sha256Hash(rawHashBytes); - } - - public static Sha256Hash wrap(ByteString rawHashByteString) { - return wrap(rawHashByteString.toByteArray()); - } - - /** - * Use {@link #of(byte[])} instead: this old name is ambiguous. - */ - @Deprecated - public static Sha256Hash create(byte[] contents) { - return of(contents); - } - - /** - * Creates a new instance containing the calculated (one-time) hash of the given bytes. - * - * @param contents the bytes on which the hash value is calculated - * @return a new instance containing the calculated (one-time) hash - */ - public static Sha256Hash of(byte[] contents) { - return wrap(hash(contents)); - } - - /** - * Creates a new instance containing the calculated (one-time) hash of the given file's contents. - * The file contents are read fully into memory, so this method should only be used with small - * files. - * - * @param file the file on which the hash value is calculated - * @return a new instance containing the calculated (one-time) hash - * @throws IOException if an error occurs while reading the file - */ - public static Sha256Hash of(File file) throws IOException { - - try (FileInputStream in = new FileInputStream(file)) { - return of(ByteStreams.toByteArray(in)); - } - } - - /** - * Use {@link #twiceOf(byte[])} instead: this old name is ambiguous. - */ - @Deprecated - public static Sha256Hash createDouble(byte[] contents) { - return twiceOf(contents); - } - - /** - * Creates a new instance containing the hash of the calculated hash of the given bytes. - * - * @param contents the bytes on which the hash value is calculated - * @return a new instance containing the calculated (two-time) hash - */ - public static Sha256Hash twiceOf(byte[] contents) { - return wrap(hashTwice(contents)); - } - - /** - * Returns a new SHA-256 MessageDigest instance. This is a convenience method which wraps the - * checked exception that can never occur with a RuntimeException. - * - * @return a new SHA-256 MessageDigest instance - */ - public static MessageDigest newDigest() { - try { - return MessageDigest.getInstance("SHA-256"); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); // Can't happen. - } - } - - /** - * Calculates the SHA-256 hash of the given bytes. - * - * @param input the bytes to hash - * @return the hash (in big-endian order) - */ - public static byte[] hash(byte[] input) { - return hash(input, 0, input.length); - } - - /** - * Calculates the SHA-256 hash of the given byte range. - * - * @param input the array containing the bytes to hash - * @param offset the offset within the array of the bytes to hash - * @param length the number of bytes to hash - * @return the hash (in big-endian order) - */ - public static byte[] hash(byte[] input, int offset, int length) { - MessageDigest digest = newDigest(); - digest.update(input, offset, length); - return digest.digest(); - } - - /** - * Calculates the SHA-256 hash of the given bytes, and then hashes the resulting hash again. - * - * @param input the bytes to hash - * @return the double-hash (in big-endian order) - */ - public static byte[] hashTwice(byte[] input) { - return hashTwice(input, 0, input.length); - } - - /** - * Calculates the SHA-256 hash of the given byte range, and then hashes the resulting hash again. - * - * @param input the array containing the bytes to hash - * @param offset the offset within the array of the bytes to hash - * @param length the number of bytes to hash - * @return the double-hash (in big-endian order) - */ - public static byte[] hashTwice(byte[] input, int offset, int length) { - MessageDigest digest = newDigest(); - digest.update(input, offset, length); - return digest.digest(digest.digest()); - } - - /** - * Calculates the hash of hash on the given byte ranges. This is equivalent to concatenating the - * two ranges and then passing the result to {@link #hashTwice(byte[])}. - */ - public static byte[] hashTwice(byte[] input1, int offset1, int length1, - byte[] input2, int offset2, int length2) { - MessageDigest digest = newDigest(); - digest.update(input1, offset1, length1); - digest.update(input2, offset2, length2); - return digest.digest(digest.digest()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || !(o instanceof Sha256Hash)) { - return false; - } - return Arrays.equals(bytes, ((Sha256Hash) o).bytes); - } - - @Override - public String toString() { - return ByteArray.toHexString(bytes); - } - - /** - * Returns the last four bytes of the wrapped hash. This should be unique enough to be a suitable - * hash code even for blocks, where the goal is to try and get the first bytes to be zeros (i.e. - * the value as a big integer lower than the target value). - */ - @Override - public int hashCode() { - // Use the last 4 bytes, not the first 4 which are often zeros in Bitcoin. - return Ints - .fromBytes(bytes[LENGTH - 4], bytes[LENGTH - 3], bytes[LENGTH - 2], bytes[LENGTH - 1]); - } - - /** - * Returns the bytes interpreted as a positive integer. - */ - public BigInteger toBigInteger() { - return new BigInteger(1, bytes); - } - - /** - * Returns the internal byte array, without defensively copying. Therefore do NOT modify the - * returned array. - */ - public byte[] getBytes() { - return bytes; - } - - /** - * For pb return ByteString. - */ - public ByteString getByteString() { - return ByteString.copyFrom(bytes); - } - - @Override - public int compareTo(final Sha256Hash other) { - for (int i = LENGTH - 1; i >= 0; i--) { - final int thisByte = this.bytes[i] & 0xff; - final int otherByte = other.bytes[i] & 0xff; - if (thisByte > otherByte) { - return 1; - } - if (thisByte < otherByte) { - return -1; - } - } - return 0; - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/ShieldAddressInfo.java b/src/test/java/stest/tron/wallet/common/client/utils/ShieldAddressInfo.java deleted file mode 100644 index fae12525394..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/ShieldAddressInfo.java +++ /dev/null @@ -1,145 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import java.util.Arrays; -import java.util.Optional; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.tron.common.utils.ByteArray; -import org.tron.core.exception.ZksnarkException; -import org.tron.core.zen.address.DiversifierT; -import org.tron.core.zen.address.FullViewingKey; -import org.tron.core.zen.address.IncomingViewingKey; -import org.tron.core.zen.address.KeyIo; -import org.tron.core.zen.address.PaymentAddress; -import org.tron.core.zen.address.SpendingKey; - -@AllArgsConstructor -public class ShieldAddressInfo { - - @Setter - @Getter - public byte[] sk; - @Setter - @Getter - public byte[] ivk; // 256 - @Setter - @Getter - public byte[] ovk; // 256 - @Setter - @Getter - DiversifierT d; - @Setter - @Getter - byte[] pkD; // 256 - - public ShieldAddressInfo(){ - } - - public FullViewingKey getFullViewingKey() throws ZksnarkException { - SpendingKey spendingKey = new SpendingKey(sk); - return spendingKey.fullViewingKey(); - } - - /** - * check parameters. - * @return - */ - public boolean validateCheck() { - try { - SpendingKey spendingKey = new SpendingKey(sk); - FullViewingKey fullViewingKey = spendingKey.fullViewingKey(); - if (!Arrays.equals(fullViewingKey.getOvk(), ovk)) { - System.out.println("ovk check failure!"); - return false; - } - IncomingViewingKey incomingViewingKey = fullViewingKey.inViewingKey(); - if (!Arrays.equals(incomingViewingKey.getValue(), ivk)) { - System.out.println("ivk check failure!"); - return false; - } - Optional optionalPaymentAddress = incomingViewingKey.address(d); - if (!optionalPaymentAddress.isPresent() - || !Arrays.equals(optionalPaymentAddress.get().getPkD(), pkD)) { - System.out.println("pkd check failure!"); - return false; - } - return true; - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - public String getAddress() { - return getShieldAddress(d, pkD); - } - - public static String getShieldAddress(DiversifierT d, byte[] pkD) { - try { - PaymentAddress paymentAddress = new PaymentAddress(d, pkD); - return KeyIo.encodePaymentAddress(paymentAddress); - } catch (Exception e) { - e.printStackTrace(); - } - return ""; - } - - // public static PaymentAddress parseFromShieldAddress(final String shieldAddress) { - // PaymentAddress paymentAddress = null; - // try { - // byte[] byteShield = ByteArray.fromHexString(shieldAddress); - // int lenPkd = byteShield.length - Constant.ZC_DIVERSIFIER_SIZE; - // byte[] d = new byte[Constant.ZC_DIVERSIFIER_SIZE]; - // byte[] pkd = new byte[lenPkd]; - // - // System.arraycopy(byteShield, 0, d, 0, Constant.ZC_DIVERSIFIER_SIZE); - // System.arraycopy(byteShield, Constant.ZC_DIVERSIFIER_SIZE, pkd, 0, lenPkd); - // - // paymentAddress = new PaymentAddress(new DiversifierT(d), pkd); - // } catch (Exception e) { - // System.out.println("parseFromShieldAddress " + shieldAddress + " failure."); - // e.printStackTrace(); - // } - // - // return paymentAddress; - // } - - /** - * format shield address info to a string. - * @return - */ - public String encode() { - String encodeString = ByteArray.toHexString(sk) + ";"; - encodeString += ByteArray.toHexString(ivk); - encodeString += ";"; - encodeString += ByteArray.toHexString(ovk); - encodeString += ";"; - encodeString += ByteArray.toHexString(d.getData()); - encodeString += ";"; - encodeString += ByteArray.toHexString(pkD); - return encodeString; - } - - /** - * constructor. - */ - public boolean decode(final String data) { - String[] sourceStrArray = data.split(";"); - if (sourceStrArray.length != 5) { - System.out.println("len is not right."); - return false; - } - sk = ByteArray.fromHexString(sourceStrArray[0]); - ivk = ByteArray.fromHexString(sourceStrArray[1]); - ovk = ByteArray.fromHexString(sourceStrArray[2]); - d = new DiversifierT(ByteArray.fromHexString(sourceStrArray[3])); - pkD = ByteArray.fromHexString(sourceStrArray[4]); - - if (validateCheck()) { - return true; - } else { - return false; - } - } -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/ShieldNoteInfo.java b/src/test/java/stest/tron/wallet/common/client/utils/ShieldNoteInfo.java deleted file mode 100644 index 8691ac26abc..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/ShieldNoteInfo.java +++ /dev/null @@ -1,81 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.tron.common.utils.ByteArray; - -@AllArgsConstructor -public class ShieldNoteInfo { - - @Setter - @Getter - public long value = 0; - @Setter - @Getter - public String paymentAddress; - @Setter - @Getter - public byte[] r; // 256 - @Setter - @Getter - public String trxId; - @Setter - @Getter - public int index; - @Setter - @Getter - public long noteIndex; - @Setter - @Getter - public byte[] memo; - @Setter - @Getter - public Boolean isSpend; - - public ShieldNoteInfo() { - } - - /** - * format shield note to a string. - */ - public String encode() { - String encodeString = noteIndex + ";"; - encodeString += paymentAddress; - encodeString += ";"; - encodeString += ByteArray.toHexString(r); - encodeString += ";"; - encodeString += trxId; - encodeString += ";"; - encodeString += String.valueOf(value); - encodeString += ";"; - encodeString += String.valueOf(index); - encodeString += ";"; - encodeString += ByteArray.toHexString(memo); - encodeString += ";"; - encodeString += Boolean.valueOf(isSpend); - return encodeString; - } - - /** - * constructor. - */ - public boolean decode(final String data) { - String[] sourceStrArray = data.split(";"); - if (sourceStrArray.length != 8) { - System.out.println("len is not right."); - return false; - } - noteIndex = Long.valueOf(sourceStrArray[0]); - paymentAddress = sourceStrArray[1]; - r = ByteArray.fromHexString(sourceStrArray[2]); - trxId = sourceStrArray[3]; - value = Long.valueOf(sourceStrArray[4]); - index = Integer.valueOf(sourceStrArray[5]); - memo = ByteArray.fromHexString(sourceStrArray[6]); - isSpend = Boolean.valueOf(sourceStrArray[7]); - return true; - } - -} - diff --git a/src/test/java/stest/tron/wallet/common/client/utils/ShieldWrapper.java b/src/test/java/stest/tron/wallet/common/client/utils/ShieldWrapper.java deleted file mode 100644 index ac671e22259..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/ShieldWrapper.java +++ /dev/null @@ -1,443 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import io.netty.util.internal.StringUtil; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicLong; -import lombok.Getter; -import lombok.Setter; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.DecryptNotes.NoteTx; -import org.tron.api.GrpcAPI.IvkDecryptParameters; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.GrpcAPI.NoteParameters; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.SpendResult; -import org.tron.api.WalletGrpc; -import org.tron.common.utils.ByteArray; -import org.tron.protos.Contract.IncrementalMerkleVoucherInfo; -import org.tron.protos.Contract.OutputPoint; -import org.tron.protos.Contract.OutputPointInfo; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; - -//import org.tron.walletserver.WalletApi; -//import stest.tron.wallet.common.client.Parameter.CommonConstant; - -public class ShieldWrapper { - - private static final String PREFIX_FOLDER = "WalletShield"; - private static final String IVK_AND_NUM_FILE_NAME = PREFIX_FOLDER + "/scanblocknumber"; - private static final String UNSPEND_NOTE_FILE_NAME = PREFIX_FOLDER + "/unspendnote"; - private static final String SPEND_NOTE_FILE_NAME = PREFIX_FOLDER + "/spendnote"; - private static final String SHIELD_ADDRESS_FILE_NAME = PREFIX_FOLDER + "/shieldaddress"; - - - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private ManagedChannel channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - private WalletGrpc.WalletBlockingStub blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - //Wallet wallet = new Wallet(); - - //private WalletApi wallet; - private static AtomicLong nodeIndex = new AtomicLong(0L); - private Thread thread; - - @Setter - @Getter - Map shieldAddressInfoMap = new ConcurrentHashMap(); - @Setter - private boolean resetNote = false; - @Getter - @Setter - public Map ivkMapScanBlockNum = new ConcurrentHashMap(); - @Getter - @Setter - public Map utxoMapNote = new ConcurrentHashMap(); - @Getter - @Setter - public List spendUtxoList = new ArrayList<>(); - - /* public void setWallet(WalletApi walletApi) { - wallet = walletApi; - if (!thread.isAlive()) { - thread.start(); - } - }*/ - - public class scanIvkRunable implements Runnable { - public void run() { - for (;;) { - try { - scanBlockByIvk(); - updateNoteWhetherSpend(); - //wait for 2.5 seconds - for (int i = 0; i < 5; ++i) { - Thread.sleep(500); - if (resetNote) { - resetShieldNote(); - resetNote = false; - System.out.println("Reset shield note success!"); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - - private void resetShieldNote() { - ivkMapScanBlockNum.clear(); - for (Entry entry : getShieldAddressInfoMap().entrySet()) { - ivkMapScanBlockNum.put(ByteArray.toHexString(entry.getValue().getIvk()), 0L); - } - - utxoMapNote.clear(); - spendUtxoList.clear(); - - ZenUtils.clearFile(IVK_AND_NUM_FILE_NAME); - ZenUtils.clearFile(UNSPEND_NOTE_FILE_NAME); - ZenUtils.clearFile(SPEND_NOTE_FILE_NAME); - nodeIndex.set(0L); - - updateIvkAndBlockNumFile(); - } - - private void scanBlockByIvk() { - try { - NumberMessage.Builder builder1 = NumberMessage.newBuilder(); - builder1.setNum(-1); - Block block = blockingStubFull.getBlockByNum(builder1.build()); - if (block != null) { - long blockNum = block.getBlockHeader().toBuilder().getRawData().getNumber(); - for (Entry entry : ivkMapScanBlockNum.entrySet()) { - - long start = entry.getValue(); - long end = start; - while (end < blockNum) { - if (blockNum - start > 1000) { - end = start + 1000; - } else { - end = blockNum; - } - - IvkDecryptParameters.Builder builder = IvkDecryptParameters.newBuilder(); - builder.setStartBlockIndex(start); - builder.setEndBlockIndex(end); - builder.setIvk(ByteString.copyFrom(ByteArray.fromHexString(entry.getKey()))); - DecryptNotes notes = blockingStubFull.scanNoteByIvk(builder.build()); - if (notes != null) { - for (int i = 0; i < notes.getNoteTxsList().size(); ++i) { - NoteTx noteTx = notes.getNoteTxsList().get(i); - ShieldNoteInfo noteInfo = new ShieldNoteInfo(); - noteInfo.setPaymentAddress(noteTx.getNote().getPaymentAddress()); - noteInfo.setR(noteTx.getNote().getRcm().toByteArray()); - noteInfo.setValue(noteTx.getNote().getValue()); - noteInfo.setTrxId(ByteArray.toHexString(noteTx.getTxid().toByteArray())); - noteInfo.setIndex(noteTx.getIndex()); - noteInfo.setNoteIndex(nodeIndex.getAndIncrement()); - noteInfo.setMemo(noteTx.getNote().getMemo().toByteArray()); - - utxoMapNote.put(noteInfo.getNoteIndex(), noteInfo); - } - saveUnspendNoteToFile(); - } - start = end; - } - - ivkMapScanBlockNum.put(entry.getKey(), blockNum); - } - updateIvkAndBlockNumFile(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void updateNoteWhetherSpend() { - try { - for (Entry entry : utxoMapNote.entrySet()) { - ShieldNoteInfo noteInfo = entry.getValue(); - - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(ByteArray.fromHexString(noteInfo.getTrxId()))); - outPointBuild.setIndex(noteInfo.getIndex()); - request.addOutPoints(outPointBuild.build()); - - IncrementalMerkleVoucherInfo merkleVoucherInfo = blockingStubFull.getMerkleTreeVoucherInfo( - request.build()); - if (merkleVoucherInfo.getVouchersCount() > 0) { - ShieldAddressInfo addressInfo = getShieldAddressInfoMap().get( - noteInfo.getPaymentAddress()); - NoteParameters.Builder builder = NoteParameters.newBuilder(); - builder.setAk(ByteString.copyFrom(addressInfo.getFullViewingKey().getAk())); - builder.setNk(ByteString.copyFrom(addressInfo.getFullViewingKey().getNk())); - - Note.Builder noteBuild = Note.newBuilder(); - noteBuild.setPaymentAddress(noteInfo.getPaymentAddress()); - noteBuild.setValue(noteInfo.getValue()); - noteBuild.setRcm(ByteString.copyFrom(noteInfo.getR())); - noteBuild.setMemo(ByteString.copyFrom(noteInfo.getMemo())); - builder.setNote(noteBuild.build()); - //builder.setVoucher(merkleVoucherInfo.getVouchers(0)); - - SpendResult result = blockingStubFull.isSpend(builder.build()); - - - if (result.getResult()) { - spendNote(entry.getKey()); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public boolean init() { - ZenUtils.checkFolderExist(PREFIX_FOLDER); - - loadAddressFromFile(); - loadIvkFromFile(); - loadUnSpendNoteFromFile(); - loadSpendNoteFromFile(); - - thread = new Thread(new scanIvkRunable()); - return true; - } - - /** - * constructor. - */ - public boolean spendNote(long noteIndex) { - ShieldNoteInfo noteInfo = utxoMapNote.get(noteIndex); - if (noteInfo != null) { - utxoMapNote.remove(noteIndex); - spendUtxoList.add(noteInfo); - - saveUnspendNoteToFile(); - saveSpendNoteToFile(noteInfo); - } else { - System.err.println("Find note failure. index:" + noteIndex); - } - return true; - } - - /** - * constructor. - */ - public boolean addNewShieldAddress(final ShieldAddressInfo addressInfo) { - appendAddressInfoToFile(addressInfo); - long blockNum = 0; - try { - NumberMessage.Builder builder1 = NumberMessage.newBuilder(); - builder1.setNum(-1); - Block block = blockingStubFull.getBlockByNum(builder1.build()); - if (block != null) { - blockNum = block.getBlockHeader().toBuilder().getRawData().getNumber(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - ivkMapScanBlockNum.put(ByteArray.toHexString(addressInfo.getIvk()), blockNum); - updateIvkAndBlockNum(ByteArray.toHexString(addressInfo.getIvk()), blockNum); - - return true; - } - - /** - * constructor. - */ - private boolean updateIvkAndBlockNum(final String ivk, long blockNum) { - synchronized (IVK_AND_NUM_FILE_NAME) { - String date = ivk + ";" + blockNum; - ZenUtils.appendToFileTail(IVK_AND_NUM_FILE_NAME, date); - } - return true; - } - - /** - * constructor. - */ - private boolean updateIvkAndBlockNumFile() { - synchronized (IVK_AND_NUM_FILE_NAME) { - ZenUtils.clearFile(IVK_AND_NUM_FILE_NAME); - for (Entry entry : ivkMapScanBlockNum.entrySet()) { - String date = entry.getKey() + ";" + entry.getValue(); - ZenUtils.appendToFileTail(IVK_AND_NUM_FILE_NAME, date); - } - } - return true; - } - - /** - * constructor. - */ - private boolean loadIvkFromFile() { - ivkMapScanBlockNum.clear(); - List list = ZenUtils.getListFromFile(IVK_AND_NUM_FILE_NAME); - for (int i = 0; i < list.size(); ++i) { - String[] sourceStrArray = list.get(i).split(";"); - if (sourceStrArray.length != 2) { - System.err.println("len is not right."); - return false; - } - ivkMapScanBlockNum.put(sourceStrArray[0], Long.valueOf(sourceStrArray[1])); - } - return true; - } - - /** - * get shield address list. - * @return - */ - public List getShieldAddressList() { - List addressList = new ArrayList<>(); - for (Entry entry : shieldAddressInfoMap.entrySet()) { - addressList.add(entry.getKey()); - } - return addressList; - } - - - - /** - * update unspend note. - * @return - */ - private boolean saveUnspendNoteToFile() { - ZenUtils.clearFile(UNSPEND_NOTE_FILE_NAME); - for (Entry entry : utxoMapNote.entrySet()) { - String date = entry.getValue().encode(); - ZenUtils.appendToFileTail(UNSPEND_NOTE_FILE_NAME, date); - } - return true; - } - - /** - * load unspend note from file. - * @return - */ - private boolean loadUnSpendNoteFromFile() { - utxoMapNote.clear(); - - List list = ZenUtils.getListFromFile(UNSPEND_NOTE_FILE_NAME); - for (int i = 0; i < list.size(); ++i) { - ShieldNoteInfo noteInfo = new ShieldNoteInfo(); - noteInfo.decode(list.get(i)); - utxoMapNote.put(noteInfo.getNoteIndex(), noteInfo); - - if (noteInfo.getNoteIndex() > nodeIndex.get()) { - nodeIndex.set(noteInfo.getNoteIndex()); - } - } - return true; - } - - - /** - * append spend note to file tail. - * @return - */ - private boolean saveSpendNoteToFile(ShieldNoteInfo noteInfo) { - String date = noteInfo.encode(); - ZenUtils.appendToFileTail(SPEND_NOTE_FILE_NAME, date); - return true; - } - - /** - * load spend note from file. - * @return - */ - private boolean loadSpendNoteFromFile() { - spendUtxoList.clear(); - List list = ZenUtils.getListFromFile(SPEND_NOTE_FILE_NAME); - for (int i = 0; i < list.size(); ++i) { - ShieldNoteInfo noteInfo = new ShieldNoteInfo(); - noteInfo.decode(list.get(i)); - spendUtxoList.add(noteInfo); - } - return true; - } - - - /** - * load shield address from file. - * @return - */ - public boolean loadAddressFromFile() { - List addressList = ZenUtils.getListFromFile(SHIELD_ADDRESS_FILE_NAME); - - shieldAddressInfoMap.clear(); - for (String addressString : addressList) { - ShieldAddressInfo addressInfo = new ShieldAddressInfo(); - if (addressInfo.decode(addressString)) { - shieldAddressInfoMap.put(addressInfo.getAddress(), addressInfo); - } else { - System.out.println("*******************"); - } - } - return true; - } - - /** - * constructor. - */ - public boolean appendAddressInfoToFile(final ShieldAddressInfo addressInfo) { - String shieldAddress = addressInfo.getAddress(); - if (!StringUtil.isNullOrEmpty(shieldAddress)) { - String addressString = addressInfo.encode(); - ZenUtils.appendToFileTail(SHIELD_ADDRESS_FILE_NAME, addressString); - - shieldAddressInfoMap.put(shieldAddress, addressInfo); - } - return true; - } - - /** - * sort by value of UTXO. - * @return - */ - public List getvalidateSortUtxoList() { - List> list = new ArrayList<>(utxoMapNote.entrySet()); - Collections.sort(list, (Entry o1, Entry o2) -> { - if (o1.getValue().getValue() < o2.getValue().getValue()) { - return 1; - } else { - return -1; - } - }); - - List utxoList = new ArrayList<>(); - for (Map.Entry entry : list) { - String string = entry.getKey() + " " + entry.getValue().getPaymentAddress() + " "; - string += entry.getValue().getValue(); - string += " "; - string += entry.getValue().getTrxId(); - string += " "; - string += entry.getValue().getIndex(); - string += " "; - string += "UnSpend"; - string += " "; - string += ZenUtils.getMemo(entry.getValue().getMemo()); - utxoList.add(string); - } - return utxoList; - } - - -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/TransactionUtils.java b/src/test/java/stest/tron/wallet/common/client/utils/TransactionUtils.java deleted file mode 100644 index c927682e5b9..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/TransactionUtils.java +++ /dev/null @@ -1,221 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -/* - * java-tron is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * java-tron is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import com.google.protobuf.ByteString; -import java.security.SignatureException; -import java.util.Arrays; -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.tron.api.GrpcAPI; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.ECKey.ECDSASignature; -import org.tron.common.utils.Sha256Hash; -//import org.tron.protos.Protocol.DeferredStage; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract; - - -public class TransactionUtils { - - private static final Logger logger = LoggerFactory.getLogger("Transaction"); - private static final int RESERVE_BALANCE = 10; - public static final int NORMALTRANSACTION = 0; - public static final int UNEXECUTEDDEFERREDTRANSACTION = 1; - public static final int EXECUTINGDEFERREDTRANSACTION = 2; - - /** - * constructor. - */ - - public static byte[] getHash(Transaction transaction) { - Transaction.Builder tmp = transaction.toBuilder(); - //tmp.clearId(); - - return Sha256Hash.hash(tmp.build().toByteArray()); - } - - /** - * constructor. - */ - - public static byte[] getOwner(Transaction.Contract contract) { - ByteString owner; - try { - switch (contract.getType()) { - case AccountCreateContract: - owner = contract.getParameter() - .unpack(org.tron.protos.Contract.AccountCreateContract.class).getOwnerAddress(); - break; - case TransferContract: - owner = contract.getParameter().unpack(org.tron.protos.Contract.TransferContract.class) - .getOwnerAddress(); - break; - case TransferAssetContract: - owner = contract.getParameter() - .unpack(org.tron.protos.Contract.TransferAssetContract.class).getOwnerAddress(); - break; - case VoteAssetContract: - owner = contract.getParameter().unpack(org.tron.protos.Contract.VoteAssetContract.class) - .getOwnerAddress(); - break; - case VoteWitnessContract: - owner = contract.getParameter().unpack(org.tron.protos.Contract.VoteWitnessContract.class) - .getOwnerAddress(); - break; - case WitnessCreateContract: - owner = contract.getParameter() - .unpack(org.tron.protos.Contract.WitnessCreateContract.class).getOwnerAddress(); - break; - case AssetIssueContract: - owner = contract.getParameter().unpack(org.tron.protos.Contract.AssetIssueContract.class) - .getOwnerAddress(); - break; - case ParticipateAssetIssueContract: - owner = contract.getParameter() - .unpack(org.tron.protos.Contract.ParticipateAssetIssueContract.class) - .getOwnerAddress(); - break; - case CreateSmartContract: - owner = contract.getParameter().unpack(org.tron.protos.Contract.CreateSmartContract.class) - .getOwnerAddress(); - break; - default: - return null; - } - return owner.toByteArray(); - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } - - /** - * constructor. - */ - - public static String getBase64FromByteString(ByteString sign) { - byte[] r = sign.substring(0, 32).toByteArray(); - byte[] s = sign.substring(32, 64).toByteArray(); - byte v = sign.byteAt(64); - if (v < 27) { - v += 27; //revId -> v - } - ECDSASignature signature = ECDSASignature.fromComponents(r, s, v); - return signature.toBase64(); - } - - /* - * 1. check hash - * 2. check double spent - * 3. check sign - * 4. check balance - */ - - /** - * constructor. - */ - - public static boolean validTransaction(Transaction signedTransaction) { - assert (signedTransaction.getSignatureCount() - == signedTransaction.getRawData().getContractCount()); - List listContract = signedTransaction.getRawData().getContractList(); - byte[] hash = Sha256Hash.hash(signedTransaction.getRawData().toByteArray()); - int count = signedTransaction.getSignatureCount(); - if (count == 0) { - return false; - } - for (int i = 0; i < count; ++i) { - try { - Transaction.Contract contract = listContract.get(i); - byte[] owner = getOwner(contract); - byte[] address = ECKey - .signatureToAddress(hash, getBase64FromByteString(signedTransaction.getSignature(i))); - if (!Arrays.equals(owner, address)) { - return false; - } - } catch (SignatureException e) { - e.printStackTrace(); - return false; - } - } - return true; - } - - /** - * constructor. - */ - - public static Transaction sign(Transaction transaction, ECKey myKey) { - ByteString lockSript = ByteString.copyFrom(myKey.getAddress()); - Transaction.Builder transactionBuilderSigned = transaction.toBuilder(); - - byte[] hash = Sha256Hash.hash(transaction.getRawData().toByteArray()); - List listContract = transaction.getRawData().getContractList(); - for (int i = 0; i < listContract.size(); i++) { - ECDSASignature signature = myKey.sign(hash); - ByteString bsSign = ByteString.copyFrom(signature.toByteArray()); - transactionBuilderSigned.addSignature( - bsSign);//Each contract may be signed with a different private key in the future. - } - - transaction = transactionBuilderSigned.build(); - return transaction; - } - - /** - * constructor. - */ - - public static Transaction setTimestamp(Transaction transaction) { - long currentTime = System.currentTimeMillis();//*1000000 + System.nanoTime()%1000000; - Transaction.Builder builder = transaction.toBuilder(); - org.tron.protos.Protocol.Transaction.raw.Builder rowBuilder = transaction.getRawData() - .toBuilder(); - rowBuilder.setTimestamp(currentTime); - builder.setRawData(rowBuilder.build()); - return builder.build(); - } - - /** - * constructor. - */ - /* public static Transaction setDelaySeconds(Transaction transaction, long delaySeconds) { - DeferredStage deferredStage = transaction.getRawData().toBuilder() - .getDeferredStage().toBuilder().setDelaySeconds(delaySeconds) - .setStage(UNEXECUTEDDEFERREDTRANSACTION).build(); - Transaction.raw rawData = transaction.toBuilder().getRawData() - .toBuilder().setDeferredStage(deferredStage).build(); - return transaction.toBuilder().setRawData(rawData).build(); - }*/ - - /* *//** - * constructor. - *//* - public static GrpcAPI.TransactionExtention setDelaySecondsToExtension(GrpcAPI - .TransactionExtention transactionExtention, long delaySeconds) { - if (delaySeconds == 0) { - return transactionExtention; - } - GrpcAPI.TransactionExtention.Builder builder = transactionExtention.toBuilder(); - - Transaction transaction = setDelaySeconds(transactionExtention.getTransaction(), delaySeconds); - builder.setTransaction(transaction); - - return builder.build(); - }*/ -} diff --git a/src/test/java/stest/tron/wallet/common/client/utils/ZenUtils.java b/src/test/java/stest/tron/wallet/common/client/utils/ZenUtils.java deleted file mode 100644 index 5e5d641b5e3..00000000000 --- a/src/test/java/stest/tron/wallet/common/client/utils/ZenUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -package stest.tron.wallet.common.client.utils; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - -public class ZenUtils { - - public static List getListFromFile(final String fileName) { - List list = new ArrayList<>(); - try { - FileInputStream inputStream = new FileInputStream(fileName); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); - - String str = null; - while ((str = bufferedReader.readLine()) != null) { - System.out.println(str); - list.add(str); - } - inputStream.close(); - bufferedReader.close(); - } catch (Exception e) { - if (e.getMessage() != null) { - System.out.println(e.getMessage()); - } else { - System.out.println(e.getClass()); - } - } - return list; - } - - public static boolean appendToFileTail(final String fileName, final String content) { - BufferedWriter out = null; - try { - out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true))); - out.write(content + "\n"); - out.flush(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return true; - } - - public static void clearFile(String fileName) { - File file = new File(fileName); - try { - if (file.exists()) { - FileWriter fileWriter = new FileWriter(file); - fileWriter.write(""); - fileWriter.flush(); - fileWriter.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void checkFolderExist(final String filePath) { - try { - File file = new File(filePath); - if (file.exists()) { - if (file.isDirectory()) { - return; - } else { - file.delete(); - } - } - file.mkdir(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static String getMemo(byte[] meno) { - int index = meno.length; - for (; index > 0; --index) { - if (meno[index - 1] != 0) { - break; - } - } - - byte[] inputCheck = new byte[index]; - System.arraycopy(meno, 0, inputCheck, 0, index); - return new String(inputCheck, Charset.forName("UTF-8")); - } - - -} diff --git a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage002.java b/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage002.java deleted file mode 100644 index bd69755e8ba..00000000000 --- a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage002.java +++ /dev/null @@ -1,273 +0,0 @@ -package stest.tron.wallet.contract.linkage; - -import static org.tron.protos.Protocol.Transaction.Result.contractResult.SUCCESS_VALUE; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractLinkage002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] linkage002Address = ecKey1.getAddress(); - String linkage002Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(linkage002Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true) - public void updateSetting() { - String sendcoin = PublicMethed - .sendcoinGetTransactionId(linkage002Address, 200000000000L, fromAddress, - testKey002, blockingStubFull); - Account info; - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById0 = null; - infoById0 = PublicMethed.getTransactionInfoById(sendcoin, blockingStubFull); - logger.info("infoById0 " + infoById0.get()); - Assert.assertEquals(ByteArray.toHexString(infoById0.get().getContractResult(0).toByteArray()), - ""); - Assert.assertEquals(infoById0.get().getResult().getNumber(), 0); - Optional ById = PublicMethed.getTransactionById(sendcoin, blockingStubFull); - Assert.assertEquals(ById.get().getRet(0).getContractRet().getNumber(), - SUCCESS_VALUE); - Assert.assertEquals(ById.get().getRet(0).getContractRetValue(), SUCCESS_VALUE); - Assert.assertEquals(ById.get().getRet(0).getContractRet(), contractResult.SUCCESS); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(linkage002Address, 50000000L, - 3, 1, linkage002Key, blockingStubFull)); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(linkage002Address, - blockingStubFull); - info = PublicMethed.queryAccount(linkage002Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyLimit = resourceInfo.getEnergyLimit(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - Long beforeNetLimit = resourceInfo.getNetLimit(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyLimit:" + beforeEnergyLimit); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeFreeNetLimit:" + beforeFreeNetLimit); - logger.info("beforeNetLimit:" + beforeNetLimit); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String filePath = "./src/test/resources/soliditycode/contractLinkage002.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - //Set the consumeUserResourcePercent is -1,Nothing change. - byte[] contractAddress; - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", - maxFeeLimit, 0L, -1, null, linkage002Key, linkage002Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account infoafter = PublicMethed.queryAccount(linkage002Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(linkage002Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyLimit = resourceInfoafter.getEnergyLimit(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterFreeNetLimit = resourceInfoafter.getFreeNetLimit(); - Long afterNetLimit = resourceInfoafter.getNetLimit(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyLimit:" + afterEnergyLimit); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterFreeNetLimit:" + afterFreeNetLimit); - logger.info("afterNetLimit:" + afterNetLimit); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertTrue(afterNetUsed == 0); - Assert.assertTrue(afterEnergyUsed == 0); - Assert.assertTrue(afterFreeNetUsed > 0); - - //Set the consumeUserResourcePercent is 101,Nothing change. - AccountResourceMessage resourceInfo3 = PublicMethed.getAccountResource(linkage002Address, - blockingStubFull); - Account info3 = PublicMethed.queryAccount(linkage002Address, blockingStubFull); - Long beforeBalance3 = info3.getBalance(); - Long beforeEnergyLimit3 = resourceInfo3.getEnergyLimit(); - Long beforeEnergyUsed3 = resourceInfo3.getEnergyUsed(); - Long beforeFreeNetLimit3 = resourceInfo3.getFreeNetLimit(); - Long beforeNetLimit3 = resourceInfo3.getNetLimit(); - Long beforeNetUsed3 = resourceInfo3.getNetUsed(); - Long beforeFreeNetUsed3 = resourceInfo3.getFreeNetUsed(); - logger.info("beforeBalance3:" + beforeBalance3); - logger.info("beforeEnergyLimit3:" + beforeEnergyLimit3); - logger.info("beforeEnergyUsed3:" + beforeEnergyUsed3); - logger.info("beforeFreeNetLimit3:" + beforeFreeNetLimit3); - logger.info("beforeNetLimit3:" + beforeNetLimit3); - logger.info("beforeNetUsed3:" + beforeNetUsed3); - logger.info("beforeFreeNetUsed3:" + beforeFreeNetUsed3); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 101, null, linkage002Key, linkage002Address, blockingStubFull); - Account infoafter3 = PublicMethed.queryAccount(linkage002Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(linkage002Address, - blockingStubFull1); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyLimit3 = resourceInfoafter3.getEnergyLimit(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterFreeNetLimit3 = resourceInfoafter3.getFreeNetLimit(); - Long afterNetLimit3 = resourceInfoafter3.getNetLimit(); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - logger.info("afterBalance3:" + afterBalance3); - logger.info("afterEnergyLimit3:" + afterEnergyLimit3); - logger.info("afterEnergyUsed3:" + afterEnergyUsed3); - logger.info("afterFreeNetLimit3:" + afterFreeNetLimit3); - logger.info("afterNetLimit3:" + afterNetLimit3); - logger.info("afterNetUsed3:" + afterNetUsed3); - logger.info("afterFreeNetUsed3:" + afterFreeNetUsed3); - - Assert.assertEquals(beforeBalance3, afterBalance3); - Assert.assertTrue(afterNetUsed3 == 0); - Assert.assertTrue(afterEnergyUsed3 == 0); - Assert.assertTrue(afterFreeNetUsed3 > 0); - - //Set consumeUserResourcePercent is 100,balance not change,use FreeNet freezeBalanceGetEnergy. - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, linkage002Key, linkage002Address, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getConsumeUserResourcePercent() == 100); - - //Set the consumeUserResourcePercent is 0,balance not change,use FreeNet freezeBalanceGetEnergy. - AccountResourceMessage resourceInfo2 = PublicMethed.getAccountResource(linkage002Address, - blockingStubFull); - Account info2 = PublicMethed.queryAccount(linkage002Address, blockingStubFull); - Long beforeBalance2 = info2.getBalance(); - Long beforeEnergyLimit2 = resourceInfo2.getEnergyLimit(); - Long beforeEnergyUsed2 = resourceInfo2.getEnergyUsed(); - Long beforeFreeNetLimit2 = resourceInfo2.getFreeNetLimit(); - Long beforeNetLimit2 = resourceInfo2.getNetLimit(); - Long beforeNetUsed2 = resourceInfo2.getNetUsed(); - Long beforeFreeNetUsed2 = resourceInfo2.getFreeNetUsed(); - logger.info("beforeBalance2:" + beforeBalance2); - logger.info("beforeEnergyLimit2:" + beforeEnergyLimit2); - logger.info("beforeEnergyUsed2:" + beforeEnergyUsed2); - logger.info("beforeFreeNetLimit2:" + beforeFreeNetLimit2); - logger.info("beforeNetLimit2:" + beforeNetLimit2); - logger.info("beforeNetUsed2:" + beforeNetUsed2); - logger.info("beforeFreeNetUsed2:" + beforeFreeNetUsed2); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, null, linkage002Key, linkage002Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account infoafter2 = PublicMethed.queryAccount(linkage002Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(linkage002Address, - blockingStubFull1); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyLimit2 = resourceInfoafter2.getEnergyLimit(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterFreeNetLimit2 = resourceInfoafter2.getFreeNetLimit(); - Long afterNetLimit2 = resourceInfoafter2.getNetLimit(); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - logger.info("afterBalance2:" + afterBalance2); - logger.info("afterEnergyLimit2:" + afterEnergyLimit2); - logger.info("afterEnergyUsed2:" + afterEnergyUsed2); - logger.info("afterFreeNetLimit2:" + afterFreeNetLimit2); - logger.info("afterNetLimit2:" + afterNetLimit2); - logger.info("afterNetUsed2:" + afterNetUsed2); - logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2); - - Assert.assertEquals(beforeBalance2, afterBalance2); - Assert.assertTrue(afterNetUsed2 == 0); - Assert.assertTrue(afterEnergyUsed2 > 0); - Assert.assertTrue(afterFreeNetUsed2 > 0); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getConsumeUserResourcePercent() == 0); - - //Update the consumeUserResourcePercent setting. - Assert.assertTrue(PublicMethed.updateSetting(contractAddress, 66L, - linkage002Key, linkage002Address, blockingStubFull)); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getConsumeUserResourcePercent() == 66); - - //Updaate the consumeUserResourcePercent setting with -1 and 101 - Assert.assertFalse(PublicMethed.updateSetting(contractAddress, -1L, - linkage002Key, linkage002Address, blockingStubFull)); - Assert.assertFalse(PublicMethed.updateSetting(contractAddress, 101L, - linkage002Key, linkage002Address, blockingStubFull)); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage003.java b/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage003.java deleted file mode 100644 index a58ce5764b7..00000000000 --- a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage003.java +++ /dev/null @@ -1,163 +0,0 @@ -package stest.tron.wallet.contract.linkage; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractLinkage003 { - - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] linkage003Address = ecKey1.getAddress(); - String linkage002Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(linkage002Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true) - public void deployWhenNoEnergy() { - Assert.assertTrue(PublicMethed.sendcoin(linkage003Address, 200000000L, fromAddress, - testKey003, blockingStubFull)); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(linkage003Address, - blockingStubFull); - info = PublicMethed.queryAccount(linkage003Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyLimit = resourceInfo.getEnergyLimit(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - Long beforeNetLimit = resourceInfo.getNetLimit(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyLimit:" + beforeEnergyLimit); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeFreeNetLimit:" + beforeFreeNetLimit); - logger.info("beforeNetLimit:" + beforeNetLimit); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String filePath = "./src/test/resources/soliditycode/contractLinkage003.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - //use FreeNet and balance,EnergyUsed==0. - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 0, null, linkage002Key, linkage003Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - byte[] contractAddress = infoById.get().getContractAddress().toByteArray(); - Long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - Long fee = infoById.get().getFee(); - Long energyFee = infoById.get().getReceipt().getEnergyFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal:" + energyUsageTotal); - logger.info("fee:" + fee); - logger.info("energyFee:" + energyFee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(linkage003Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(linkage003Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyLimit = resourceInfoafter.getEnergyLimit(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterFreeNetLimit = resourceInfoafter.getFreeNetLimit(); - Long afterNetLimit = resourceInfoafter.getNetLimit(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyLimit:" + afterEnergyLimit); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterFreeNetLimit:" + afterFreeNetLimit); - logger.info("afterNetLimit:" + afterNetLimit); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getName().isEmpty()); - Assert.assertTrue((beforeBalance - fee) == afterBalance); - Assert.assertTrue(afterEnergyUsed == 0L); - Assert.assertTrue(afterFreeNetUsed > 0L); - Assert.assertTrue(afterNetUsed == 0L); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage004.java b/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage004.java deleted file mode 100644 index 7856c2229dc..00000000000 --- a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage004.java +++ /dev/null @@ -1,330 +0,0 @@ -package stest.tron.wallet.contract.linkage; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractLinkage004 { - - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - String contractName; - String code; - String abi; - Long currentFee; - Account info; - Long beforeBalance; - Long beforeNetLimit; - Long beforeFreeNetLimit; - Long beforeFreeNetUsed; - Long beforeNetUsed; - Long beforeEnergyLimit; - Long beforeEnergyUsed; - - Long afterBalance; - Long afterNetLimit; - Long afterFreeNetLimit; - Long afterFreeNetUsed; - Long afterNetUsed; - Long afterEnergyLimit; - Long afterEnergyUsed; - - Long energyUsed; - Long netUsed; - Long energyFee; - Long fee; - Long energyUsageTotal; - Long netFee; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] linkage004Address = ecKey1.getAddress(); - String linkage004Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(linkage004Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true) - public void test1GetTransactionInfoById() { - ecKey1 = new ECKey(Utils.getRandom()); - linkage004Address = ecKey1.getAddress(); - linkage004Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(linkage004Address, 2000000000000L, fromAddress, - testKey003, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalance(linkage004Address, 10000000L, - 3, linkage004Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(linkage004Address, - blockingStubFull); - info = PublicMethed.queryAccount(linkage004Address, blockingStubFull); - beforeBalance = info.getBalance(); - beforeEnergyLimit = resourceInfo.getEnergyLimit(); - beforeEnergyUsed = resourceInfo.getEnergyUsed(); - beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - beforeNetLimit = resourceInfo.getNetLimit(); - beforeNetUsed = resourceInfo.getNetUsed(); - beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyLimit:" + beforeEnergyLimit); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeFreeNetLimit:" + beforeFreeNetLimit); - logger.info("beforeNetLimit:" + beforeNetLimit); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String filePath = "./src/test/resources/soliditycode/contractLinkage004.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - //use freezeBalanceGetNet,Balance .No freezeBalanceGetenergy - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit, 0L, 50, null, linkage004Key, linkage004Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - fee = infoById.get().getFee(); - currentFee = fee; - energyFee = infoById.get().getReceipt().getEnergyFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal:" + energyUsageTotal); - logger.info("fee:" + fee); - logger.info("energyFee:" + energyFee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(linkage004Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(linkage004Address, - blockingStubFull1); - afterBalance = infoafter.getBalance(); - afterEnergyLimit = resourceInfoafter.getEnergyLimit(); - afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - afterFreeNetLimit = resourceInfoafter.getFreeNetLimit(); - afterNetLimit = resourceInfoafter.getNetLimit(); - afterNetUsed = resourceInfoafter.getNetUsed(); - afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyLimit:" + afterEnergyLimit); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterFreeNetLimit:" + afterFreeNetLimit); - logger.info("afterNetLimit:" + afterNetLimit); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("---------------:"); - Assert.assertTrue(infoById.isPresent()); - Assert.assertTrue((beforeBalance - fee) == afterBalance); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterEnergyUsed == 0); - Assert.assertTrue(afterFreeNetUsed > 0); - } - - @Test(enabled = true) - public void test2FeeLimitIsTooSmall() { - //When the fee limit is only short with 1 sun,failed.use freezeBalanceGetNet. - maxFeeLimit = currentFee - 1L; - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(linkage004Address, - blockingStubFull); - Account info1 = PublicMethed.queryAccount(linkage004Address, blockingStubFull); - Long beforeBalance1 = info1.getBalance(); - Long beforeEnergyLimit1 = resourceInfo1.getEnergyLimit(); - Long beforeEnergyUsed1 = resourceInfo1.getEnergyUsed(); - Long beforeFreeNetLimit1 = resourceInfo1.getFreeNetLimit(); - Long beforeNetLimit1 = resourceInfo1.getNetLimit(); - Long beforeNetUsed1 = resourceInfo1.getNetUsed(); - Long beforeFreeNetUsed1 = resourceInfo1.getFreeNetUsed(); - logger.info("beforeBalance1:" + beforeBalance1); - logger.info("beforeEnergyLimit1:" + beforeEnergyLimit1); - logger.info("beforeEnergyUsed1:" + beforeEnergyUsed1); - logger.info("beforeFreeNetLimit1:" + beforeFreeNetLimit1); - logger.info("beforeNetLimit1:" + beforeNetLimit1); - logger.info("beforeNetUsed1:" + beforeNetUsed1); - logger.info("beforeFreeNetUsed1:" + beforeFreeNetUsed1); - - String filePath = "./src/test/resources/soliditycode/contractLinkage004.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit, 0L, 50, null, linkage004Key, linkage004Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - - Optional infoById1 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - Long fee1 = infoById1.get().getFee(); - Long energyFee1 = infoById1.get().getReceipt().getEnergyFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - logger.info("fee1:" + fee1); - logger.info("energyFee1:" + energyFee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - - Account infoafter1 = PublicMethed.queryAccount(linkage004Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(linkage004Address, - blockingStubFull1); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyLimit1 = resourceInfoafter1.getEnergyLimit(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterFreeNetLimit1 = resourceInfoafter1.getFreeNetLimit(); - Long afterNetLimit1 = resourceInfoafter1.getNetLimit(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyLimit1:" + afterEnergyLimit1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterFreeNetLimit1:" + afterFreeNetLimit1); - logger.info("afterNetLimit1:" + afterNetLimit1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - - Assert.assertTrue((beforeBalance1 - fee1) == afterBalance1); - Assert.assertTrue(infoById1.get().getResultValue() == 1); - Assert.assertTrue(energyUsageTotal1 > 0); - Assert.assertTrue(afterEnergyUsed1 == 0); - Assert.assertTrue(beforeNetUsed1 < afterNetUsed1); - - //When the fee limit is just ok.use energyFee,freezeBalanceGetNet,balance change. - maxFeeLimit = currentFee; - AccountResourceMessage resourceInfo2 = PublicMethed.getAccountResource(linkage004Address, - blockingStubFull); - Account info2 = PublicMethed.queryAccount(linkage004Address, blockingStubFull); - Long beforeBalance2 = info2.getBalance(); - Long beforeEnergyLimit2 = resourceInfo2.getEnergyLimit(); - Long beforeEnergyUsed2 = resourceInfo2.getEnergyUsed(); - Long beforeFreeNetLimit2 = resourceInfo2.getFreeNetLimit(); - Long beforeNetLimit2 = resourceInfo2.getNetLimit(); - Long beforeNetUsed2 = resourceInfo2.getNetUsed(); - Long beforeFreeNetUsed2 = resourceInfo2.getFreeNetUsed(); - logger.info("beforeBalance2:" + beforeBalance2); - logger.info("beforeEnergyLimit2:" + beforeEnergyLimit2); - logger.info("beforeEnergyUsed2:" + beforeEnergyUsed2); - logger.info("beforeFreeNetLimit2:" + beforeFreeNetLimit2); - logger.info("beforeNetLimit2:" + beforeNetLimit2); - logger.info("beforeNetUsed2:" + beforeNetUsed2); - logger.info("beforeFreeNetUsed2:" + beforeFreeNetUsed2); - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit, 0L, 50, null, linkage004Key, linkage004Address, blockingStubFull); - //logger.info("testFeeLimitIsTooSmall, the txid is " + txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById2 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Long energyUsageTotal2 = infoById2.get().getReceipt().getEnergyUsageTotal(); - Long fee2 = infoById2.get().getFee(); - Long energyFee2 = infoById2.get().getReceipt().getEnergyFee(); - Long netUsed2 = infoById2.get().getReceipt().getNetUsage(); - Long energyUsed2 = infoById2.get().getReceipt().getEnergyUsage(); - Long netFee2 = infoById2.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal2:" + energyUsageTotal2); - logger.info("fee2:" + fee2); - logger.info("energyFee2:" + energyFee2); - logger.info("netUsed2:" + netUsed2); - logger.info("energyUsed2:" + energyUsed2); - logger.info("netFee2:" + netFee2); - Account infoafter2 = PublicMethed.queryAccount(linkage004Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(linkage004Address, - blockingStubFull1); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyLimit2 = resourceInfoafter2.getEnergyLimit(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterFreeNetLimit2 = resourceInfoafter2.getFreeNetLimit(); - Long afterNetLimit2 = resourceInfoafter2.getNetLimit(); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - logger.info("afterBalance2:" + afterBalance2); - logger.info("afterEnergyLimit2:" + afterEnergyLimit2); - logger.info("afterEnergyUsed2:" + afterEnergyUsed2); - logger.info("afterFreeNetLimit2:" + afterFreeNetLimit2); - logger.info("afterNetLimit2:" + afterNetLimit2); - logger.info("afterNetUsed2:" + afterNetUsed2); - logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2); - - Assert.assertTrue(infoById2.get().getResultValue() == 0); - Assert.assertTrue(infoById2.get().getReceipt().getEnergyUsageTotal() > 0); - Assert.assertTrue((beforeBalance2 - fee2) == afterBalance2); - Assert.assertTrue((beforeNetUsed2 + netUsed2) >= afterNetUsed2); - - currentFee = fee2; - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage007.java b/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage007.java deleted file mode 100644 index 70d7dc54103..00000000000 --- a/src/test/java/stest/tron/wallet/contract/linkage/ContractLinkage007.java +++ /dev/null @@ -1,357 +0,0 @@ -package stest.tron.wallet.contract.linkage; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractLinkage007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - String contractName; - String code; - String abi; - byte[] contractAddress; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] linkage007Address = ecKey1.getAddress(); - String linkage007Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(linkage007Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - } - - @Test(enabled = true) - public void testRangeOfFeeLimit() { - - //Now the feelimit range is 0-1000000000,including 0 and 1000000000 - Assert.assertTrue(PublicMethed.sendcoin(linkage007Address, 2000000000L, fromAddress, - testKey002, blockingStubFull)); - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull); - Account info; - info = PublicMethed.queryAccount(linkage007Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyLimit = resourceInfo.getEnergyLimit(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - Long beforeNetLimit = resourceInfo.getNetLimit(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyLimit:" + beforeEnergyLimit); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeFreeNetLimit:" + beforeFreeNetLimit); - logger.info("beforeNetLimit:" + beforeNetLimit); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - //When the feelimit is large, the deploy will be failed,No used everything. - - String filePath = "./src/test/resources/soliditycode/contractLinkage002.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid; - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit + 1, 0L, 100, null, linkage007Key, - linkage007Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account infoafter = PublicMethed.queryAccount(linkage007Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyLimit = resourceInfoafter.getEnergyLimit(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterFreeNetLimit = resourceInfoafter.getFreeNetLimit(); - Long afterNetLimit = resourceInfoafter.getNetLimit(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyLimit:" + afterEnergyLimit); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterFreeNetLimit:" + afterFreeNetLimit); - logger.info("afterNetLimit:" + afterNetLimit); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertTrue(afterEnergyUsed == 0); - Assert.assertTrue(afterNetUsed == 0); - Assert.assertTrue(afterFreeNetUsed == 0); - - Assert.assertTrue(txid == null); - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull); - Account info1 = PublicMethed.queryAccount(linkage007Address, blockingStubFull); - Long beforeBalance1 = info1.getBalance(); - Long beforeEnergyLimit1 = resourceInfo1.getEnergyLimit(); - Long beforeEnergyUsed1 = resourceInfo1.getEnergyUsed(); - Long beforeFreeNetLimit1 = resourceInfo1.getFreeNetLimit(); - Long beforeNetLimit1 = resourceInfo1.getNetLimit(); - Long beforeNetUsed1 = resourceInfo1.getNetUsed(); - Long beforeFreeNetUsed1 = resourceInfo1.getFreeNetUsed(); - logger.info("beforeBalance1:" + beforeBalance1); - logger.info("beforeEnergyLimit1:" + beforeEnergyLimit1); - logger.info("beforeEnergyUsed1:" + beforeEnergyUsed1); - logger.info("beforeFreeNetLimit1:" + beforeFreeNetLimit1); - logger.info("beforeNetLimit1:" + beforeNetLimit1); - logger.info("beforeNetUsed1:" + beforeNetUsed1); - logger.info("beforeFreeNetUsed1:" + beforeFreeNetUsed1); - //When the feelimit is 0, the deploy will be failed.Only use FreeNet,balance not change. - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", 0L, 0L, 100, null, linkage007Key, - linkage007Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account infoafter1 = PublicMethed.queryAccount(linkage007Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull1); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyLimit1 = resourceInfoafter1.getEnergyLimit(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterFreeNetLimit1 = resourceInfoafter1.getFreeNetLimit(); - Long afterNetLimit1 = resourceInfoafter1.getNetLimit(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyLimit1:" + afterEnergyLimit1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterFreeNetLimit1:" + afterFreeNetLimit1); - logger.info("afterNetLimit1:" + afterNetLimit1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - logger.info("---------------:"); - Assert.assertEquals(beforeBalance1, afterBalance1); - Assert.assertTrue(afterFreeNetUsed1 > 0); - Assert.assertTrue(afterNetUsed1 == 0); - Assert.assertTrue(afterEnergyUsed1 == 0); - Optional infoById; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - - //Deploy the contract.success.use FreeNet,EnergyFee.balcne change - AccountResourceMessage resourceInfo2 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull); - Account info2 = PublicMethed.queryAccount(linkage007Address, blockingStubFull); - Long beforeBalance2 = info2.getBalance(); - Long beforeEnergyLimit2 = resourceInfo2.getEnergyLimit(); - Long beforeEnergyUsed2 = resourceInfo2.getEnergyUsed(); - Long beforeFreeNetLimit2 = resourceInfo2.getFreeNetLimit(); - Long beforeNetLimit2 = resourceInfo2.getNetLimit(); - Long beforeNetUsed2 = resourceInfo2.getNetUsed(); - Long beforeFreeNetUsed2 = resourceInfo2.getFreeNetUsed(); - logger.info("beforeBalance2:" + beforeBalance2); - logger.info("beforeEnergyLimit2:" + beforeEnergyLimit2); - logger.info("beforeEnergyUsed2:" + beforeEnergyUsed2); - logger.info("beforeFreeNetLimit2:" + beforeFreeNetLimit2); - logger.info("beforeNetLimit2:" + beforeNetLimit2); - logger.info("beforeNetUsed2:" + beforeNetUsed2); - logger.info("beforeFreeNetUsed2:" + beforeFreeNetUsed2); - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit, 0L, 100, null, linkage007Key, - linkage007Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById2 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Long energyUsageTotal2 = infoById2.get().getReceipt().getEnergyUsageTotal(); - Long fee2 = infoById2.get().getFee(); - Long energyFee2 = infoById2.get().getReceipt().getEnergyFee(); - Long netUsed2 = infoById2.get().getReceipt().getNetUsage(); - Long energyUsed2 = infoById2.get().getReceipt().getEnergyUsage(); - Long netFee2 = infoById2.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal2:" + energyUsageTotal2); - logger.info("fee2:" + fee2); - logger.info("energyFee2:" + energyFee2); - logger.info("netUsed2:" + netUsed2); - logger.info("energyUsed2:" + energyUsed2); - logger.info("netFee2:" + netFee2); - Account infoafter2 = PublicMethed.queryAccount(linkage007Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull1); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyLimit2 = resourceInfoafter2.getEnergyLimit(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterFreeNetLimit2 = resourceInfoafter2.getFreeNetLimit(); - Long afterNetLimit2 = resourceInfoafter2.getNetLimit(); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - logger.info("afterBalance2:" + afterBalance2); - logger.info("afterEnergyLimit2:" + afterEnergyLimit2); - logger.info("afterEnergyUsed2:" + afterEnergyUsed2); - logger.info("afterFreeNetLimit2:" + afterFreeNetLimit2); - logger.info("afterNetLimit2:" + afterNetLimit2); - logger.info("afterNetUsed2:" + afterNetUsed2); - logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2); - logger.info("---------------:"); - Assert.assertTrue((beforeBalance2 - fee2) == afterBalance2); - Assert.assertTrue(afterEnergyUsed2 == 0); - Assert.assertTrue(afterFreeNetUsed2 > beforeFreeNetUsed2); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - contractAddress = infoById2.get().getContractAddress().toByteArray(); - - //When the feelimit is large, the trigger will be failed.Only use FreeNetUsed,Balance not change - AccountResourceMessage resourceInfo3 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull); - Account info3 = PublicMethed.queryAccount(linkage007Address, blockingStubFull); - Long beforeBalance3 = info3.getBalance(); - Long beforeEnergyLimit3 = resourceInfo3.getEnergyLimit(); - Long beforeEnergyUsed3 = resourceInfo3.getEnergyUsed(); - Long beforeFreeNetLimit3 = resourceInfo3.getFreeNetLimit(); - Long beforeNetLimit3 = resourceInfo3.getNetLimit(); - Long beforeNetUsed3 = resourceInfo3.getNetUsed(); - Long beforeFreeNetUsed3 = resourceInfo3.getFreeNetUsed(); - logger.info("beforeBalance3:" + beforeBalance3); - logger.info("beforeEnergyLimit3:" + beforeEnergyLimit3); - logger.info("beforeEnergyUsed3:" + beforeEnergyUsed3); - logger.info("beforeFreeNetLimit3:" + beforeFreeNetLimit3); - logger.info("beforeNetLimit3:" + beforeNetLimit3); - logger.info("beforeNetUsed3:" + beforeNetUsed3); - logger.info("beforeFreeNetUsed3:" + beforeFreeNetUsed3); - //String initParmes = "\"" + Base58.encode58Check(fromAddress) + "\",\"63\""; - String num = "4" + "," + "2"; - txid = PublicMethed.triggerContract(contractAddress, - "divideIHaveArgsReturn(int256,int256)", num, false, - 1000, maxFeeLimit + 1, linkage007Address, linkage007Key, blockingStubFull); - Account infoafter3 = PublicMethed.queryAccount(linkage007Address, blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull1); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyLimit3 = resourceInfoafter3.getEnergyLimit(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterFreeNetLimit3 = resourceInfoafter3.getFreeNetLimit(); - Long afterNetLimit3 = resourceInfoafter3.getNetLimit(); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - logger.info("afterBalance3:" + afterBalance3); - logger.info("afterEnergyLimit3:" + afterEnergyLimit3); - logger.info("afterEnergyUsed3:" + afterEnergyUsed3); - logger.info("afterFreeNetLimit3:" + afterFreeNetLimit3); - logger.info("afterNetLimit3:" + afterNetLimit3); - logger.info("afterNetUsed3:" + afterNetUsed3); - logger.info("afterFreeNetUsed3:" + afterFreeNetUsed3); - logger.info("---------------:"); - Assert.assertTrue(txid == null); - Assert.assertEquals(beforeBalance3, afterBalance3); - Assert.assertTrue(afterFreeNetUsed3 > beforeNetUsed3); - Assert.assertTrue(afterNetUsed3 == 0); - Assert.assertTrue(afterEnergyUsed3 == 0); - //When the feelimit is 0, the trigger will be failed.Only use FreeNetUsed,Balance not change - AccountResourceMessage resourceInfo4 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull); - Account info4 = PublicMethed.queryAccount(linkage007Address, blockingStubFull); - Long beforeBalance4 = info4.getBalance(); - Long beforeEnergyLimit4 = resourceInfo4.getEnergyLimit(); - Long beforeEnergyUsed4 = resourceInfo4.getEnergyUsed(); - Long beforeFreeNetLimit4 = resourceInfo4.getFreeNetLimit(); - Long beforeNetLimit4 = resourceInfo4.getNetLimit(); - Long beforeNetUsed4 = resourceInfo4.getNetUsed(); - Long beforeFreeNetUsed4 = resourceInfo4.getFreeNetUsed(); - logger.info("beforeBalance4:" + beforeBalance4); - logger.info("beforeEnergyLimit4:" + beforeEnergyLimit4); - logger.info("beforeEnergyUsed4:" + beforeEnergyUsed4); - logger.info("beforeFreeNetLimit4:" + beforeFreeNetLimit4); - logger.info("beforeNetLimit4:" + beforeNetLimit4); - logger.info("beforeNetUsed4:" + beforeNetUsed4); - logger.info("beforeFreeNetUsed4:" + beforeFreeNetUsed4); - txid = PublicMethed.triggerContract(contractAddress, - "divideIHaveArgsReturn(int256,int256)", num, false, - 1000, maxFeeLimit + 1, linkage007Address, linkage007Key, blockingStubFull); - Account infoafter4 = PublicMethed.queryAccount(linkage007Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter4 = PublicMethed.getAccountResource(linkage007Address, - blockingStubFull1); - Long afterBalance4 = infoafter4.getBalance(); - Long afterEnergyLimit4 = resourceInfoafter4.getEnergyLimit(); - Long afterEnergyUsed4 = resourceInfoafter4.getEnergyUsed(); - Long afterFreeNetLimit4 = resourceInfoafter4.getFreeNetLimit(); - Long afterNetLimit4 = resourceInfoafter4.getNetLimit(); - Long afterNetUsed4 = resourceInfoafter4.getNetUsed(); - Long afterFreeNetUsed4 = resourceInfoafter4.getFreeNetUsed(); - logger.info("afterBalance4:" + afterBalance4); - logger.info("afterEnergyLimit4:" + afterEnergyLimit4); - logger.info("afterEnergyUsed4:" + afterEnergyUsed4); - logger.info("afterFreeNetLimit4:" + afterFreeNetLimit4); - logger.info("afterNetLimit4:" + afterNetLimit4); - logger.info("afterNetUsed4:" + afterNetUsed4); - logger.info("afterFreeNetUsed4:" + afterFreeNetUsed4); - logger.info("---------------:"); - Assert.assertEquals(beforeBalance4, afterBalance4); - Assert.assertTrue(afterFreeNetUsed4 > beforeNetUsed4); - Assert.assertTrue(afterNetUsed4 == 0); - Assert.assertTrue(afterEnergyUsed4 == 0); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info(Integer.toString(infoById.get().getResultValue())); - Assert.assertTrue(infoById.get().getFee() == 0); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario001.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario001.java deleted file mode 100644 index 37d4a83375c..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario001.java +++ /dev/null @@ -1,135 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract001Address = ecKey1.getAddress(); - String contract001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true) - public void deployAddressDemo() { - ecKey1 = new ECKey(Utils.getRandom()); - contract001Address = ecKey1.getAddress(); - contract001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(contract001Key); - - Assert.assertTrue(PublicMethed.sendcoin(contract001Address, 20000000L, toAddress, - testKey003, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract001Address, 15000000L, - 3, 1, contract001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract001Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Long balanceBefore = PublicMethed.queryAccount(contract001Key, blockingStubFull).getBalance(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/contractScenario001.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract001Key, contract001Address, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - accountResource = PublicMethed.getAccountResource(contract001Address, blockingStubFull1); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - Long balanceAfter = PublicMethed.queryAccount(contract001Key, blockingStubFull1).getBalance(); - - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - logger.info("after balance is " + Long.toString(balanceAfter)); - - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario003.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario003.java deleted file mode 100644 index 942cbe0e7a3..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario003.java +++ /dev/null @@ -1,143 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract003Address = ecKey1.getAddress(); - String contract003Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract003Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - logger.info(Long.toString(PublicMethed.queryAccount(contract003Key, blockingStubFull) - .getBalance())); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true) - public void deployErc223() { - ecKey1 = new ECKey(Utils.getRandom()); - contract003Address = ecKey1.getAddress(); - contract003Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(contract003Address, 500000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract003Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Long balanceBefore = PublicMethed.queryAccount(contract003Key, blockingStubFull).getBalance(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/contractScenario003.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 100, null, contract003Key, contract003Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - logger.info(txid); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - com.google.protobuf.ByteString contractAddress = infoById.get().getContractAddress(); - SmartContract smartContract = PublicMethed - .getContract(contractAddress.toByteArray(), blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - PublicMethed.waitProduceNextBlock(blockingStubFull1); - accountResource = PublicMethed.getAccountResource(contract003Address, blockingStubFull1); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - Long balanceAfter = PublicMethed.queryAccount(contract003Address, blockingStubFull1) - .getBalance(); - - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - logger.info("after balance is " + Long.toString(balanceAfter)); - logger.info("transaction fee is " + Long.toString(infoById.get().getFee())); - - Assert.assertTrue(energyLimit == 0); - Assert.assertTrue(energyUsage == 0); - Assert.assertTrue(balanceBefore == balanceAfter + infoById.get().getFee()); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario004.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario004.java deleted file mode 100644 index 2ac708412ee..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario004.java +++ /dev/null @@ -1,120 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract004Address = ecKey1.getAddress(); - String contract004Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract004Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployErc20TronToken() { - Assert.assertTrue(PublicMethed.sendcoin(contract004Address, 200000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract004Address, 100000000L, - 3, 1, contract004Key, blockingStubFull)); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract004Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - - String filePath = "./src/test/resources/soliditycode/contractScenario004.sol"; - String contractName = "TronToken"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract004Key, contract004Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - byte[] contractAddress; - contractAddress = infoById.get().getContractAddress().toByteArray(); - - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - accountResource = PublicMethed.getAccountResource(contract004Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario005.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario005.java deleted file mode 100644 index 31d1541d20d..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario005.java +++ /dev/null @@ -1,124 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract005Address = ecKey1.getAddress(); - String contract005Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract005Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployIcoContract() { - Assert.assertTrue(PublicMethed.sendcoin(contract005Address, 200000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract005Address, 10000000L, - 3, 1, contract005Key, blockingStubFull)); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract005Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - - String filePath = "./src/test/resources/soliditycode/contractScenario005.sol"; - String contractName = "Crowdsale"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract005Key, contract005Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - byte[] contractAddress = null; - contractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - accountResource = PublicMethed.getAccountResource(contract005Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario006.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario006.java deleted file mode 100644 index 178390b015c..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario006.java +++ /dev/null @@ -1,129 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract006Address = ecKey1.getAddress(); - String contract006Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployFomo3D() { - ecKey1 = new ECKey(Utils.getRandom()); - contract006Address = ecKey1.getAddress(); - contract006Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(contract006Key); - - PublicMethed.sendcoin(contract006Address, 2000000000L, toAddress, - testKey003, blockingStubFull); - logger.info(Long.toString(PublicMethed.queryAccount(contract006Key, blockingStubFull) - .getBalance())); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract006Address, 100000000L, - 0, 1, contract006Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract006Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - - String filePath = "./src/test/resources/soliditycode/contractScenario006.sol"; - String contractName = "FoMo3Dlong"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress; - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract006Key, contract006Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - contractAddress = infoById.get().getContractAddress().toByteArray(); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - accountResource = PublicMethed.getAccountResource(contract006Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario007.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario007.java deleted file mode 100644 index c2371f7f0cf..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario007.java +++ /dev/null @@ -1,117 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract007Address = ecKey1.getAddress(); - String contract007Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract007Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployErc721CardMigration() { - ecKey1 = new ECKey(Utils.getRandom()); - contract007Address = ecKey1.getAddress(); - contract007Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(contract007Address, 20000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract007Address, 100000000L, - 3, 1, contract007Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract007Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Account account = PublicMethed.queryAccount(contract007Key, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - String filePath = "./src/test/resources/soliditycode/contractScenario007.sol"; - String contractName = "ERC721Token"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract007Key, contract007Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - accountResource = PublicMethed.getAccountResource(contract007Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - account = PublicMethed.queryAccount(contract007Key, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario008.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario008.java deleted file mode 100644 index 4f306b7daef..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario008.java +++ /dev/null @@ -1,120 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario008 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract008Address = ecKey1.getAddress(); - String contract008Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployErc721CryptoKitties() { - ecKey1 = new ECKey(Utils.getRandom()); - contract008Address = ecKey1.getAddress(); - contract008Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(contract008Key); - Assert.assertTrue(PublicMethed.sendcoin(contract008Address, 5000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract008Address, 1000000L, - 3, 1, contract008Key, blockingStubFull)); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract008Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Account account = PublicMethed.queryAccount(contract008Key, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - Long shortFeeLimit = 900L; - - String filePath = "./src/test/resources/soliditycode/contractScenario008.sol"; - String contractName = "KittyCore"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", shortFeeLimit, - 0L, 100, null, contract008Key, contract008Address, blockingStubFull); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract008Key, contract008Address, blockingStubFull); - - final SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - accountResource = PublicMethed.getAccountResource(contract008Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - account = PublicMethed.queryAccount(contract008Key, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario009.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario009.java deleted file mode 100644 index cfa4ea28d72..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario009.java +++ /dev/null @@ -1,132 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private String compilerVersion = Configuration.getByPath("testng.conf") - .getString("defaultParameter.solidityCompilerVersion"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract009Address = ecKey1.getAddress(); - String contract009Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract009Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployContainLibraryContract() { - Assert.assertTrue(PublicMethed.sendcoin(contract009Address, 20000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract009Address, 1000000L, - 3, 1, contract009Key, blockingStubFull)); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract009Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - String filePath = "./src/test/resources/soliditycode/contractScenario009.sol"; - String contractName = "Set"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] libraryContractAddress; - libraryContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract009Key, contract009Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - contractName = "C"; - retMap = PublicMethed.getBycodeAbiForLibrary(filePath, contractName); - code = retMap.get("byteCode").toString(); - abi = retMap.get("abI").toString(); - String library = retMap.get("library").toString(); - - //String libraryAddress = - // "browser/TvmTest_p1_Grammar_002.sol:Set:" + Base58.encode58Check(libraryContractAddress); - String libraryAddress; - libraryAddress = library - + Base58.encode58Check(libraryContractAddress); - - byte[] contractAddress = PublicMethed - .deployContractForLibrary(contractName, abi, code, "", maxFeeLimit, 0L, 100, libraryAddress, - contract009Key, contract009Address, compilerVersion, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - logger.info(ByteArray.toHexString(smartContract.getContractAddress().toByteArray())); - accountResource = PublicMethed.getAccountResource(contract009Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario010.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario010.java deleted file mode 100644 index 2ea380bafe1..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario010.java +++ /dev/null @@ -1,120 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario010 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract009Address = ecKey1.getAddress(); - String contract009Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract009Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployContainLibraryContract() { - ecKey1 = new ECKey(Utils.getRandom()); - contract009Address = ecKey1.getAddress(); - contract009Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(contract009Address, 600000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract009Address, 10000000L, - 3, 1, contract009Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract009Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Long netUsage = accountResource.getNetUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - logger.info("before Net usage is " + Long.toString(netUsage)); - String filePath = "./src/test/resources/soliditycode/contractScenario010.sol"; - String contractName = "TRON_ERC721"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] libraryAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract009Key, contract009Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(libraryAddress, blockingStubFull); - - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - logger.info(ByteArray.toHexString(smartContract.getContractAddress().toByteArray())); - accountResource = PublicMethed.getAccountResource(contract009Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - netUsage = accountResource.getNetUsed(); - Assert.assertTrue(energyLimit > 0); - Assert.assertTrue(energyUsage > 0); - - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - logger.info("after Net usage is " + Long.toString(netUsage)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario012.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario012.java deleted file mode 100644 index 1b12c881a30..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario012.java +++ /dev/null @@ -1,205 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario012 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - byte[] contractAddress = null; - String txid = ""; - Optional infoById = null; - String receiveAddressParam; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract012Address = ecKey1.getAddress(); - String contract012Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverAddress = ecKey2.getAddress(); - String receiverKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract012Key); - PublicMethed.printAddress(receiverKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void test1DeployTransactionCoin() { - ecKey1 = new ECKey(Utils.getRandom()); - contract012Address = ecKey1.getAddress(); - contract012Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(contract012Address, 2000000000L, fromAddress, - testKey002, blockingStubFull)); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract012Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - String filePath = "./src/test/resources/soliditycode/contractScenario012.sol"; - String contractName = "PayTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, 0L, 100, - null, contract012Key, contract012Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - Assert.assertTrue(infoById.get().getResultValue() == 0); - logger.info("energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - contractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - } - - - @Test(enabled = true) - public void test2TriggerTransactionCoin() { - Account account = PublicMethed.queryAccount(contractAddress, blockingStubFull); - logger.info("contract Balance : -- " + account.getBalance()); - receiveAddressParam = "\"" + Base58.encode58Check(fromAddress) - + "\""; - //When the contract has no money,transaction coin failed. - txid = PublicMethed.triggerContract(contractAddress, - "sendToAddress2(address)", receiveAddressParam, false, - 0, 100000000L, contract012Address, contract012Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - Assert.assertTrue(infoById.get().getResultValue() == 1); - logger.info("energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() > 0); - Assert.assertTrue(infoById.get().getFee() == infoById.get().getReceipt().getEnergyFee()); - Assert.assertFalse(infoById.get().getContractAddress().isEmpty()); - } - - - @Test(enabled = true) - public void test3TriggerTransactionCanNotCreateAccount() { - ecKey2 = new ECKey(Utils.getRandom()); - receiverAddress = ecKey2.getAddress(); - receiverKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - //Send some trx to the contract account. - Assert.assertTrue(PublicMethed.sendcoin(contractAddress, 1000000000L, toAddress, - testKey003, blockingStubFull)); - Account account = PublicMethed.queryAccount(contractAddress, blockingStubFull); - logger.info("contract Balance : -- " + account.getBalance()); - receiveAddressParam = "\"" + Base58.encode58Check(receiverAddress) - + "\""; - //In smart contract, you can't create account - txid = PublicMethed.triggerContract(contractAddress, - "sendToAddress2(address)", receiveAddressParam, false, - 0, 100000000L, contract012Address, contract012Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - logger.info("result is " + infoById.get().getResultValue()); - logger.info("energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() > 0); - Assert.assertTrue(infoById.get().getFee() == infoById.get().getReceipt().getEnergyFee()); - Assert.assertFalse(infoById.get().getContractAddress().isEmpty()); - - } - - - @Test(enabled = true) - public void test4TriggerTransactionCoin() { - receiveAddressParam = "\"" + Base58.encode58Check(receiverAddress) - + "\""; - Account account = PublicMethed.queryAccount(contractAddress, blockingStubFull); - logger.info("contract Balance : -- " + account.getBalance()); - //This time, trigger the methed sendToAddress2 is OK. - Assert.assertTrue(PublicMethed.sendcoin(receiverAddress, 10000000L, toAddress, - testKey003, blockingStubFull)); - txid = PublicMethed.triggerContract(contractAddress, - "sendToAddress2(address)", receiveAddressParam, false, - 0, 100000000L, contract012Address, contract012Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - logger.info("result is " + infoById.get().getResultValue()); - logger.info("energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() > 0); - Assert.assertTrue(infoById.get().getFee() == infoById.get().getReceipt().getEnergyFee()); - Assert.assertFalse(infoById.get().getContractAddress().isEmpty()); - - } - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario013.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario013.java deleted file mode 100644 index 57eed764388..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario013.java +++ /dev/null @@ -1,149 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario013 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - byte[] contractAddress = null; - String txid = ""; - Optional infoById = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract013Address = ecKey1.getAddress(); - String contract013Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract013Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void deployTronTrxAndSunContract() { - Assert.assertTrue(PublicMethed.sendcoin(contract013Address, 20000000000L, fromAddress, - testKey002, blockingStubFull)); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract013Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - - String filePath = "./src/test/resources/soliditycode/contractScenario013.sol"; - String contractName = "timetest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 100, null, contract013Key, contract013Address, blockingStubFull); - logger.info(txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() > 0); - Assert.assertFalse(infoById.get().getContractAddress().isEmpty()); - } - - @Test(enabled = true) - public void triggerTronTrxAndSunContract() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract013Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - - String filePath = "./src/test/resources/soliditycode/contractScenario013.sol"; - String contractName = "timetest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contract013Key, contract013Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - logger.info("energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - contractAddress = infoById.get().getContractAddress().toByteArray(); - - txid = PublicMethed.triggerContract(contractAddress, - "time()", "#", false, - 0, 100000000L, contract013Address, contract013Key, blockingStubFull); - logger.info(txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("result is " + infoById.get().getResultValue()); - logger.info("energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() > 0); - Assert.assertTrue(infoById.get().getFee() == infoById.get().getReceipt().getEnergyFee()); - Assert.assertFalse(infoById.get().getContractAddress().isEmpty()); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario014.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario014.java deleted file mode 100644 index fc586aab93b..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario014.java +++ /dev/null @@ -1,171 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import static org.tron.protos.Protocol.Transaction.Result.contractResult.SUCCESS_VALUE; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario014 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Clear a contract with ABI created by itself") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertEquals(0,infoById.get().getResultValue()); - Assert.assertEquals("", - ByteArray.toHexString(infoById.get().getResMessage().toByteArray())); - - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - Assert.assertEquals(byId.get().getRet(0).getContractRet().getNumber(), - SUCCESS_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), SUCCESS_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.SUCCESS); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario015.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario015.java deleted file mode 100644 index 6c3f66de9a1..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario015.java +++ /dev/null @@ -1,155 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario015 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "TriggerConstantContract a constant function ") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - logger.info("message:" + transaction.getRet(0).getRet()); - logger.info(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - logger.info("Result:" + Hex.toHexString(result)); - logger.info("getCode" + transactionExtention.getResult().getCode().getNumber()); - Assert.assertEquals("SUCESS",transaction.getRet(0).getRet().toString()); - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario016.java b/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario016.java deleted file mode 100644 index 914a6230915..00000000000 --- a/src/test/java/stest/tron/wallet/contract/scenario/ContractScenario016.java +++ /dev/null @@ -1,206 +0,0 @@ -package stest.tron.wallet.contract.scenario; - -import static org.tron.protos.Protocol.Transaction.Result.contractResult.BAD_JUMP_DESTINATION_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.OUT_OF_ENERGY_VALUE; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario016 { - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String compilerVersion = Configuration.getByPath("testng.conf") - .getString("defaultParameter.solidityCompilerVersion"); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress = ecKey1.getAddress(); - String testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true, description = "ContractResult is BAD_JUMP_DESTINATION") - public void test1Grammar001() { - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName = "Test"; - - String code = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600" - + "080fd5b5061011f8061003a6000396000f30060806040526004361060485763ffffffff7c01000000000000" - + "000000000000000000000000000000000000000000006000350416634ef5a0088114604d5780639093b95b1" - + "4608c575b600080fd5b348015605857600080fd5b50d38015606457600080fd5b50d28015607057600080fd" - + "5b50607a60043560b8565b60408051918252519081900360200190f35b348015609757600080fd5b50d3801" - + "560a357600080fd5b50d2801560af57600080fd5b5060b660ee565b005b6000606082604051908082528060" - + "20026020018201604052801560e5578160200160208202803883390190505b50905050919050565b6001805" - + "600a165627a7a7230582092ba162087e13f41c6d6c00ba493edc5a5a6250a3840ece5f99aa38b66366a7000" - + "29"; - String abi = "[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\"" - + ":\"testOutOfMem\",\"outputs\":[{\"name\":\"r\",\"type\":\"bytes32\"}],\"payable\":false" - + ",\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs" - + "\":[],\"name\":\"testBadJumpDestination\",\"outputs\":[],\"payable\":false,\"stateMutab" - + "ility\":\"nonpayable\",\"type\":\"function\"}]"; - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, grammarAddress, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - org.testng.Assert.assertTrue(smartContract.getAbi().toString() != null); - String txid = null; - Optional infoById = null; - txid = PublicMethed.triggerContract(contractAddress, - "testBadJumpDestination()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - logger.info("ById:" + byId); - - logger.info("infoById:" + infoById); - - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), BAD_JUMP_DESTINATION_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.BAD_JUMP_DESTINATION); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert - .assertEquals(contractResult.BAD_JUMP_DESTINATION, infoById.get().getReceipt().getResult()); - - Assert.assertEquals(byId.get().getRet(0).getRet().getNumber(), 0); - Assert.assertEquals(byId.get().getRet(0).getRetValue(), 0); - - - } - - - @Test(enabled = true, description = "ContractResult is OUT_OF_ENERGY") - public void test2Grammar002() { - - String filePath = "src/test/resources/soliditycode/contractUnknownException.sol"; - String contractName = "testC"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 20L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - logger.info("ById:" + byId); - - logger.info("infoById:" + infoById); - - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), OUT_OF_ENERGY_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.OUT_OF_ENERGY); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert - .assertEquals(contractResult.OUT_OF_ENERGY, infoById.get().getReceipt().getResult()); - - Assert.assertEquals(byId.get().getRet(0).getRet().getNumber(), 0); - Assert.assertEquals(byId.get().getRet(0).getRetValue(), 0); - - } - - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue001.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue001.java deleted file mode 100644 index 6f6bbbb12c7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue001.java +++ /dev/null @@ -1,338 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue001_" + Long.toString(now); - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] noBandwitchAddress = ecKey.getAddress(); - String noBandwitch = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Transfer asset use Bandwitch") - public void testTransferAssetBandwitchDecreaseWithin10Second() { - //get account - ecKey = new ECKey(Utils.getRandom()); - noBandwitchAddress = ecKey.getAddress(); - noBandwitch = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - PublicMethed.printAddress(noBandwitch); - - Assert.assertTrue(PublicMethed.sendcoin(noBandwitchAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 5000; - Long end = System.currentTimeMillis() + 1000000000; - - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(noBandwitchAddress, name, totalSupply, 1, - 100, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, noBandwitch, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(noBandwitch, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - Assert.assertTrue(transferAsset(toAddress, assetAccountId.toByteArray(), 100L, - noBandwitchAddress, noBandwitch)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Transfer Asset failed when transfer to yourself - Assert.assertFalse(transferAsset(toAddress, assetAccountId.toByteArray(), 100L, - toAddress, testKey003)); - //Transfer Asset failed when the transfer amount is large than the asset balance you have. - Assert.assertFalse( - transferAsset(fromAddress, assetAccountId.toByteArray(), 9100000000000000000L, - toAddress, testKey003)); - //Transfer Asset failed when the transfer amount is 0 - Assert.assertFalse(transferAsset(fromAddress, assetAccountId.toByteArray(), 0L, - toAddress, testKey003)); - //Transfer Asset failed when the transfer amount is -1 - Assert.assertFalse(transferAsset(fromAddress, assetAccountId.toByteArray(), -1L, - toAddress, testKey003)); - - //Transfer success. - Assert.assertTrue(transferAsset(fromAddress, assetAccountId.toByteArray(), 1L, - toAddress, testKey003)); - - //No freeze asset, try to unfreeze asset failed. - Assert.assertFalse(unFreezeAsset(noBandwitchAddress, noBandwitch)); - - //Not create asset, try to unfreeze asset failed.No exception. - Assert.assertFalse(unFreezeAsset(toAddress, testKey003)); - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(20000); - builder.setPublicFreeAssetNetLimit(20000); - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null || transaction.getRawData().getContractCount() == 0"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue002.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue002.java deleted file mode 100644 index ca5021e3688..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue002.java +++ /dev/null @@ -1,347 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue002_" + Long.toString(now); - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test(enabled = true, description = "Participate token") - public void testParticipateAssetissue() { - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] participateAccountAddress = ecKey1.getAddress(); - final String participateAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] toAddress = ecKey2.getAddress(); - final String testKey003 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - //send coin to the new account - Assert.assertTrue(PublicMethed.sendcoin(participateAccountAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Create a new Asset Issue - Assert.assertTrue(PublicMethed.createAssetIssue(participateAccountAddress, - name, totalSupply, 1, 1, System.currentTimeMillis() + 5000, - System.currentTimeMillis() + 1000000000, 1, description, url, - 2000L, 2000L, 1L, 1L, - participateAccountKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(participateAccountKey, blockingStubFull); - final ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Participate AssetIssue success - logger.info(name); - //Freeze amount to get bandwitch. - logger.info("toaddress balance is " - + PublicMethed.queryAccount(toAddress, blockingStubFull).getBalance()); - Assert.assertTrue(PublicMethed.freezeBalance(toAddress, 10000000, 3, testKey003, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.participateAssetIssue(participateAccountAddress, - assetAccountId.toByteArray(), - 100L, toAddress, testKey003, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //The amount is large than the total supply, participate failed. - Assert.assertFalse(PublicMethed.participateAssetIssue(participateAccountAddress, - assetAccountId.toByteArray(), 9100000000000000000L, toAddress, testKey003, - blockingStubFull)); - - //The amount is 0, participate asset issue failed. - Assert.assertFalse(PublicMethed.participateAssetIssue(participateAccountAddress, - assetAccountId.toByteArray(), 0L, toAddress, testKey003, blockingStubFull)); - - //The amount is -1, participate asset issue failed. - Assert.assertFalse(PublicMethed.participateAssetIssue(participateAccountAddress, - assetAccountId.toByteArray(), -1L, toAddress, testKey003, blockingStubFull)); - - //The asset issue owner address is not correct, participate asset issue failed. - Assert.assertFalse(PublicMethed.participateAssetIssue(fromAddress, - assetAccountId.toByteArray(), 100L, - toAddress, testKey003, blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, byte[] from, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long fronzenAmount, Long frozenDay, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(20000); - builder.setPublicFreeAssetNetLimit(20000); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null || transaction.getRawData().getContractCount() == 0"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - //Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue003.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue003.java deleted file mode 100644 index 2f9d819068e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue003.java +++ /dev/null @@ -1,417 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static final String name = "testAssetIssue003_" + Long.toString(now); - private static final String shortname = "a"; - private static final String tooLongName = "qazxswedcvfrtgbnhyujmkiolpoiuytre"; - private static final String chineseAssetIssuename = "中文都名字"; - private static final String tooLongAbbreviation = "wazxswedcvfrtgbnhyujmkiolpoiuytre"; - private static final String chineseAbbreviation = "中文的简称"; - private static final String tooLongDescription = - "1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqa" - + "zxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvq" - + "azxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcv"; - private static final String tooLongUrl = - "qaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqasw1qazxswedcvqazxswedcv" - + "qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedc" - + "vqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqaz" - + "xswedcvqazxswedcvqazxswedcvqazxswedcv"; - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] asset003Address = ecKey.getAddress(); - String asset003Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Create token with exception condition") - public void testExceptionOfAssetIssuew() { - PublicMethed.sendcoin(asset003Address, 2048000000L, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 100000; - Long end = System.currentTimeMillis() + 1000000000; - //Freeze amount is large than total supply, create asset issue failed. - Assert.assertFalse(PublicMethed.createAssetIssue(asset003Address, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 9000000000000000000L, 1L, asset003Key, blockingStubFull)); - //Freeze day is 0, create failed - Assert.assertFalse(PublicMethed.createAssetIssue(asset003Address, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 100L, 0L, asset003Key, blockingStubFull)); - //Freeze amount is 0, create failed - Assert.assertFalse(PublicMethed.createAssetIssue(asset003Address, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 0L, 1L, asset003Key, blockingStubFull)); - //Freeze day is -1, create failed - Assert.assertFalse(PublicMethed.createAssetIssue(asset003Address, name, totalSupply, 1, 10, - start, end, 2, description, url, 1000L, 1000L, - 1000L, -1L, asset003Key, blockingStubFull)); - //Freeze amount is -1, create failed - Assert.assertFalse(PublicMethed.createAssetIssue(asset003Address, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - -1L, 1L, asset003Key, blockingStubFull)); - //Freeze day is 3653(10 years + 1 day), create failed - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3653L, asset003Key, blockingStubFull)); - //Start time is late than end time. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, 10, - end, start, 2, description, url, 10000L, 10000L, - 1L, 2L, asset003Key, blockingStubFull)); - //Start time is early than currently time. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, 10, - start - 1000000L, end, 2, description, url, 10000L, - 10000L, 1L, 2L, asset003Key, blockingStubFull)); - //totalSupply is zero. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, 0L, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //Total supply is -1. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, -1L, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //TrxNum is zero. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 0, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //TrxNum is -1. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, -1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //IcoNum is 0. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, 0, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //IcoNum is -1. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, -1, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //The asset issue name is null. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, "", totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //The asset issue name is large than 33 char. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, tooLongName, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //The asset issue name is chinese name. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, chineseAssetIssuename, - totalSupply, 1, 10, start, end, 2, description, url, 10000L, - 10000L, 1L, 3652L, asset003Key, blockingStubFull)); - //The abbreviation is null. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, "", totalSupply, - 1, 10, start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //The abbreviation is large than 33 char. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, tooLongAbbreviation, - totalSupply, 1, 10, start, end, 2, description, url, 10000L, - 10000L, 1L, 3652L, asset003Key, blockingStubFull)); - //The abbreviation is chinese name. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, chineseAbbreviation, - totalSupply, 1, 10, start, end, 2, description, url, 10000L, - 10000L, 1L, 3652L, asset003Key, blockingStubFull)); - //The URL is null. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, 10, - start, end, 2, description, "", 10000L, 10000L, - 1L, 3652L, asset003Key, blockingStubFull)); - //The URL is too long. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, - 1, 10, start, end, 2, description, tooLongUrl, 10000L, - 10000L, 1L, 3652L, asset003Key, blockingStubFull)); - //The description is null. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, - 1, 10, start, end, 2, "", url, 10000L, - 10000L, 1L, 3652L, asset003Key, blockingStubFull)); - //The description is too long, create failed. - Assert.assertFalse(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, 10, - start, end, 2, tooLongDescription, url, 10000L, - 10000L, 1L, 3652L, asset003Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Get asset issue list") - public void testGetAllAssetIssue() { - GrpcAPI.AssetIssueList assetIssueList = blockingStubFull - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(assetIssueList.getAssetIssueCount() >= 1); - Integer times = assetIssueList.getAssetIssueCount(); - if (assetIssueList.getAssetIssueCount() >= 10) { - times = 10; - } - for (Integer j = 0; j < times; j++) { - Assert.assertFalse(assetIssueList.getAssetIssue(j).getOwnerAddress().isEmpty()); - Assert.assertFalse(assetIssueList.getAssetIssue(j).getName().isEmpty()); - Assert.assertFalse(assetIssueList.getAssetIssue(j).getUrl().isEmpty()); - Assert.assertTrue(assetIssueList.getAssetIssue(j).getTotalSupply() > 0); - logger.info("test get all assetissue"); - } - - //Improve coverage. - assetIssueList.equals(assetIssueList); - assetIssueList.equals(null); - GrpcAPI.AssetIssueList newAssetIssueList = blockingStubFull - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - assetIssueList.equals(newAssetIssueList); - assetIssueList.hashCode(); - assetIssueList.getSerializedSize(); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, byte[] from, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue004.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue004.java deleted file mode 100644 index 4be3f2a73a8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue004.java +++ /dev/null @@ -1,305 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - //testng001、testng002、testng003、testng004 - /* private static final byte[] fromAddress = Base58 - .decodeFromBase58Check("THph9K2M2nLvkianrMGswRhz5hjSA9fuH7");*/ - private static final byte[] NO_ASSET_ADDRESS = Base58 - .decodeFromBase58Check("27XeWZUtufGk8jdjF3m1tuPnnRqqKgzS3pT"); - private static final byte[] INVALID_ADDRESS = Base58 - .decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - - private static final long now = System.currentTimeMillis(); - private static final String name = "testAssetIssue004_" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - ByteString addressBs1 = ByteString.copyFrom(fromAddress); - Account request1 = Account.newBuilder().setAddress(addressBs1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - //Create a new asset issue - Assert.assertTrue(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 6, 1000, - start, end, 2, description, url, 10000L, 10000L, - 1L, 1L, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } else { - logger.info("This account already create an assetisue"); - } - - } - - @Test(enabled = true, description = "Get asset issue by account") - public void testGetAssetIssueByAccount() { - ByteString addressBs = ByteString.copyFrom(fromAddress); - Account request = Account.newBuilder().setAddress(addressBs).build(); - GrpcAPI.AssetIssueList assetIssueList = blockingStubFull - .getAssetIssueByAccount(request); - Optional queryAssetIssueByAccount = Optional.ofNullable(assetIssueList); - logger.info(Integer.toString(queryAssetIssueByAccount.get().getAssetIssueCount())); - Assert.assertTrue(queryAssetIssueByAccount.get().getAssetIssueCount() == 1); - for (Integer j = 0; j < queryAssetIssueByAccount.get().getAssetIssueCount(); j++) { - if (queryAssetIssueByAccount.get().getAssetIssue(j).getTotalSupply() == totalSupply) { - Assert.assertTrue(queryAssetIssueByAccount.isPresent()); - //Assert.assertTrue(queryAssetIssueByAccount.get().getAssetIssue(j).getDecayRatio() > 0); - Assert.assertTrue(queryAssetIssueByAccount.get().getAssetIssue(j).getTrxNum() > 0); - Assert.assertTrue(queryAssetIssueByAccount.get().getAssetIssue(j).getVoteScore() > 0); - Assert.assertFalse(queryAssetIssueByAccount.get().getAssetIssue(j).getUrl().isEmpty()); - logger.info("TestGetAssetIssueByAccount ok!"); - } - } - - //No exception when the address didn't create asset issue. - ByteString addressBS1 = ByteString.copyFrom(NO_ASSET_ADDRESS); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryNoAssetByAccount = Optional.ofNullable(assetIssueList1); - Assert.assertTrue(queryNoAssetByAccount.get().getAssetIssueCount() == 0); - logger.info("No asset account queryed nothing"); - - //No exception when the address is invalid. - addressBS1 = ByteString.copyFrom(INVALID_ADDRESS); - request1 = Account.newBuilder().setAddress(addressBS1).build(); - assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - queryNoAssetByAccount = Optional.ofNullable(assetIssueList1); - Assert.assertTrue(queryNoAssetByAccount.get().getAssetIssueCount() == 0); - logger.info("No asset account queryed nothing"); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long fronzenAmount, Long frozenDay, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(20000); - builder.setPublicFreeAssetNetLimit(20000); - Contract.AssetIssueContract.FrozenSupply.Builder - frozenBuilder = Contract.AssetIssueContract.FrozenSupply - .newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue005.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue005.java deleted file mode 100644 index 084fddb69b1..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue005.java +++ /dev/null @@ -1,305 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue005_" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Get asset issue by name") - public void testGetAssetIssueByName() { - ByteString addressBS1 = ByteString.copyFrom(fromAddress); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - //Create a new asset issue - Assert.assertTrue(PublicMethed.createAssetIssue(fromAddress, name, totalSupply, 1, 100, - start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } else { - logger.info("This account already create an assetisue"); - Optional queryAssetByAccount1 = Optional.ofNullable(assetIssueList1); - name = ByteArray.toStr(queryAssetByAccount1.get().getAssetIssue(0).getName().toByteArray()); - } - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(testKey002, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Get asset issue by name success. - - GrpcAPI.BytesMessage request = GrpcAPI.BytesMessage.newBuilder().setValue(assetAccountId) - .build(); - Contract.AssetIssueContract assetIssueByName = - blockingStubFull.getAssetIssueByName(request); - - Assert.assertFalse(assetIssueByName.getUrl().isEmpty()); - Assert.assertFalse(assetIssueByName.getDescription().isEmpty()); - Assert.assertTrue(assetIssueByName.getTotalSupply() > 0); - Assert.assertTrue(assetIssueByName.getTrxNum() > 0); - - //Get asset issue by name failed when the name is not correct.There is no exception. - String wrongName = name + "_wrong"; - ByteString assetNameBs = ByteString.copyFrom(name.getBytes()); - assetNameBs = ByteString.copyFrom(wrongName.getBytes()); - request = GrpcAPI.BytesMessage.newBuilder().setValue(assetNameBs).build(); - assetIssueByName = blockingStubFull.getAssetIssueByName(request); - - Assert.assertFalse(assetIssueByName.getTotalSupply() > 0); - Assert.assertFalse(assetIssueByName.getTrxNum() > 0); - Assert.assertTrue(assetIssueByName.getUrl().isEmpty()); - Assert.assertTrue(assetIssueByName.getDescription().isEmpty()); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long fronzenAmount, Long frozenDay, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(20000); - builder.setPublicFreeAssetNetLimit(20000); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply - .newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null || transaction.getRawData().getContractCount() == 0"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue006.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue006.java deleted file mode 100644 index 980b11a6d7b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue006.java +++ /dev/null @@ -1,221 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - private static final long now = System.currentTimeMillis(); - private static String name = "assetissue006" + Long.toString(now); - private static final long totalSupply = now; - String description = "test query assetissue by timestamp from soliditynode"; - String url = "https://testqueryassetissue.com/bytimestamp/from/soliditynode/"; - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] queryAssetIssueFromSoliAddress = ecKey.getAddress(); - String queryAssetIssueKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - - } - - /* @Test(enabled = true) - public void testGetAssetIssueListByTimestamp() { - Assert.assertTrue(PublicMethed.freezeBalance(fromAddress,10000000,3,testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(queryAssetIssueFromSoliAddress,2048000000,fromAddress, - testKey002,blockingStubFull)); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(queryAssetIssueFromSoliAddress, name, - totalSupply, 1, 100, start, end, 1, description, url, 1000L, - 1000L,1L,1L,queryAssetIssueKey,blockingStubFull)); - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Block solidityCurrentBlock = blockingStubSolidity.getNowBlock(GrpcAPI.EmptyMessage - .newBuilder().build()); - Integer wait = 0; - while (solidityCurrentBlock.getBlockHeader().getRawData().getNumber() - < currentBlock.getBlockHeader().getRawData().getNumber() + 1 && wait < 10) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("Solidity didn't synchronize the fullnode block,please wait"); - solidityCurrentBlock = blockingStubSolidity.getNowBlock(GrpcAPI.EmptyMessage.newBuilder() - .build()); - wait++; - if (wait == 9) { - logger.info("Didn't syn,skip to next case."); - } - } - - - long time = now; - NumberMessage.Builder timeStamp = NumberMessage.newBuilder(); - timeStamp.setNum(time); - GrpcAPI.AssetIssueList assetIssueList = blockingStubSolidity - .getAssetIssueListByTimestamp(timeStamp.build()); - Optional getAssetIssueListByTimestamp = Optional - .ofNullable(assetIssueList); - - Assert.assertTrue(getAssetIssueListByTimestamp.isPresent()); - Assert.assertTrue(getAssetIssueListByTimestamp.get().getAssetIssueCount() > 0); - logger.info(Integer.toString(getAssetIssueListByTimestamp.get().getAssetIssueCount())); - for (Integer j = 0; j < getAssetIssueListByTimestamp.get().getAssetIssueCount(); j++) { - Assert.assertFalse(getAssetIssueListByTimestamp.get().getAssetIssue(j).getName().isEmpty()); - Assert.assertTrue(getAssetIssueListByTimestamp.get().getAssetIssue(j).getTotalSupply() > 0); - Assert.assertTrue(getAssetIssueListByTimestamp.get().getAssetIssue(j).getNum() > 0); - logger.info( - Long.toString(getAssetIssueListByTimestamp.get().getAssetIssue(j).getTotalSupply())); - } - - } - - @Test(enabled = true) - public void testExceptionGetAssetIssueListByTimestamp() { - //Time stamp is below zero. - long time = -1000000000; - NumberMessage.Builder timeStamp = NumberMessage.newBuilder(); - timeStamp.setNum(time); - GrpcAPI.AssetIssueList assetIssueList = blockingStubSolidity - .getAssetIssueListByTimestamp(timeStamp.build()); - Optional getAssetIssueListByTimestamp = Optional - .ofNullable(assetIssueList); - Assert.assertTrue(getAssetIssueListByTimestamp.get().getAssetIssueCount() == 0); - - //No asset issue was create - time = 1000000000; - timeStamp = NumberMessage.newBuilder(); - timeStamp.setNum(time); - assetIssueList = blockingStubSolidity.getAssetIssueListByTimestamp(timeStamp.build()); - getAssetIssueListByTimestamp = Optional.ofNullable(assetIssueList); - Assert.assertTrue(getAssetIssueListByTimestamp.get().getAssetIssueCount() == 0); - - }*/ - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue007.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue007.java deleted file mode 100644 index b0d9d3e8f56..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue007.java +++ /dev/null @@ -1,177 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue007_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - private static final Integer trxNum = 1; - private static final Integer icoNum = 1; - - Long freeAssetNetLimit = 10000L; - Long publicFreeAssetNetLimit = 10000L; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset007Address = ecKey1.getAddress(); - String testKeyForAssetIssue007 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] participateAssetAddress = ecKey2.getAddress(); - String participateAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForAssetIssue007); - PublicMethed.printAddress(participateAssetCreateKey); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Participate asset issue use participate bandwidth") - public void testParticipateAssetIssueUseParticipateBandwidth() { - Assert.assertTrue(PublicMethed - .sendcoin(asset007Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 5000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed - .createAssetIssue(asset007Address, name, totalSupply, trxNum, icoNum, start, end, 1, - description, url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, - testKeyForAssetIssue007, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info(name); - //Assert.assertTrue(PublicMethed.waitProduceNextBlock(blockingStubFull)); - //When no balance, participate an asset issue - Assert.assertFalse(PublicMethed.participateAssetIssue(asset007Address, name.getBytes(), - 1L, participateAssetAddress, participateAssetCreateKey, blockingStubFull)); - - ByteString addressBs = ByteString.copyFrom(asset007Address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - AccountNetMessage asset007NetMessage = blockingStubFull.getAccountNet(request); - final Long asset007BeforeFreeNetUsed = asset007NetMessage.getFreeNetUsed(); - - //SendCoin to participate account. - Assert.assertTrue(PublicMethed.sendcoin(participateAssetAddress, 10000000L, - fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - addressBs = ByteString.copyFrom(participateAssetAddress); - request = Account.newBuilder().setAddress(addressBs).build(); - AccountNetMessage participateAccountNetMessage = blockingStubFull.getAccountNet(request); - final Long participateAccountBeforeNetUsed = participateAccountNetMessage.getFreeNetUsed(); - Assert.assertTrue(participateAccountBeforeNetUsed == 0); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset007Address, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - logger.info(assetAccountId.toString()); - - //Participate an assetIssue, then query the net information. - Assert.assertTrue(PublicMethed.participateAssetIssue( - asset007Address, assetAccountId.toByteArray(), - 1L, participateAssetAddress, participateAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - addressBs = ByteString.copyFrom(asset007Address); - request = Account.newBuilder().setAddress(addressBs).build(); - asset007NetMessage = blockingStubFull.getAccountNet(request); - final Long asset007AfterFreeNetUsed = asset007NetMessage.getFreeNetUsed(); - - addressBs = ByteString.copyFrom(participateAssetAddress); - request = Account.newBuilder().setAddress(addressBs).build(); - participateAccountNetMessage = blockingStubFull.getAccountNet(request); - final Long participateAccountAfterNetUsed = participateAccountNetMessage.getFreeNetUsed(); - - logger.info(Long.toString(asset007BeforeFreeNetUsed)); - logger.info(Long.toString(asset007AfterFreeNetUsed)); - logger.info(Long.toString(participateAccountBeforeNetUsed)); - logger.info(Long.toString(participateAccountAfterNetUsed)); - Assert.assertTrue(asset007AfterFreeNetUsed <= asset007BeforeFreeNetUsed); - Assert.assertTrue(participateAccountAfterNetUsed - participateAccountBeforeNetUsed > 150); - - Assert.assertTrue(PublicMethed.participateAssetIssue( - asset007Address, assetAccountId.toByteArray(), - 1L, participateAssetAddress, participateAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.participateAssetIssue( - asset007Address, assetAccountId.toByteArray(), - 1L, participateAssetAddress, participateAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account participateInfo = PublicMethed - .queryAccount(participateAssetCreateKey, blockingStubFull); - final Long beforeBalance = participateInfo.getBalance(); - Assert.assertTrue(PublicMethed.participateAssetIssue( - asset007Address, assetAccountId.toByteArray(), - 1L, participateAssetAddress, participateAssetCreateKey, blockingStubFull)); - participateInfo = PublicMethed.queryAccount(participateAssetCreateKey, blockingStubFull); - final Long afterBalance = participateInfo.getBalance(); - - Assert.assertTrue(beforeBalance - trxNum * 1 * icoNum >= afterBalance); - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue008.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue008.java deleted file mode 100644 index b2453ee4f2a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue008.java +++ /dev/null @@ -1,284 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue008 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - private static final long now = System.currentTimeMillis(); - private static String name = "assetissue008" + Long.toString(now); - private static final long totalSupply = now; - String description = "test query assetissue from soliditynode"; - String url = "https://testqueryassetissue.com/from/soliditynode/"; - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] queryAssetIssueFromSoliAddress = ecKey.getAddress(); - String queryAssetIssueKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(ByteArray.toHexString(ecKey.getPrivKeyBytes())); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test(enabled = true, description = "Get asset issue list from Solidity") - public void testGetAllAssetIssueFromSolidity() { - Assert.assertTrue(PublicMethed.sendcoin(queryAssetIssueFromSoliAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(queryAssetIssueFromSoliAddress, name, - totalSupply, 1, 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, queryAssetIssueKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - GrpcAPI.AssetIssueList assetIssueList = blockingStubSolidity - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - logger.info(Long.toString(assetIssueList.getAssetIssueCount())); - - if (assetIssueList.getAssetIssueCount() == 0) { - Assert.assertTrue(PublicMethed.freezeBalance(fromAddress, 10000000L, 3, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 999999L, fromAddress, - testKey002, blockingStubFull)); - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - logger.info("fullnode block num is " + Long.toString(currentBlock.getBlockHeader() - .getRawData().getNumber())); - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity); - } - - assetIssueList = blockingStubSolidity - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(assetIssueList.getAssetIssueCount() >= 1); - for (Integer j = 0; j < assetIssueList.getAssetIssueCount(); j++) { - Assert.assertFalse(assetIssueList.getAssetIssue(j).getOwnerAddress().isEmpty()); - Assert.assertFalse(assetIssueList.getAssetIssue(j).getName().isEmpty()); - Assert.assertFalse(assetIssueList.getAssetIssue(j).getUrl().isEmpty()); - Assert.assertTrue(assetIssueList.getAssetIssue(j).getTotalSupply() > 0); - logger.info("test get all assetissue from solidity"); - } - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Account search = queryAccount(ecKey, blockingStubFull); - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue009.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue009.java deleted file mode 100644 index 904ec6fac4e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue009.java +++ /dev/null @@ -1,175 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - /* @Test(enabled = true) - public void testGetAssetIssueByAccountOrNameFromSolidity() { - //By name - ByteString addressBs = ByteString.copyFrom(fromAddress); - Account request = Account.newBuilder().setAddress(addressBs).build(); - GrpcAPI.AssetIssueList assetIssueList = blockingStubSolidity - .getAssetIssueByAccount(request); - Optional queryAssetIssueByAccount = Optional.ofNullable(assetIssueList); - logger.info(Integer.toString(queryAssetIssueByAccount.get().getAssetIssueCount())); - Assert.assertTrue(queryAssetIssueByAccount.get().getAssetIssueCount() >= 1); - for (Integer j = 0; j < queryAssetIssueByAccount.get().getAssetIssueCount(); j++) { - Assert.assertTrue(queryAssetIssueByAccount.get().getAssetIssue(j).getTotalSupply() > 0); - Assert.assertFalse(queryAssetIssueByAccount.get().getAssetIssue(j).getName().isEmpty()); - logger.info("TestGetAssetIssueByAccount in soliditynode ok!!!"); - - } - - //By ID - ByteString assetName = queryAssetIssueByAccount.get().getAssetIssue(0).getName(); - GrpcAPI.BytesMessage requestAsset = GrpcAPI.BytesMessage.newBuilder().setValue(assetName) - .build(); - Contract.AssetIssueContract assetIssueByName = blockingStubSolidity - .getAssetIssueByName(requestAsset); - - Assert.assertFalse(assetIssueByName.getUrl().isEmpty()); - Assert.assertFalse(assetIssueByName.getDescription().isEmpty()); - Assert.assertTrue(assetIssueByName.getTotalSupply() > 0); - Assert.assertTrue(assetIssueByName.getTrxNum() > 0); - - logger.info("TestGetAssetIssueByNameFromSolidity"); - }*/ - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue010.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue010.java deleted file mode 100644 index c56d915c1eb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue010.java +++ /dev/null @@ -1,440 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue010 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue010_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - String updateDescription = "This is test for update asset issue, case AssetIssue_010"; - String updateUrl = "www.updateassetissue.010.cn"; - private static final String tooLongDescription = - "1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcv" - + "qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswe" - + "dcvqazxswedcvqazxswedcvqazxswedcvqazxswedcv"; - private static final String tooLongUrl = "qaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqas" - + "wqaswqasw1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazx" - + "swedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedc" - + "vqazxswedcvqazxswedcvqazxswedcvqazxswedcv"; - - Long freeAssetNetLimit = 1000L; - Long publicFreeAssetNetLimit = 1000L; - Long updateFreeAssetNetLimit = 10001L; - Long updatePublicFreeAssetNetLimit = 10001L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] asset010Address = ecKey.getAddress(); - String testKeyForAssetIssue010 = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Update asset issue") - public void testUpdateAssetIssue() { - ecKey = new ECKey(Utils.getRandom()); - asset010Address = ecKey.getAddress(); - testKeyForAssetIssue010 = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(testKeyForAssetIssue010); - - Assert.assertTrue(PublicMethed - .sendcoin(asset010Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalance(asset010Address, 200000000L, 3, testKeyForAssetIssue010, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(asset010Address, name, totalSupply, 1, 1, - start, end, 1, description, url, freeAssetNetLimit, publicFreeAssetNetLimit, - 1L, 1L, testKeyForAssetIssue010, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed - .queryAccount(testKeyForAssetIssue010, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Query the description and url,freeAssetNetLimit and publicFreeAssetNetLimit - GrpcAPI.BytesMessage request = GrpcAPI.BytesMessage.newBuilder() - .setValue(assetAccountId).build(); - Contract.AssetIssueContract assetIssueByName = blockingStubFull.getAssetIssueByName(request); - - Assert.assertTrue( - ByteArray.toStr(assetIssueByName.getDescription().toByteArray()).equals(description)); - Assert.assertTrue(ByteArray.toStr(assetIssueByName.getUrl().toByteArray()).equals(url)); - Assert.assertTrue(assetIssueByName.getFreeAssetNetLimit() == freeAssetNetLimit); - Assert.assertTrue(assetIssueByName.getPublicFreeAssetNetLimit() == publicFreeAssetNetLimit); - - //Test update asset issue - Assert.assertTrue(PublicMethed - .updateAsset(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), - updateFreeAssetNetLimit, - updatePublicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //After update asset issue ,query the description and url, - // freeAssetNetLimit and publicFreeAssetNetLimit - assetIssueByName = blockingStubFull.getAssetIssueByName(request); - - Assert.assertTrue( - ByteArray.toStr(assetIssueByName.getDescription().toByteArray()).equals(updateDescription)); - Assert.assertTrue(ByteArray.toStr(assetIssueByName.getUrl().toByteArray()).equals(updateUrl)); - Assert.assertTrue(assetIssueByName.getFreeAssetNetLimit() == updateFreeAssetNetLimit); - Assert - .assertTrue(assetIssueByName.getPublicFreeAssetNetLimit() == updatePublicFreeAssetNetLimit); - } - - @Test(enabled = true, description = "Update asset issue with exception condition") - public void testUpdateAssetIssueException() { - //Test update asset issue for wrong parameter - //publicFreeAssetNetLimit is -1 - Assert.assertFalse(PublicMethed - .updateAsset(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), - updateFreeAssetNetLimit, - -1L, testKeyForAssetIssue010, blockingStubFull)); - //publicFreeAssetNetLimit is 0 - Assert.assertTrue(PublicMethed - .updateAsset(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), - updateFreeAssetNetLimit, - 0, testKeyForAssetIssue010, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //FreeAssetNetLimit is -1 - Assert.assertFalse(PublicMethed - .updateAsset(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), -1, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - //FreeAssetNetLimit is 0 - Assert.assertTrue(PublicMethed - .updateAsset(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), 0, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Description is null - Assert.assertTrue(PublicMethed - .updateAsset(asset010Address, "".getBytes(), updateUrl.getBytes(), freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - //Url is null - Assert.assertFalse(PublicMethed - .updateAsset(asset010Address, description.getBytes(), "".getBytes(), freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - //Too long discription - Assert.assertFalse(PublicMethed - .updateAsset(asset010Address, tooLongDescription.getBytes(), url.getBytes(), - freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - //Too long URL - Assert.assertFalse(PublicMethed - .updateAsset(asset010Address, description.getBytes(), tooLongUrl.getBytes(), - freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long fronzenAmount, Long frozenDay, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = PublicMethed.queryAccount(priKey, blockingStubFull); - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply - .newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, byte[] from, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue011.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue011.java deleted file mode 100644 index a5bde1d6cfa..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue011.java +++ /dev/null @@ -1,140 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue011_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final String updateMostLongName = Long.toString(now) + "w234567890123456789"; - - Long freeAssetNetLimit = 10000L; - Long publicFreeAssetNetLimit = 10000L; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset011Address = ecKey1.getAddress(); - String testKeyForAssetIssue011 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetCreateAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForAssetIssue011); - PublicMethed.printAddress(transferAssetCreateKey); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Transfer asset to create account") - public void testTransferAssetCreateAccount() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - asset011Address = ecKey1.getAddress(); - testKeyForAssetIssue011 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - transferAssetCreateAddress = ecKey2.getAddress(); - transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed - .sendcoin(asset011Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalance(asset011Address, 100000000L, 3, testKeyForAssetIssue011, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed - .createAssetIssue(asset011Address, name, totalSupply, 1, 1, start, end, 1, description, - url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, testKeyForAssetIssue011, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset011Address, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Transfer asset to create an account. - Assert.assertTrue(PublicMethed - .transferAsset(transferAssetCreateAddress, assetAccountId.toByteArray(), 1L, - asset011Address, testKeyForAssetIssue011, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account queryTransferAssetAccount = PublicMethed - .queryAccount(transferAssetCreateKey, blockingStubFull); - Assert.assertTrue(queryTransferAssetAccount.getAssetV2Count() == 1); - Assert.assertTrue(PublicMethed.updateAccount(asset011Address, Long.toString(now) - .getBytes(), testKeyForAssetIssue011, blockingStubFull)); - Assert.assertTrue(PublicMethed.updateAccount(transferAssetCreateAddress, updateMostLongName - .getBytes(), transferAssetCreateKey, blockingStubFull)); - queryTransferAssetAccount = PublicMethed.queryAccount(transferAssetCreateKey, blockingStubFull); - Assert.assertFalse(queryTransferAssetAccount.getAccountName().isEmpty()); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue012.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue012.java deleted file mode 100644 index 217d6896907..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue012.java +++ /dev/null @@ -1,163 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue012 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue012_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 10000L; - Long publicFreeAssetNetLimit = 10000L; - String description = "for case assetissue012"; - String url = "https://stest.assetissue012.url"; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset012Address = ecKey1.getAddress(); - String testKeyForAssetIssue012 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(testKeyForAssetIssue012); - logger.info(transferAssetCreateKey); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Transfer asset use token owner net") - public void testTransferAssetUseCreatorNet() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - asset012Address = ecKey1.getAddress(); - testKeyForAssetIssue012 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - transferAssetAddress = ecKey2.getAddress(); - transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(testKeyForAssetIssue012); - PublicMethed.printAddress(transferAssetCreateKey); - - Assert.assertTrue(PublicMethed - .sendcoin(asset012Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalance(asset012Address, 100000000L, 3, testKeyForAssetIssue012, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed - .createAssetIssue(asset012Address, name, totalSupply, 1, 1, start, end, 1, description, - url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, testKeyForAssetIssue012, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset012Address, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Transfer asset to an account. - Assert.assertTrue(PublicMethed.transferAsset( - transferAssetAddress, assetAccountId.toByteArray(), 10000000L, asset012Address, - testKeyForAssetIssue012, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Before transfer asset issue, query the net used from creator and transfer. - AccountNetMessage assetCreatorNet = PublicMethed - .getAccountNet(asset012Address, blockingStubFull); - AccountNetMessage assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorBeforeNetUsed = assetCreatorNet.getNetUsed(); - Long transferBeforeFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorBeforeNetUsed)); - logger.info(Long.toString(transferBeforeFreeNetUsed)); - - //Transfer send some asset issue to default account, to test if this - // transaction use the creator net. - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetCreatorNet = PublicMethed - .getAccountNet(asset012Address, blockingStubFull); - assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorAfterNetUsed = assetCreatorNet.getNetUsed(); - Long transferAfterFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorAfterNetUsed)); - logger.info(Long.toString(transferAfterFreeNetUsed)); - - Assert.assertTrue(creatorAfterNetUsed - creatorBeforeNetUsed > netCostMeasure); - Assert.assertTrue(transferAfterFreeNetUsed - transferBeforeFreeNetUsed < netCostMeasure); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue013.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue013.java deleted file mode 100644 index 2bb13a76847..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue013.java +++ /dev/null @@ -1,165 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue013 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue013_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 300L; - Long publicFreeAssetNetLimit = 3000L; - String description = "for case assetissue013"; - String url = "https://stest.assetissue013.url"; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset013Address = ecKey1.getAddress(); - String testKeyForAssetIssue013 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Use transfer net when token owner has no enough net") - public void testWhenNoEnoughFreeAssetNetLimitUseTransferNet() { - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset013Address = ecKey1.getAddress(); - final String testKeyForAssetIssue013 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - final byte[] transferAssetAddress = ecKey2.getAddress(); - final String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - logger.info(testKeyForAssetIssue013); - logger.info(transferAssetCreateKey); - - Assert.assertTrue(PublicMethed - .sendcoin(asset013Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalance(asset013Address, 100000000L, 3, testKeyForAssetIssue013, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed - .createAssetIssue(asset013Address, name, totalSupply, 1, 1, start, end, 1, description, - url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, testKeyForAssetIssue013, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset013Address, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Transfer asset to an account. - Assert.assertTrue(PublicMethed.transferAsset( - transferAssetAddress, assetAccountId.toByteArray(), - 10000000L, asset013Address, testKeyForAssetIssue013, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Transfer send some asset issue to default account, to test if this - // transaction use the creator net. - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Before use transfer net, query the net used from creator and transfer. - AccountNetMessage assetCreatorNet = PublicMethed - .getAccountNet(asset013Address, blockingStubFull); - AccountNetMessage assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorBeforeNetUsed = assetCreatorNet.getNetUsed(); - Long transferBeforeFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorBeforeNetUsed)); - logger.info(Long.toString(transferBeforeFreeNetUsed)); - - //Transfer send some asset issue to default account, to test if this - // transaction use the transaction free net. - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - assetCreatorNet = PublicMethed - .getAccountNet(asset013Address, blockingStubFull); - assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorAfterNetUsed = assetCreatorNet.getNetUsed(); - Long transferAfterFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorAfterNetUsed)); - logger.info(Long.toString(transferAfterFreeNetUsed)); - - Assert.assertTrue(creatorAfterNetUsed - creatorBeforeNetUsed < netCostMeasure); - Assert.assertTrue(transferAfterFreeNetUsed - transferBeforeFreeNetUsed > netCostMeasure); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue014.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue014.java deleted file mode 100644 index 16b2c227ab4..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue014.java +++ /dev/null @@ -1,161 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue014 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue014_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 3000L; - Long publicFreeAssetNetLimit = 300L; - String description = "for case assetissue014"; - String url = "https://stest.assetissue014.url"; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset014Address = ecKey1.getAddress(); - String testKeyForAssetIssue014 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(testKeyForAssetIssue014); - logger.info(transferAssetCreateKey); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Use transfer net when no enough public free asset net") - public void testWhenNoEnoughPublicFreeAssetNetLimitUseTransferNet() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - asset014Address = ecKey1.getAddress(); - testKeyForAssetIssue014 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - transferAssetAddress = ecKey2.getAddress(); - transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed - .sendcoin(asset014Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed - .createAssetIssue(asset014Address, name, totalSupply, 1, 1, start, end, 1, description, - url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, testKeyForAssetIssue014, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset014Address, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Transfer asset to an account. - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .transferAsset(transferAssetAddress, assetAccountId.toByteArray(), 10000000L, - asset014Address, testKeyForAssetIssue014, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Transfer send some asset issue to default account, to test if this - // transaction use the creator net. - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Before use transfer net, query the net used from creator and transfer. - AccountNetMessage assetCreatorNet = PublicMethed - .getAccountNet(asset014Address, blockingStubFull); - AccountNetMessage assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorBeforeNetUsed = assetCreatorNet.getNetUsed(); - Long transferBeforeFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorBeforeNetUsed)); - logger.info(Long.toString(transferBeforeFreeNetUsed)); - - //Transfer send some asset issue to default account, to test if this - // transaction use the transaction free net. - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetCreatorNet = PublicMethed - .getAccountNet(asset014Address, blockingStubFull); - assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorAfterNetUsed = assetCreatorNet.getNetUsed(); - Long transferAfterFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorAfterNetUsed)); - logger.info(Long.toString(transferAfterFreeNetUsed)); - - Assert.assertTrue(creatorAfterNetUsed - creatorBeforeNetUsed < netCostMeasure); - Assert.assertTrue(transferAfterFreeNetUsed - transferBeforeFreeNetUsed > netCostMeasure); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue015.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue015.java deleted file mode 100644 index e1a5ff7addf..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue015.java +++ /dev/null @@ -1,228 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue015 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue015_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 30000L; - Long publicFreeAssetNetLimit = 30000L; - String description = "for case assetissue015"; - String url = "https://stest.assetissue015.url"; - ByteString assetAccountId; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset015Address = ecKey1.getAddress(); - String testKeyForAssetIssue015 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] newAddress = ecKey3.getAddress(); - String testKeyForNewAddress = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(testKeyForAssetIssue015); - logger.info(transferAssetCreateKey); - logger.info(testKeyForNewAddress); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Use transfer net when token owner has not enough bandwidth") - public void atestWhenCreatorHasNoEnoughBandwidthUseTransferNet() { - ecKey1 = new ECKey(Utils.getRandom()); - asset015Address = ecKey1.getAddress(); - testKeyForAssetIssue015 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - transferAssetAddress = ecKey2.getAddress(); - transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - newAddress = ecKey3.getAddress(); - testKeyForNewAddress = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed - .sendcoin(asset015Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed - .createAssetIssue(asset015Address, name, totalSupply, 1, 1, start, end, 1, description, - url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, testKeyForAssetIssue015, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset015Address, blockingStubFull); - assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - //Transfer asset to an account. - Assert.assertTrue(PublicMethed - .transferAsset(transferAssetAddress, assetAccountId.toByteArray(), 10000000L, - asset015Address, testKeyForAssetIssue015, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Before use transfer net, query the net used from creator and transfer. - AccountNetMessage assetCreatorNet = PublicMethed - .getAccountNet(asset015Address, blockingStubFull); - AccountNetMessage assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorBeforeFreeNetUsed = assetCreatorNet.getFreeNetUsed(); - Long transferBeforeFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorBeforeFreeNetUsed)); - logger.info(Long.toString(transferBeforeFreeNetUsed)); - - //Transfer send some asset issue to default account, to test if this - // transaction use the transaction free net. - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetCreatorNet = PublicMethed - .getAccountNet(asset015Address, blockingStubFull); - assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Long creatorAfterFreeNetUsed = assetCreatorNet.getFreeNetUsed(); - Long transferAfterFreeNetUsed = assetTransferNet.getFreeNetUsed(); - logger.info(Long.toString(creatorAfterFreeNetUsed)); - logger.info(Long.toString(transferAfterFreeNetUsed)); - - Assert.assertTrue(creatorAfterFreeNetUsed - creatorBeforeFreeNetUsed < netCostMeasure); - Assert.assertTrue(transferAfterFreeNetUsed - transferBeforeFreeNetUsed > netCostMeasure); - } - - @Test(enabled = true, description = "Use balance when transfer has not enough net") - public void btestWhenTransferHasNoEnoughBandwidthUseBalance() { - Integer i = 0; - AccountNetMessage assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - while (assetTransferNet.getNetUsed() < 4700 && i++ < 200) { - PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull); - assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - } - - logger.info(Long.toString(assetTransferNet.getFreeNetUsed())); - Assert.assertTrue(assetTransferNet.getFreeNetUsed() >= 4700); - - Assert.assertTrue(PublicMethed.sendcoin(transferAssetAddress, - 20000000, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account transferAccount = PublicMethed.queryAccount(transferAssetCreateKey, blockingStubFull); - Long beforeBalance = transferAccount.getBalance(); - logger.info(Long.toString(beforeBalance)); - - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - transferAccount = PublicMethed.queryAccount(transferAssetCreateKey, blockingStubFull); - Long afterBalance = transferAccount.getBalance(); - logger.info(Long.toString(afterBalance)); - - Assert.assertTrue(beforeBalance - afterBalance > 2000); - } - - @Test(enabled = true, description = "Transfer asset use bandwidth when freeze balance") - public void ctestWhenFreezeBalanceUseNet() { - Assert.assertTrue(PublicMethed.freezeBalance(transferAssetAddress, 5000000, - 3, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountNetMessage assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - Account transferAccount = PublicMethed.queryAccount(transferAssetCreateKey, blockingStubFull); - - final Long transferNetUsedBefore = assetTransferNet.getNetUsed(); - final Long transferBalanceBefore = transferAccount.getBalance(); - logger.info("before " + Long.toString(transferBalanceBefore)); - - Assert.assertTrue(PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 1L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetTransferNet = PublicMethed - .getAccountNet(transferAssetAddress, blockingStubFull); - transferAccount = PublicMethed.queryAccount(transferAssetCreateKey, blockingStubFull); - final Long transferNetUsedAfter = assetTransferNet.getNetUsed(); - final Long transferBalanceAfter = transferAccount.getBalance(); - logger.info("after " + Long.toString(transferBalanceAfter)); - - Assert.assertTrue(transferBalanceAfter - transferBalanceBefore == 0); - Assert.assertTrue(transferNetUsedAfter - transferNetUsedBefore > 200); - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue016.java b/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue016.java deleted file mode 100644 index 5b8b23a98e7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/assetissue/WalletTestAssetIssue016.java +++ /dev/null @@ -1,169 +0,0 @@ -package stest.tron.wallet.dailybuild.assetissue; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue016 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue016_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 30000L; - Long publicFreeAssetNetLimit = 30000L; - String description = "for case assetissue016"; - String url = "https://stest.assetissue016.url"; - ByteString assetAccountId; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset016Address = ecKey1.getAddress(); - String testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Get asset issue net resource") - public void testGetAssetIssueNet() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - asset016Address = ecKey1.getAddress(); - testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - transferAssetAddress = ecKey2.getAddress(); - transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(testKeyForAssetIssue016); - PublicMethed.printAddress(transferAssetCreateKey); - - Assert.assertTrue(PublicMethed - .sendcoin(asset016Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed - .createAssetIssue(asset016Address, name, totalSupply, 1, 1, start, end, 1, description, - url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, testKeyForAssetIssue016, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset016Address, blockingStubFull); - assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - AccountNetMessage assetIssueInfo = PublicMethed - .getAccountNet(asset016Address, blockingStubFull); - Assert.assertTrue(assetIssueInfo.getAssetNetLimitCount() == 1); - Assert.assertTrue(assetIssueInfo.getAssetNetUsedCount() == 1); - Assert.assertFalse(assetIssueInfo.getAssetNetLimitMap().isEmpty()); - Assert.assertFalse(assetIssueInfo.getAssetNetUsedMap().isEmpty()); - - GrpcAPI.BytesMessage request = GrpcAPI.BytesMessage.newBuilder() - .setValue(assetAccountId).build(); - Contract.AssetIssueContract assetIssueByName = blockingStubFull.getAssetIssueByName(request); - Assert.assertTrue(assetIssueByName.getFreeAssetNetLimit() == freeAssetNetLimit); - Assert.assertTrue(assetIssueByName.getPublicFreeAssetNetLimit() == publicFreeAssetNetLimit); - Assert.assertTrue(assetIssueByName.getPublicLatestFreeNetTime() == 0); - assetIssueInfo.hashCode(); - assetIssueInfo.getSerializedSize(); - assetIssueInfo.equals(assetIssueInfo); - - PublicMethed.transferAsset(transferAssetAddress, assetAccountId.toByteArray(), 1000L, - asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 100L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetIssueByName = blockingStubFull.getAssetIssueByName(request); - Assert.assertTrue(assetIssueByName.getPublicLatestFreeNetTime() == 0); - Assert.assertTrue(assetIssueByName.getPublicFreeAssetNetUsage() == 0); - - Assert.assertTrue(PublicMethed.freezeBalance(asset016Address, 30000000L, - 3, testKeyForAssetIssue016, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.transferAsset(toAddress, assetAccountId.toByteArray(), 100L, - transferAssetAddress, transferAssetCreateKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetIssueByName = blockingStubFull.getAssetIssueByName(request); - Assert.assertTrue(assetIssueByName.getPublicLatestFreeNetTime() > 0); - Assert.assertTrue(assetIssueByName.getPublicFreeAssetNetUsage() > 150); - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction001.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction001.java deleted file mode 100644 index dd960b90ab8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction001.java +++ /dev/null @@ -1,428 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Objects; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -//import org.tron.protos.Protocol.DeferredTransaction; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class DelayTransaction001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - - - public static final long MAX_DEFERRED_TRANSACTION_DELAY_SECONDS = 45 * 24 * 3_600L; //45 days - Optional infoById = null; - //Optional deferredTransactionById = null; - Optional getTransactionById = null; - - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] delayAccount1Address = ecKey.getAddress(); - String delayAccount1Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] receiverAccountAddress = ecKey3.getAddress(); - String receiverAccountKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] delayAccount3Address = ecKey4.getAddress(); - String delayAccount3Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] receiverAccount4Address = ecKey5.getAddress(); - String receiverAccount4Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delayed send coin to test delayed second") - public void test1DelayedSecond() { - //get account - ecKey = new ECKey(Utils.getRandom()); - delayAccount1Address = ecKey.getAddress(); - delayAccount1Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount1Key); - Assert.assertTrue(PublicMethed.sendcoin(delayAccount1Address, 100000000L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.sendcoinDelayed(fromAddress, 100000000L, 23L, - delayAccount1Address, delayAccount1Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoinDelayed(fromAddress, 1L, 0L,delayAccount1Address, - delayAccount1Key, blockingStubFull)); - Assert.assertFalse(PublicMethed.sendcoinDelayed(fromAddress, 1L, -1L,delayAccount1Address, - delayAccount1Key, blockingStubFull)); - Assert.assertFalse(PublicMethed.sendcoinDelayed(fromAddress, 1L, - MAX_DEFERRED_TRANSACTION_DELAY_SECONDS + 1L,delayAccount1Address, delayAccount1Key, - blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoinDelayed(fromAddress, 1L, - MAX_DEFERRED_TRANSACTION_DELAY_SECONDS,delayAccount1Address, delayAccount1Key, - blockingStubFull)); - } - - /* - @Test(enabled = false, description = "Get deferred transaction by id") - public void test2getDeferredTransactionByid() { - //get account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - receiverAccountAddress = ecKey3.getAddress(); - receiverAccountKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount2Key); - PublicMethed.printAddress(receiverAccountKey); - - //Pre sendcoin to the test account - Assert.assertTrue(PublicMethed.sendcoin(delayAccount2Address, 100000000L,fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(receiverAccountAddress, 10L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Do delay send coin transaction. - Long delaySecond = 10L; - Long sendCoinAmout = 100L; - - //Query balance before send coin. - Long deplayAccountBeforeBalance = PublicMethed.queryAccount( - delayAccount2Address, blockingStubFull).getBalance(); - Long recevierAccountBeforeBalance = PublicMethed.queryAccount( - receiverAccountAddress, blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - String txid = PublicMethed.sendcoinDelayedGetTxid(receiverAccountAddress, - sendCoinAmout, delaySecond,delayAccount2Address, - delayAccount2Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance when pre-sendcoin stage. - Long deplayAccountInDelayBalance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Long recevierAccountInDelayalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountInDelayBalance " + deplayAccountInDelayBalance); - logger.info("recevierAccountInDelayalance " + recevierAccountInDelayalance); - Assert.assertTrue(recevierAccountBeforeBalance == recevierAccountInDelayalance); - //Assert.assertTrue(); - - - deferredTransactionById = PublicMethed.getDeferredTransactionById(txid,blockingStubFull); - DeferredTransaction transaction = deferredTransactionById.get(); - String finalTxid = ByteArray.toHexString(Sha256Hash.hash(transaction.getTransaction() - .getRawData().toByteArray())); - PublicMethed.getDeferredTransactionById(finalTxid,blockingStubFull); - logger.info(finalTxid); - //logger.info("receiver address is " + Base58.encode58Check(transaction.getReceiverAddress() - .toByteArray())); - Assert.assertTrue(Base58.encode58Check(transaction.getReceiverAddress().toByteArray()) - .equalsIgnoreCase(PublicMethed.getAddressString(receiverAccountKey))); - //logger.info("sender address is " + Base58.encode58Check(transaction.getSenderAddress() - .toByteArray())); - Assert.assertTrue(Base58.encode58Check(transaction.getSenderAddress().toByteArray()) - .equalsIgnoreCase(PublicMethed.getAddressString(delayAccount2Key))); - // logger.info("delaySeconds is " + transaction.getDelaySeconds()); - Assert.assertTrue(delaySecond == transaction.getDelaySeconds()); - //logger.info("DelayUntil " + transaction.getDelayUntil()); - Assert.assertTrue(transaction.getDelayUntil() > System.currentTimeMillis()); - //logger.info("Expiration " + transaction.getExpiration()); - Assert.assertTrue(transaction.getExpiration() > System.currentTimeMillis()); - //logger.info("PublishTime " + transaction.getPublishTime()); - Assert.assertTrue(transaction.getPublishTime() < System.currentTimeMillis()); - //Assert.assertTrue(transaction.getDelayUntil() + 60000 == transaction.getExpiration()); - getTransactionById = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("transaction stage in txid is " + getTransactionById.get().getRawData() - .getDeferredStage().getStage()); - - Assert.assertTrue(getTransactionById.get().getRawData().getDeferredStage().getStage() == 1); - getTransactionById = PublicMethed.getTransactionById(finalTxid, blockingStubFull); - logger.info("transaction stage in final id is " + getTransactionById.get().getRawData() - .getDeferredStage().getStage()); - Assert.assertTrue(getTransactionById.get().getRawData().getDeferredStage().getStage() == 0); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed.getDeferredTransactionById(finalTxid,blockingStubFull); - deferredTransactionById = PublicMethed.getDeferredTransactionById(txid,blockingStubFull); - finalTxid = ByteArray.toHexString(Sha256Hash.hash(transaction.getTransaction().getRawData() - .toByteArray())); - transaction = deferredTransactionById.get(); - logger.info(finalTxid); - //logger.info("receiver address is " + Base58.encode58Check(transaction - .getReceiverAddress().toByteArray())); - //logger.info("receiver address is " + Base58.encode58Check(transaction - .getSenderAddress().toByteArray())); - //logger.info("delaySeconds is " + transaction.getDelaySeconds()); - //logger.info("DelayUntil " + transaction.getDelayUntil()); - //logger.info("Expiration " + transaction.getExpiration()); - //logger.info("PublishTime " + transaction.getPublishTime()); - getTransactionById = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("transaction stage in txid is " + getTransactionById.get().getRawData() - .getDeferredStage().getStage()); - getTransactionById = PublicMethed.getTransactionById(finalTxid, blockingStubFull); - logger.info("transaction stage in final id is " + getTransactionById.get() - .getRawData().getDeferredStage().getStage()); - - - - //Query balance after delay send coin. - Long deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Long recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - - Assert.assertTrue(deplayAccountBeforeBalance - deplayAccountAfterBalance == sendCoinAmout - + 100000L); - Assert.assertTrue(recevierAccountAfterDelayalance - recevierAccountBeforeBalance == - sendCoinAmout); - - - - }*/ - - @Test(enabled = false, description = "Delay send coin") - public void test3DelaySendCoin() { - ecKey4 = new ECKey(Utils.getRandom()); - delayAccount3Address = ecKey4.getAddress(); - delayAccount3Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount3Key); - - ecKey5 = new ECKey(Utils.getRandom()); - receiverAccount4Address = ecKey5.getAddress(); - receiverAccount4Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - PublicMethed.printAddress(receiverAccount4Key); - - Long sendCoinAmount = 100000000L; - //Pre sendcoin to the test account - Assert.assertTrue(PublicMethed.sendcoin(delayAccount3Address, sendCoinAmount,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("----------------No balance to send coin--------------------"); - //Do delay send coin transaction. - Long delaySecond = 4L; - - //Test no balance to send coin. - //Query balance before send coin. - Long deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - Long recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - Assert.assertFalse(PublicMethed.sendcoinDelayed(receiverAccount4Address, sendCoinAmount, - delaySecond,delayAccount3Address, delayAccount3Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance after delay send coin. - Long deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - Long recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - - Assert.assertTrue(recevierAccountAfterDelayalance == 0); - logger.info("deplayAccountBeforeBalance: " + deplayAccountBeforeBalance); - logger.info("deplayAccountAfterBalance: " + deplayAccountAfterBalance); - - Assert.assertEquals(deplayAccountBeforeBalance,deplayAccountAfterBalance); - - - logger.info("----------------No balance to create account send coin--------------------"); - //Test delay send coin to create account. - deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - - Long createAccountFee = 100000L; - Assert.assertTrue(PublicMethed.sendcoinDelayed(receiverAccount4Address, - deplayAccountBeforeBalance - createAccountFee, delaySecond,delayAccount3Address, - delayAccount3Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance after delay send coin. - deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - - Assert.assertTrue(recevierAccountAfterDelayalance == 0); - Assert.assertTrue(deplayAccountBeforeBalance - deplayAccountAfterBalance == 100000); - - - logger.info("---------------Balance enough to create account send coin--------------------"); - //Test delay send coin to create account. - createAccountFee = 100000L; - deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - Assert.assertTrue(PublicMethed.sendcoinDelayed(receiverAccount4Address, - deplayAccountBeforeBalance - createAccountFee - delayTransactionFee, - delaySecond,delayAccount3Address, delayAccount3Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance after delay send coin. - deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - Long receiverBalanceShouldBe = deplayAccountBeforeBalance - createAccountFee - - delayTransactionFee; - - Assert.assertEquals(recevierAccountAfterDelayalance, receiverBalanceShouldBe); - Assert.assertTrue(deplayAccountAfterBalance == 0); - - - } - - @Test(enabled = false, description = "Not enough money to send coin.") - public void test4DelaySendCoin() { - ecKey4 = new ECKey(Utils.getRandom()); - delayAccount3Address = ecKey4.getAddress(); - delayAccount3Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount3Key); - - ecKey5 = new ECKey(Utils.getRandom()); - receiverAccount4Address = ecKey5.getAddress(); - receiverAccount4Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - PublicMethed.printAddress(receiverAccount4Key); - - Long sendCoinAmount = 100000000L; - //Pre sendcoin to the test account - Assert.assertTrue(PublicMethed.sendcoin(delayAccount3Address, sendCoinAmount, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(receiverAccount4Address, sendCoinAmount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Do delay send coin transaction. - Long createAccountFee = 100000L; - - logger.info("----------------Send all balance to exist account--------------------"); - //Test no balance to send coin. - //Query balance before send coin. - Long deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - Long recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - - Long delaySecond = 4L; - Assert.assertTrue(PublicMethed.sendcoinDelayed(receiverAccount4Address, sendCoinAmount, - delaySecond,delayAccount3Address, delayAccount3Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance after delay send coin. - Long deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - Long recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - - Assert.assertTrue(recevierAccountAfterDelayalance == 0); - logger.info("deplayAccountBeforeBalance: " + deplayAccountBeforeBalance); - logger.info("deplayAccountAfterBalance: " + deplayAccountAfterBalance); - - Assert.assertEquals(deplayAccountBeforeBalance,deplayAccountAfterBalance); - - - - } - - - - - /** - * constructor. - */ - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction002.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction002.java deleted file mode 100644 index 00195a0c031..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction002.java +++ /dev/null @@ -1,255 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -//import org.tron.protos.Protocol.DeferredTransaction; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; - -@Slf4j -public class DelayTransaction002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - - - - Optional infoById = null; - //Optional deferredTransactionById = null; - Optional getTransactionById = null; - - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] delayAccount1Address = ecKey.getAddress(); - String delayAccount1Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] receiverAccountAddress = ecKey3.getAddress(); - String receiverAccountKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] delayAccount3Address = ecKey4.getAddress(); - String delayAccount3Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] receiverAccount4Address = ecKey5.getAddress(); - String receiverAccount4Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Cancel deferred transaction") - public void test1CancleDeferredTransaction() { - //get account - ecKey = new ECKey(Utils.getRandom()); - delayAccount1Address = ecKey.getAddress(); - delayAccount1Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount1Key); - ecKey3 = new ECKey(Utils.getRandom()); - receiverAccountAddress = ecKey3.getAddress(); - receiverAccountKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(receiverAccountKey); - - Assert.assertTrue(PublicMethed.sendcoin(delayAccount1Address, 100000000L,fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(receiverAccountAddress, 100L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Do delay send coin transaction. - Long delaySecond = 10L; - Long sendCoinAmount = 1L; - - //Query balance before send coin. - Long deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount1Address, - blockingStubFull).getBalance(); - Long recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - String txid = PublicMethed.sendcoinDelayedGetTxid(receiverAccountAddress, sendCoinAmount, - delaySecond,delayAccount1Address, - delayAccount1Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //deferredTransactionById = PublicMethed.getDeferredTransactionById(txid,blockingStubFull); - //DeferredTransaction transaction = deferredTransactionById.get(); - //String finalTxid = ByteArray.toHexString(Sha256Hash.hash(transaction.getTransaction() - // .getRawData().toByteArray())); - - //Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(finalTxid,receiverAccountAddress - // ,receiverAccountKey,blockingStubFull)); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,receiverAccountAddress, - receiverAccountKey,blockingStubFull)); - Assert.assertTrue(PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address, - delayAccount1Key,blockingStubFull)); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address, - delayAccount1Key,blockingStubFull)); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount1Address, - blockingStubFull).getBalance(); - Long recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - //Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address, - // delayAccount1Key,blockingStubFull)); - //PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - // blockingStubFull); - //PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - // blockingStubFull); - //PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - // blockingStubFull); - //PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - // blockingStubFull); - //PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address,delayAccount1Key, - // blockingStubFull); - - - Assert.assertTrue(deplayAccountBeforeBalance - deplayAccountAfterBalance - == delayTransactionFee + cancleDelayTransactionFee); - Assert.assertTrue(recevierAccountBeforeBalance == recevierAccountAfterDelayalance); - - } - - @Test(enabled = false, description = "Cancel deferred transaction") - public void test2CancleDeferredTransactionQuickly() { - //get account - ecKey = new ECKey(Utils.getRandom()); - delayAccount1Address = ecKey.getAddress(); - delayAccount1Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount1Key); - ecKey3 = new ECKey(Utils.getRandom()); - receiverAccountAddress = ecKey3.getAddress(); - receiverAccountKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(receiverAccountKey); - - Assert.assertTrue(PublicMethed.sendcoin(delayAccount1Address, 100000000L,fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(receiverAccountAddress, 100L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Do delay send coin transaction. - Long delaySecond = 10L; - Long sendCoinAmount = 1000L; - - //Query balance before send coin. - Long deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount1Address, - blockingStubFull).getBalance(); - Long recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - String txid = PublicMethed.sendcoinDelayedGetTxid(receiverAccountAddress, sendCoinAmount, - delaySecond,delayAccount1Address, - delayAccount1Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,receiverAccountAddress, - receiverAccountKey,blockingStubFull)); - Assert.assertTrue(PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address, - delayAccount1Key,blockingStubFull)); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address, - delayAccount1Key,blockingStubFull)); - //PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount1Address, - blockingStubFull).getBalance(); - Long recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,delayAccount1Address, - delayAccount1Key,blockingStubFull)); - - - Assert.assertTrue(deplayAccountBeforeBalance - deplayAccountAfterBalance - == delayTransactionFee + cancleDelayTransactionFee); - Assert.assertTrue(recevierAccountBeforeBalance == recevierAccountAfterDelayalance); - - - } - - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction003.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction003.java deleted file mode 100644 index 7d914804fb7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction003.java +++ /dev/null @@ -1,216 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -//import org.tron.protos.Protocol.DeferredTransaction; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; - -@Slf4j -public class DelayTransaction003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static final long now = System.currentTimeMillis(); - private static final long totalSupply = now; - private static final String name = "Asset008_" + Long.toString(now); - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - Long delaySecond = 10L; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - ByteString assetId; - - - - Optional infoById = null; - //Optional deferredTransactionById = null; - Optional getTransactionById = null; - - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] assetOwnerAddress = ecKey.getAddress(); - String assetOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] receiverAssetAddress = ecKey3.getAddress(); - String receiverassetKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delay transfer asset") - public void test1DelayTransferAsset() { - //get account - ecKey = new ECKey(Utils.getRandom()); - assetOwnerAddress = ecKey.getAddress(); - assetOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(assetOwnerKey); - ecKey3 = new ECKey(Utils.getRandom()); - receiverAssetAddress = ecKey3.getAddress(); - receiverassetKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(receiverassetKey); - - Assert.assertTrue(PublicMethed.sendcoin(assetOwnerAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Create test token. - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(assetOwnerAddress, - name, totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 100000L, 1L, - assetOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account assetOwnerAccount = PublicMethed.queryAccount(assetOwnerKey, blockingStubFull); - assetId = assetOwnerAccount.getAssetIssuedID(); - - //Delay transfer asset - Long transferAssetAmount = 1L; - final Long ownerAssetBalanceOfbeforeTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId, assetOwnerKey,blockingStubFull); - final Long receiverAssetBalanceOfbeforeTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,receiverassetKey,blockingStubFull); - Assert.assertTrue(PublicMethed.transferAssetDelay(receiverAssetAddress, assetId.toByteArray(), - transferAssetAmount, delaySecond,assetOwnerAddress, assetOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long ownerAssetBalanceInDelayTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,assetOwnerKey,blockingStubFull); - final Long receiverAssetBalanceInDelayTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,receiverassetKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long ownerAssetBalanceAfterTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,assetOwnerKey,blockingStubFull); - Long receiverAssetBalanceAfterTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,receiverassetKey,blockingStubFull); - - - Assert.assertEquals(ownerAssetBalanceOfbeforeTransferAsset, - ownerAssetBalanceInDelayTransferAsset); - Assert.assertTrue(receiverAssetBalanceOfbeforeTransferAsset - == receiverAssetBalanceInDelayTransferAsset); - Assert.assertTrue(ownerAssetBalanceInDelayTransferAsset - transferAssetAmount - == ownerAssetBalanceAfterTransferAsset); - Assert.assertTrue(receiverAssetBalanceAfterTransferAsset == transferAssetAmount); - - } - - - @Test(enabled = false, description = "Cancel delay transfer asset") - public void test2CancelDelayTransferAsset() { - - - //Delay transfer asset - Long transferAssetAmount = 1L; - final Long ownerAssetBalanceOfbeforeTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId, assetOwnerKey,blockingStubFull); - final Long receiverAssetBalanceOfbeforeTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,receiverassetKey,blockingStubFull); - - String txid = PublicMethed.transferAssetDelayGetTxid(receiverAssetAddress, - assetId.toByteArray(), transferAssetAmount, delaySecond,assetOwnerAddress, assetOwnerKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,receiverAssetAddress, - // receiverassetKey,blockingStubFull)); - Assert.assertTrue(PublicMethed.cancelDeferredTransactionById(txid,assetOwnerAddress, - assetOwnerKey,blockingStubFull)); - //Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,assetOwnerAddress, - // assetOwnerKey,blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long ownerAssetBalanceAfterTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,assetOwnerKey,blockingStubFull); - Long receiverAssetBalanceAfterTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId,receiverassetKey,blockingStubFull); - - - Assert.assertEquals(ownerAssetBalanceOfbeforeTransferAsset, ownerAssetBalanceAfterTransferAsset - ); - Assert.assertTrue(receiverAssetBalanceAfterTransferAsset - == receiverAssetBalanceOfbeforeTransferAsset); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,assetOwnerAddress, - assetOwnerKey,blockingStubFull)); - - } - - @Test(enabled = false, description = "Delay unfreeze asset") - public void test3DelayUnfreezeAsset() { - - final Long ownerAssetBalanceOfbeforeTransferAsset = PublicMethed - .getAssetBalanceByAssetId(assetId, assetOwnerKey,blockingStubFull); - - String txid = PublicMethed.unfreezeAssetDelayGetTxid(assetOwnerAddress,delaySecond, - assetOwnerKey,blockingStubFull); - - - - } - - - - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction004.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction004.java deleted file mode 100644 index 5134a548d9a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction004.java +++ /dev/null @@ -1,199 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -//import org.tron.protos.Protocol.DeferredTransaction; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class DelayTransaction004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static final long now = System.currentTimeMillis(); - Long delaySecond = 10L; - - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - ByteString assetId; - private byte[] contractAddress = null; - SmartContract smartContract; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] smartContractOwnerAddress = ecKey.getAddress(); - String smartContractOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delay update setting contract") - public void test1DelayUpdateSetting() { - //get account - ecKey = new ECKey(Utils.getRandom()); - smartContractOwnerAddress = ecKey.getAddress(); - smartContractOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(smartContractOwnerKey); - - - Assert.assertTrue(PublicMethed.sendcoin(smartContractOwnerAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - //PublicMethed.freezeBalance(smartContractOwnerAddress,10000000L,3, - // smartContractOwnerKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName = "TRONTOKEN"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_ContractScenario004_deployErc20TronToken"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_ContractScenario004_deployErc20TronToken"); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 999L,"0",0,null, - smartContractOwnerKey, smartContractOwnerAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Long oldContractPercent = smartContract.getConsumeUserResourcePercent(); - Assert.assertTrue(PublicMethed.updateSetting(contractAddress,oldContractPercent, - smartContractOwnerKey,smartContractOwnerAddress,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getConsumeUserResourcePercent() == oldContractPercent); - - Long newContractPercent = 39L; - final String txid = PublicMethed.updateSettingDelayGetTxid(contractAddress,newContractPercent, - delaySecond,smartContractOwnerKey,smartContractOwnerAddress,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getConsumeUserResourcePercent() == oldContractPercent); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - logger.info("newContractPercent: " + smartContract.getConsumeUserResourcePercent()); - Assert.assertTrue(smartContract.getConsumeUserResourcePercent() == newContractPercent); - - Long netFee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getReceipt() - .getNetFee(); - Long fee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getFee(); - Assert.assertTrue(fee - netFee == delayTransactionFee); - Long afterFreeNetUsaged = PublicMethed.queryAccount(smartContractOwnerKey, - blockingStubFull).getFreeNetUsage(); - Long beforeFreeNetUsaged = PublicMethed.queryAccount(smartContractOwnerKey, - blockingStubFull).getFreeNetUsage(); - Long inDelayFreeNetUsaged = PublicMethed.queryAccount(smartContractOwnerKey, - blockingStubFull).getFreeNetUsage(); - logger.info("beforeFreeNetUsaged: " + beforeFreeNetUsaged); - logger.info("inDelayFreeNetUsaged: " + inDelayFreeNetUsaged); - logger.info("afterFreeNetUsaged: " + afterFreeNetUsaged); - Assert.assertTrue(beforeFreeNetUsaged + 50 < inDelayFreeNetUsaged); - Assert.assertTrue(inDelayFreeNetUsaged + 50 < afterFreeNetUsaged); - - } - - @Test(enabled = false, description = "Cancel delay update setting contract") - public void test2CancelDelayUpdateSetting() { - //get account - final Long oldContractPercent = smartContract.getConsumeUserResourcePercent(); - final Long newContractPercent = 46L; - - String txid = PublicMethed.updateSettingDelayGetTxid(contractAddress,newContractPercent, - delaySecond,smartContractOwnerKey,smartContractOwnerAddress,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account ownerAccount = PublicMethed.queryAccount(smartContractOwnerKey,blockingStubFull); - final Long beforeCancelBalance = ownerAccount.getBalance(); - - - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,fromAddress,testKey002, - blockingStubFull)); - final String cancelTxid = PublicMethed.cancelDeferredTransactionByIdGetTxid(txid, - smartContractOwnerAddress,smartContractOwnerKey,blockingStubFull); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,smartContractOwnerAddress, - smartContractOwnerKey,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - logger.info("newContractPercent: " + smartContract.getConsumeUserResourcePercent()); - Assert.assertTrue(smartContract.getConsumeUserResourcePercent() == oldContractPercent); - - final Long netFee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getReceipt().getNetFee(); - final Long fee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getFee(); - logger.info("net fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getReceipt().getNetFee()); - logger.info("Fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getFee()); - - ownerAccount = PublicMethed.queryAccount(smartContractOwnerKey,blockingStubFull); - Long afterCancelBalance = ownerAccount.getBalance(); - Assert.assertTrue(fee - netFee == cancleDelayTransactionFee); - Assert.assertTrue(fee == beforeCancelBalance - afterCancelBalance); - - logger.info("beforeCancelBalance: " + beforeCancelBalance); - logger.info("afterCancelBalance : " + afterCancelBalance); - } - - - - - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction005.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction005.java deleted file mode 100644 index 76a9220cc68..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction005.java +++ /dev/null @@ -1,181 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class DelayTransaction005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static final long now = System.currentTimeMillis(); - Long delaySecond = 10L; - - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - ByteString assetId; - private byte[] contractAddress = null; - SmartContract smartContract; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] smartContractOwnerAddress = ecKey.getAddress(); - String smartContractOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delay update energy limit contract") - public void test1DelayUpdateSetting() { - //get account - ecKey = new ECKey(Utils.getRandom()); - smartContractOwnerAddress = ecKey.getAddress(); - smartContractOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(smartContractOwnerKey); - - - Assert.assertTrue(PublicMethed.sendcoin(smartContractOwnerAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.freezeBalance(smartContractOwnerAddress,10000000L,3, - smartContractOwnerKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName = "TRONTOKEN"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_ContractScenario004_deployErc20TronToken"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_ContractScenario004_deployErc20TronToken"); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 999L,"0",0,null, - smartContractOwnerKey, smartContractOwnerAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Long oldOriginEnergyLimit = 567L; - Assert.assertTrue(PublicMethed.updateEnergyLimit(contractAddress,oldOriginEnergyLimit, - smartContractOwnerKey,smartContractOwnerAddress,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getOriginEnergyLimit() == oldOriginEnergyLimit); - - Long newOriginEnergyLimit = 8765L; - final String txid = PublicMethed.updateEnergyLimitDelayGetTxid(contractAddress, - newOriginEnergyLimit, delaySecond,smartContractOwnerKey,smartContractOwnerAddress, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getOriginEnergyLimit() == oldOriginEnergyLimit); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - logger.info("newOriginEnergyLimit: " + smartContract.getOriginEnergyLimit()); - Assert.assertTrue(smartContract.getOriginEnergyLimit() == newOriginEnergyLimit); - - Long netFee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getReceipt() - .getNetFee(); - Long fee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getFee(); - Assert.assertTrue(fee - netFee == delayTransactionFee); - - } - - @Test(enabled = false, description = "Cancel delay energy limit contract") - public void test2CancelDelayUpdateSetting() { - //get account - final Long oldOriginEnergyLimit = smartContract.getOriginEnergyLimit(); - final Long newOriginEnergyLimit = 466L; - - String txid = PublicMethed.updateEnergyLimitDelayGetTxid(contractAddress,newOriginEnergyLimit, - delaySecond,smartContractOwnerKey,smartContractOwnerAddress,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account ownerAccount = PublicMethed.queryAccount(smartContractOwnerKey,blockingStubFull); - final Long beforeCancelBalance = ownerAccount.getBalance(); - - - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,fromAddress,testKey002, - blockingStubFull)); - final String cancelTxid = PublicMethed.cancelDeferredTransactionByIdGetTxid(txid, - smartContractOwnerAddress,smartContractOwnerKey,blockingStubFull); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,smartContractOwnerAddress, - smartContractOwnerKey,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - logger.info("newOriginEnergyLimit: " + smartContract.getOriginEnergyLimit()); - Assert.assertTrue(smartContract.getOriginEnergyLimit() == oldOriginEnergyLimit); - - final Long netFee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getReceipt().getNetFee(); - final Long fee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getFee(); - logger.info("net fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getReceipt().getNetFee()); - logger.info("Fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getFee()); - - ownerAccount = PublicMethed.queryAccount(smartContractOwnerKey,blockingStubFull); - Long afterCancelBalance = ownerAccount.getBalance(); - Assert.assertTrue(fee - netFee == cancleDelayTransactionFee); - Assert.assertTrue(fee == beforeCancelBalance - afterCancelBalance); - - logger.info("beforeCancelBalance: " + beforeCancelBalance); - logger.info("afterCancelBalance : " + afterCancelBalance); - } - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction006.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction006.java deleted file mode 100644 index 14e7122ae0e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction006.java +++ /dev/null @@ -1,196 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class DelayTransaction006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static final long now = System.currentTimeMillis(); - private static final long totalSupply = now; - private static final String name = "Asset008_" + Long.toString(now); - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - Long delaySecond = 10L; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - ByteString assetId; - private byte[] contractAddress = null; - SmartContract smartContract; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] assetOwnerAddress = ecKey.getAddress(); - String assetOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delay update asset contract") - public void test1DelayUpdateSetting() { - //get account - ecKey = new ECKey(Utils.getRandom()); - assetOwnerAddress = ecKey.getAddress(); - assetOwnerKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(assetOwnerKey); - - - Assert.assertTrue(PublicMethed.sendcoin(assetOwnerAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - - final Long oldFreeAssetNetLimit = 2000L; - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(assetOwnerAddress, - name, totalSupply, 1, 1, start, end, 1, description, url, - oldFreeAssetNetLimit, 2000L, 1L, 1L, - assetOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account assetOwnerAccount = PublicMethed.queryAccount(assetOwnerKey, blockingStubFull); - assetId = assetOwnerAccount.getAssetIssuedID(); - String newAssetUrl = "new.url"; - String newAssetDescription = "new.description"; - - final Long newFreeAssetNetLimit = 3333L; - final String txid = PublicMethed.updateAssetDelay(assetOwnerAddress, - newAssetDescription.getBytes(), newAssetUrl.getBytes(),newFreeAssetNetLimit, - 23L,delaySecond,assetOwnerKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.getAssetIssueById(ByteArray.toStr(assetId - .toByteArray()),blockingStubFull).getFreeAssetNetLimit() == oldFreeAssetNetLimit); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.getAssetIssueById(ByteArray.toStr(assetId - .toByteArray()),blockingStubFull).getFreeAssetNetLimit() == newFreeAssetNetLimit); - Long afterNetUsaged = PublicMethed.queryAccount(assetOwnerKey,blockingStubFull) - .getFreeNetUsage(); - Long netFee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get() - .getReceipt().getNetFee(); - Long fee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getFee(); - Long beforeNetUsaged = PublicMethed.queryAccount(assetOwnerKey,blockingStubFull) - .getFreeNetUsage(); - Long inDelayNetUsaged = PublicMethed.queryAccount(assetOwnerKey,blockingStubFull) - .getFreeNetUsage(); - Assert.assertTrue(fee - netFee == delayTransactionFee); - Assert.assertTrue(beforeNetUsaged + 50 < inDelayNetUsaged); - Assert.assertTrue(inDelayNetUsaged + 50 < afterNetUsaged); - - } - - @Test(enabled = false, description = "Cancel delay asset setting contract") - public void test2CancelDelayUpdateAsset() { - //get account - final Long oldFreeAssetNetLimit = PublicMethed.getAssetIssueById(assetId.toStringUtf8(), - blockingStubFull).getFreeAssetNetLimit(); - final Long newFreeAssetNetLimit = 461L; - - String newAssetUrl = "new.url"; - String newAssetDescription = "new.description"; - logger.info("Before delay net usage: " + PublicMethed.queryAccount(assetOwnerKey, - blockingStubFull).getFreeNetUsage()); - String txid = PublicMethed.updateAssetDelay(assetOwnerAddress,newAssetDescription.getBytes(), - newAssetUrl.getBytes(),newFreeAssetNetLimit,23L,delaySecond,assetOwnerKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("In delay net usage: " + PublicMethed.queryAccount(assetOwnerKey,blockingStubFull) - .getFreeNetUsage()); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,fromAddress,testKey002, - blockingStubFull)); - final String cancelTxid = PublicMethed.cancelDeferredTransactionByIdGetTxid(txid, - assetOwnerAddress,assetOwnerKey,blockingStubFull); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,assetOwnerAddress, - assetOwnerKey,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("After cancle net usage: " + PublicMethed.queryAccount(assetOwnerKey, - blockingStubFull).getFreeNetUsage()); - - Assert.assertTrue(PublicMethed.getAssetIssueById(assetId.toStringUtf8(), - blockingStubFull).getFreeAssetNetLimit() == oldFreeAssetNetLimit); - - final Long netFee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getReceipt().getNetFee(); - final Long fee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getFee(); - logger.info("net fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getReceipt().getNetFee()); - logger.info("Fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getFee()); - - Assert.assertTrue(fee - netFee == cancleDelayTransactionFee); - - Long afterNetUsaged = PublicMethed.queryAccount(assetOwnerKey,blockingStubFull) - .getFreeNetUsage(); - Long beforeNetUsaged = PublicMethed.queryAccount(assetOwnerKey,blockingStubFull) - .getFreeNetUsage(); - - logger.info("beforeNetUsaged: " + beforeNetUsaged); - logger.info("afterNetUsaged: " + afterNetUsaged); - Assert.assertTrue(beforeNetUsaged >= afterNetUsaged); - - } - - - - - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction007.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction007.java deleted file mode 100644 index a045d8f106a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction007.java +++ /dev/null @@ -1,175 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class DelayTransaction007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static final long now = System.currentTimeMillis(); - private static final long totalSupply = now; - private static final String name = "Asset008_" + Long.toString(now); - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - Long delaySecond = 10L; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - ByteString assetId; - private byte[] contractAddress = null; - SmartContract smartContract; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] doCreateAccountAddress = ecKey.getAddress(); - String doCreateAccountKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] newAccountAddress = ecKey1.getAddress(); - String newAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delay account create contract") - public void test1DelayAccountCreate() { - //get account - ecKey = new ECKey(Utils.getRandom()); - doCreateAccountAddress = ecKey.getAddress(); - doCreateAccountKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(doCreateAccountKey); - - ecKey1 = new ECKey(Utils.getRandom()); - newAccountAddress = ecKey1.getAddress(); - newAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(newAccountKey); - - Assert.assertTrue(PublicMethed.sendcoin(doCreateAccountAddress, 1000000L, fromAddress, - testKey002, blockingStubFull)); - - - Long beforeCreateAccountBalance = PublicMethed.queryAccount(doCreateAccountKey, - blockingStubFull).getBalance(); - final String txid = PublicMethed.createAccountDelayGetTxid(doCreateAccountAddress, - newAccountAddress,delaySecond,doCreateAccountKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.queryAccount(newAccountAddress,blockingStubFull) - .getCreateTime() == 0); - Long balanceInDelay = PublicMethed.queryAccount(doCreateAccountKey,blockingStubFull) - .getBalance(); - Assert.assertTrue(beforeCreateAccountBalance - balanceInDelay == delayTransactionFee); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("create time is " + PublicMethed.queryAccount(newAccountAddress,blockingStubFull) - .getCreateTime()); - Assert.assertTrue(PublicMethed.queryAccount(newAccountAddress,blockingStubFull) - .getCreateTime() > 0); - Long afterCreateAccountBalance = PublicMethed.queryAccount(doCreateAccountKey,blockingStubFull) - .getBalance(); - Long netFee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getReceipt() - .getNetFee(); - Long fee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getFee(); - Assert.assertTrue(fee - netFee == delayTransactionFee); - Assert.assertTrue(beforeCreateAccountBalance - afterCreateAccountBalance - == delayTransactionFee + 100000L); - - } - - @Test(enabled = false, description = "Cancel delay account create contract") - public void test2CancelDelayUpdateSetting() { - ecKey1 = new ECKey(Utils.getRandom()); - newAccountAddress = ecKey1.getAddress(); - newAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(newAccountKey); - - final Long beforeCreateBalance = PublicMethed.queryAccount(doCreateAccountKey,blockingStubFull) - .getBalance(); - final String txid = PublicMethed.createAccountDelayGetTxid(doCreateAccountAddress, - newAccountAddress,delaySecond,doCreateAccountKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,fromAddress,testKey002, - blockingStubFull)); - final String cancelTxid = PublicMethed.cancelDeferredTransactionByIdGetTxid(txid, - doCreateAccountAddress,doCreateAccountKey,blockingStubFull); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,doCreateAccountAddress, - doCreateAccountKey,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final Long afterCreateBalance = PublicMethed.queryAccount(doCreateAccountKey,blockingStubFull) - .getBalance(); - final Long netFee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getReceipt().getNetFee(); - final Long fee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getFee(); - logger.info("net fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getReceipt().getNetFee()); - logger.info("Fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getFee()); - - Assert.assertTrue(fee - netFee == cancleDelayTransactionFee + delayTransactionFee); - Assert.assertTrue(beforeCreateBalance - afterCreateBalance - == cancleDelayTransactionFee + delayTransactionFee); - - } - - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction008.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction008.java deleted file mode 100644 index 37310967ef9..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction008.java +++ /dev/null @@ -1,179 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.nio.charset.Charset; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class DelayTransaction008 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static final long now = System.currentTimeMillis(); - private static final long totalSupply = now; - private static final String name = "Asset008_" + Long.toString(now); - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - Long delaySecond = 10L; - private static String updateAccountName; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - ByteString assetId; - private byte[] contractAddress = null; - SmartContract smartContract; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] doUpdateAccountAddress = ecKey.getAddress(); - String doUpdateAccountKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] newAccountAddress = ecKey1.getAddress(); - String newAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delay account update contract") - public void test1DelayAccountUpdate() { - //get account - ecKey = new ECKey(Utils.getRandom()); - doUpdateAccountAddress = ecKey.getAddress(); - doUpdateAccountKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(doUpdateAccountKey); - - Assert.assertTrue(PublicMethed.sendcoin(doUpdateAccountAddress, 1000000L, fromAddress, - testKey002, blockingStubFull)); - - final Long beforeUpdateAccountBalance = PublicMethed.queryAccount(doUpdateAccountKey, - blockingStubFull).getBalance(); - updateAccountName = "account_" + Long.toString(System.currentTimeMillis()); - byte[] accountNameBytes = ByteArray.fromString(updateAccountName); - final String txid = PublicMethed.updateAccountDelayGetTxid(doUpdateAccountAddress, - accountNameBytes,delaySecond,doUpdateAccountKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String accountName = new String(PublicMethed.queryAccount(doUpdateAccountKey, - blockingStubFull).getAccountName().toByteArray(), Charset.forName("UTF-8")); - Assert.assertTrue(accountName.isEmpty()); - Assert.assertTrue(PublicMethed.queryAccount(newAccountAddress,blockingStubFull) - .getAccountName().isEmpty()); - Long balanceInDelay = PublicMethed.queryAccount(doUpdateAccountKey,blockingStubFull) - .getBalance(); - Assert.assertTrue(beforeUpdateAccountBalance - balanceInDelay == delayTransactionFee); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountName = new String(PublicMethed.queryAccount(doUpdateAccountKey,blockingStubFull) - .getAccountName().toByteArray(), Charset.forName("UTF-8")); - logger.info(accountName); - Assert.assertTrue(accountName.equalsIgnoreCase(updateAccountName)); - Long afterCreateAccountBalance = PublicMethed.queryAccount(doUpdateAccountKey,blockingStubFull) - .getBalance(); - Long netFee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getReceipt() - .getNetFee(); - Long fee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getFee(); - Assert.assertTrue(fee - netFee == delayTransactionFee); - Assert.assertTrue(beforeUpdateAccountBalance - afterCreateAccountBalance - == delayTransactionFee); - - } - - @Test(enabled = false, description = "Cancel delay account update contract") - public void test2CancelDelayUpdateAccount() { - //get account - ecKey = new ECKey(Utils.getRandom()); - doUpdateAccountAddress = ecKey.getAddress(); - doUpdateAccountKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(doUpdateAccountKey); - - final Long beforeUpdateAccountBalance = PublicMethed.queryAccount(doUpdateAccountKey, - blockingStubFull).getBalance(); - updateAccountName = "account_" + Long.toString(System.currentTimeMillis()); - byte[] accountNameBytes = ByteArray.fromString(updateAccountName); - final String txid = PublicMethed.updateAccountDelayGetTxid(doUpdateAccountAddress, - accountNameBytes,delaySecond,doUpdateAccountKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,fromAddress,testKey002, - blockingStubFull)); - final String cancelTxid = PublicMethed.cancelDeferredTransactionByIdGetTxid(txid, - doUpdateAccountAddress,doUpdateAccountKey,blockingStubFull); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,doUpdateAccountAddress, - doUpdateAccountKey,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final Long afterUpdateBalance = PublicMethed.queryAccount(doUpdateAccountKey,blockingStubFull) - .getBalance(); - final Long netFee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getReceipt().getNetFee(); - final Long fee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getFee(); - logger.info("net fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getReceipt().getNetFee()); - logger.info("Fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getFee()); - - Assert.assertTrue(fee - netFee == cancleDelayTransactionFee); - Assert.assertTrue(beforeUpdateAccountBalance - afterUpdateBalance - == cancleDelayTransactionFee + delayTransactionFee); - - } - - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction009.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction009.java deleted file mode 100644 index 70de6066642..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction009.java +++ /dev/null @@ -1,184 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.nio.charset.Charset; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class DelayTransaction009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static final long now = System.currentTimeMillis(); - private static final long totalSupply = now; - private static final String name = "Asset008_" + Long.toString(now); - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - Long delaySecond = 10L; - private static String accountId; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - ByteString assetId; - private byte[] contractAddress = null; - SmartContract smartContract; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] doSetIdAddress = ecKey.getAddress(); - String doSetIdKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] newAccountAddress = ecKey1.getAddress(); - String newAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delay set account id contract") - public void test1DelaySetAccountId() { - //get account - ecKey = new ECKey(Utils.getRandom()); - doSetIdAddress = ecKey.getAddress(); - doSetIdKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(doSetIdKey); - - Assert.assertTrue(PublicMethed.sendcoin(doSetIdAddress, 10000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final Long beforeSetAccountIdBalance = PublicMethed.queryAccount(doSetIdKey, - blockingStubFull).getBalance(); - accountId = "accountId_" + Long.toString(System.currentTimeMillis()); - byte[] accountIdBytes = ByteArray.fromString(accountId); - final String txid = PublicMethed.setAccountIdDelayGetTxid(accountIdBytes, - delaySecond,doSetIdAddress,doSetIdKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String getAccountId = new String(PublicMethed.queryAccount(doSetIdKey, - blockingStubFull).getAccountId().toByteArray(), Charset.forName("UTF-8")); - Assert.assertTrue(getAccountId.isEmpty()); - - Long balanceInDelay = PublicMethed.queryAccount(doSetIdKey,blockingStubFull) - .getBalance(); - Assert.assertTrue(beforeSetAccountIdBalance - balanceInDelay == delayTransactionFee); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - getAccountId = new String(PublicMethed.queryAccount(doSetIdKey,blockingStubFull) - .getAccountId().toByteArray(), Charset.forName("UTF-8")); - logger.info(accountId); - Assert.assertTrue(accountId.equalsIgnoreCase(getAccountId)); - Long afterCreateAccountBalance = PublicMethed.queryAccount(doSetIdKey,blockingStubFull) - .getBalance(); - Long netFee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getReceipt() - .getNetFee(); - Long fee = PublicMethed.getTransactionInfoById(txid,blockingStubFull).get().getFee(); - Assert.assertTrue(fee - netFee == delayTransactionFee); - Assert.assertTrue(beforeSetAccountIdBalance - afterCreateAccountBalance - == delayTransactionFee); - - } - - @Test(enabled = false, description = "Cancel delay set account id contract") - public void test2CancelDelayUpdateAccount() { - //get account - ecKey = new ECKey(Utils.getRandom()); - doSetIdAddress = ecKey.getAddress(); - doSetIdKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(doSetIdKey); - - Assert.assertTrue(PublicMethed.sendcoin(doSetIdAddress, 10000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - - final Long beforeSetAccountIdBalance = PublicMethed.queryAccount(doSetIdKey, - blockingStubFull).getBalance(); - accountId = "accountId_" + Long.toString(System.currentTimeMillis()); - byte[] accountIdBytes = ByteArray.fromString(accountId); - final String txid = PublicMethed.setAccountIdDelayGetTxid(accountIdBytes, - delaySecond,doSetIdAddress,doSetIdKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,fromAddress,testKey002, - blockingStubFull)); - final String cancelTxid = PublicMethed.cancelDeferredTransactionByIdGetTxid(txid, - doSetIdAddress,doSetIdKey,blockingStubFull); - Assert.assertFalse(PublicMethed.cancelDeferredTransactionById(txid,doSetIdAddress, - doSetIdKey,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final Long afterUpdateBalance = PublicMethed.queryAccount(doSetIdKey,blockingStubFull) - .getBalance(); - final Long netFee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getReceipt().getNetFee(); - final Long fee = PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull).get() - .getFee(); - logger.info("net fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getReceipt().getNetFee()); - logger.info("Fee : " + PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getFee()); - - Assert.assertTrue(fee - netFee == cancleDelayTransactionFee); - Assert.assertTrue(beforeSetAccountIdBalance - afterUpdateBalance - == cancleDelayTransactionFee + delayTransactionFee); - - } - - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction010.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction010.java deleted file mode 100644 index 93bd0094b45..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction010.java +++ /dev/null @@ -1,234 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -//import org.tron.protos.Protocol.DeferredTransaction; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; - -@Slf4j -public class DelayTransaction010 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - - public static final long ONE_DELAY_SECONDS = 60 * 60 * 24L; - //Optional deferredTransactionById = null; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] delayFeeAccountAddress = ecKey.getAddress(); - String delayFeeAccountKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "Delayed transaction cost 0.1TRX every day.") - public void test1TestDelayedTransactionFee() { - //get account - ecKey = new ECKey(Utils.getRandom()); - delayFeeAccountAddress = ecKey.getAddress(); - delayFeeAccountKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - delayAccount2Address = ecKey2.getAddress(); - delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - PublicMethed.printAddress(delayFeeAccountKey); - Assert.assertTrue(PublicMethed.sendcoin(delayFeeAccountAddress, 100000000L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - final String txidZeroDay = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, - 0,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - PublicMethed.cancelDeferredTransactionByIdGetTxid(txidZeroDay, - delayFeeAccountAddress,delayFeeAccountKey,blockingStubFull); - final String txidOneDay = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, - ONE_DELAY_SECONDS - 1,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - final String txidTwoDay = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, - ONE_DELAY_SECONDS * 2 - 1,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - final String txidFiveDay = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, - ONE_DELAY_SECONDS * 6 - 1,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - final String txidTenDay = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, - ONE_DELAY_SECONDS * 9,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - final String txid45Day = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, - ONE_DELAY_SECONDS * 45,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - final String txid28Day = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, - ONE_DELAY_SECONDS * 28 - 1000,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.getTransactionInfoById(txidZeroDay,blockingStubFull) - .get().getFee() == delayTransactionFee); - Assert.assertTrue(PublicMethed.getTransactionInfoById(txidOneDay,blockingStubFull) - .get().getFee() == delayTransactionFee); - Assert.assertTrue(PublicMethed.getTransactionInfoById(txidTwoDay,blockingStubFull) - .get().getFee() == delayTransactionFee * 2); - Assert.assertTrue(PublicMethed.getTransactionInfoById(txidFiveDay,blockingStubFull) - .get().getFee() == delayTransactionFee * 6); - Assert.assertTrue(PublicMethed.getTransactionInfoById(txidTenDay,blockingStubFull) - .get().getFee() == delayTransactionFee * 10); - Assert.assertTrue(PublicMethed.getTransactionInfoById(txid45Day,blockingStubFull) - .get().getFee() == delayTransactionFee * 46); - Assert.assertTrue(PublicMethed.getTransactionInfoById(txid28Day,blockingStubFull) - .get().getFee() == delayTransactionFee * 28); - - String cancelTxid = PublicMethed.cancelDeferredTransactionByIdGetTxid(txid28Day, - delayFeeAccountAddress,delayFeeAccountKey,blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.getTransactionInfoById(cancelTxid,blockingStubFull) - .get().getFee() == cancleDelayTransactionFee); - } - - /** - * constructor. - * */ - @Test(enabled = false, description = "Delayed transaction finally fialed.") - public void test2DelaydTransactionFinallyFailed() { - Long sendAmount = 12345L; - Long beforeBalance = PublicMethed.queryAccount(delayFeeAccountAddress,blockingStubFull) - .getBalance(); - final String preTxid = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, sendAmount, - 6L,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //deferredTransactionById = PublicMethed.getDeferredTransactionById(preTxid,blockingStubFull); - //DeferredTransaction transaction = deferredTransactionById.get(); - //String finalTxid = ByteArray.toHexString(Sha256Hash.hash(transaction.getTransaction() - // .getRawData().toByteArray())); - - Assert.assertTrue(PublicMethed.sendcoin(fromAddress,PublicMethed.queryAccount( - delayFeeAccountAddress, blockingStubFull).getBalance(),delayFeeAccountAddress, - delayFeeAccountKey,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Assert.assertTrue(PublicMethed.getTransactionById(finalTxid,blockingStubFull) - // .get().getRawData().getContractCount() == 0); - - Long afterBalance = PublicMethed.queryAccount(delayFeeAccountAddress,blockingStubFull) - .getBalance(); - Long afterSendCoinAccount2Balance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Long beforeSendCoinAccount2Balance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - //Assert.assertTrue(beforeBalance - afterBalance == delayTransactionFee); - Assert.assertTrue(beforeSendCoinAccount2Balance == afterSendCoinAccount2Balance); - } - - /** - * constructor. - * */ - @Test(enabled = false, description = "Delayed transaction finally successfully even during " - + "delaying time the account has no money has no money.") - public void test3DelaydTransactionFinallySuccessfully() { - Assert.assertTrue(PublicMethed.sendcoin(delayFeeAccountAddress,10000000L,fromAddress, - testKey002,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long sendAmount = 5432L; - Long beforeBalance = PublicMethed.queryAccount(delayFeeAccountAddress,blockingStubFull) - .getBalance(); - final String preTxid = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, sendAmount, - 9L,delayFeeAccountAddress, delayFeeAccountKey, blockingStubFull); - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //deferredTransactionById = PublicMethed.getDeferredTransactionById(preTxid,blockingStubFull); - //DeferredTransaction transaction = deferredTransactionById.get(); - //String finalTxid = ByteArray.toHexString(Sha256Hash.hash(transaction.getTransaction() - // .getRawData().toByteArray())); - Assert.assertTrue(PublicMethed.sendcoin(fromAddress,PublicMethed.queryAccount( - delayFeeAccountAddress, blockingStubFull).getBalance(),delayFeeAccountAddress, - delayFeeAccountKey,blockingStubFull)); - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Assert.assertTrue(PublicMethed.sendcoin(delayFeeAccountAddress,10000000L,fromAddress, - testKey002,blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Assert.assertTrue(PublicMethed.getTransactionById(finalTxid,blockingStubFull) - // .get().getRawData().getContractCount() == 1); - - Long afterBalance = PublicMethed.queryAccount(delayFeeAccountAddress,blockingStubFull) - .getBalance(); - Long afterSendCoinAccount2Balance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Long beforeSendCoinAccount2Balance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Assert.assertTrue(beforeSendCoinAccount2Balance + sendAmount == afterSendCoinAccount2Balance); - - } - - - /** - * constructor. - * */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction011.java b/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction011.java deleted file mode 100644 index 2bcbefc9ece..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/delaytransaction/DelayTransaction011.java +++ /dev/null @@ -1,135 +0,0 @@ -package stest.tron.wallet.dailybuild.delaytransaction; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -//import org.tron.protos.Protocol.DeferredTransaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; - -@Slf4j -public class DelayTransaction011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - private Long cancleDelayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.cancleDelayTransactionFee"); - - public static final long ONE_DELAY_SECONDS = 60 * 60 * 24L; - //Optional deferredTransactionById = null; - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] noBandwidthAddress = ecKey.getAddress(); - String noBandwidthKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false, description = "When Bandwidth not enough, create delay transaction.") - public void test1BandwidthInDelayTransaction() { - //get account - ecKey = new ECKey(Utils.getRandom()); - noBandwidthAddress = ecKey.getAddress(); - noBandwidthKey = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - PublicMethed.printAddress(noBandwidthKey); - ecKey2 = new ECKey(Utils.getRandom()); - delayAccount2Address = ecKey2.getAddress(); - delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount2Key); - - - Assert.assertTrue(PublicMethed.sendcoin(noBandwidthAddress, 10000000000L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - while (PublicMethed.queryAccount(noBandwidthAddress,blockingStubFull).getFreeNetUsage() - < 4700L) { - PublicMethed.sendcoin(delayAccount2Address,1L,noBandwidthAddress,noBandwidthKey, - blockingStubFull); - } - PublicMethed.sendcoin(delayAccount2Address,1L,noBandwidthAddress,noBandwidthKey, - blockingStubFull); - PublicMethed.sendcoin(delayAccount2Address,1L,noBandwidthAddress,noBandwidthKey, - blockingStubFull); - Assert.assertTrue(PublicMethed.sendcoin(fromAddress,PublicMethed.queryAccount( - noBandwidthAddress,blockingStubFull).getBalance() - 3000L,noBandwidthAddress, - noBandwidthKey,blockingStubFull)); - logger.info("balance is: " + PublicMethed.queryAccount(noBandwidthAddress, - blockingStubFull).getBalance()); - logger.info("Free net usage is " + PublicMethed.queryAccount(noBandwidthAddress, - blockingStubFull).getFreeNetUsage()); - - String updateAccountName = "account_" + Long.toString(System.currentTimeMillis()); - byte[] accountNameBytes = ByteArray.fromString(updateAccountName); - String txid = PublicMethed.updateAccountDelayGetTxid(noBandwidthAddress,accountNameBytes, - 10L,noBandwidthKey,blockingStubFull); - logger.info(txid); - Assert.assertTrue(PublicMethed.getTransactionById(txid,blockingStubFull) - .get().getRawData().getContractCount() == 0); - - Assert.assertTrue(PublicMethed.sendcoin(noBandwidthAddress, 103332L - 550L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - txid = PublicMethed.updateAccountDelayGetTxid(noBandwidthAddress,accountNameBytes, - 10L,noBandwidthKey,blockingStubFull); - - } - - - /** - * constructor. - * */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/exceptionfee/AssertException.java b/src/test/java/stest/tron/wallet/dailybuild/exceptionfee/AssertException.java deleted file mode 100644 index 4aadedd6cc0..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/exceptionfee/AssertException.java +++ /dev/null @@ -1,576 +0,0 @@ -package stest.tron.wallet.dailybuild.exceptionfee; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class AssertException { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Trigger contract Divide 0") - public void test1DivideInt() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/assertExceptiontest1DivideInt.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - Account info; - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "4" + "," + "0"; - - txid = PublicMethed.triggerContract(contractAddress, - "divideIHaveArgsReturn(int256,int256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Optional ById = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + ById.get().getRet(0)); - logger.info("getNumber:" + ById.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + ById.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + ById.get().getRet(0).getContractRet()); - - Assert.assertEquals(ById.get().getRet(0).getContractRet().getNumber(), - contractResult.ILLEGAL_OPERATION_VALUE); - Assert.assertEquals(ById.get().getRet(0).getContractRetValue(), 8); - Assert.assertEquals(ById.get().getRet(0).getContractRet(), contractResult.ILLEGAL_OPERATION); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert.assertEquals(contractResult.ILLEGAL_OPERATION, infoById.get().getReceipt().getResult()); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + maxFeeLimit + netFee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - } - - @Test(enabled = true, description = "Trigger contract index out of bounds") - public void test2FindArgsContractMinTest() { - String filePath = - "src/test/resources/soliditycode/assertExceptiontest2FindArgsContractMinTest.sol"; - String contractName = "findArgsIContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("11:" + Base58.encode58Check(contractAddress)); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - Integer triggerNum = -1; - txid = PublicMethed.triggerContract(contractAddress, - "findArgsByIndex1(uint256)", triggerNum.toString(), false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + maxFeeLimit + netFee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = true, description = "Trigger contract Bytes array index out of bounds") - public void test3ByteMinContract() { - String filePath = "src/test/resources/soliditycode/assertExceptiontest3ByteMinContract.sol"; - String contractName = "byteContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - Integer triggerNum = -1; - txid = PublicMethed.triggerContract(contractAddress, - "testBytesGet(uint256)", triggerNum.toString(), false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + maxFeeLimit + netFee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = true, description = "Trigger contract convert too large value to enumerated type") - public void test4Enum() { - String filePath = "src/test/resources/soliditycode/assertExceptiontest4Enum.sol"; - String contractName = "enumContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - Integer triggerNum = 22; - - txid = PublicMethed.triggerContract(contractAddress, - "setGoStraight(uint8)", triggerNum.toString(), false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + maxFeeLimit + netFee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - } - - @Test(enabled = true, description = "Trigger contract move a negative value to a binary") - public void test5MoveRight() { - String filePath = "src/test/resources/soliditycode/assertExceptiontest5MoveRight.sol"; - String contractName = "binaryRightContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - Integer triggerNum = -1; - txid = PublicMethed.triggerContract(contractAddress, - "binaryMoveR(int256)", triggerNum.toString(), false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + maxFeeLimit + netFee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - } - - @Test(enabled = true, description = "Trigger contract Call an uninitialized " - + "internal function type variable") - public void test6UninitializedContract() { - String filePath = - "src/test/resources/soliditycode/assertExceptiontest6UninitializedContract.sol"; - String contractName = "uni"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed.triggerContract(contractAddress, - "test2()", "#", false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + maxFeeLimit + netFee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = true, description = "Trigger contract assert exception") - public void test7TestAssertContract() { - String filePath = "src/test/resources/soliditycode/assertExceptiontest7TestAssertContract.sol"; - String contractName = "TestThrowsContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "testAssert()", "#", false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue((beforeBalance - maxFeeLimit - netFee) == afterBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar001.java b/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar001.java deleted file mode 100644 index 6a5d097f5a7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar001.java +++ /dev/null @@ -1,389 +0,0 @@ -package stest.tron.wallet.dailybuild.grammar; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractGrammar001 { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String compilerVersion = Configuration.getByPath("testng.conf") - .getString("defaultParameter.solidityCompilerVersion"); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress = ecKey1.getAddress(); - String testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true, description = "Support function type") - public void test1Grammar001() { - ecKey1 = new ECKey(Utils.getRandom()); - grammarAddress = ecKey1.getAddress(); - testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/contractGrammar001test1Grammar001.sol"; - String contractName = "FunctionSelector"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid = ""; - String num = "true" + "," + "10"; - txid = PublicMethed.triggerContract(contractAddress, - "select(bool,uint256)", num, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long returnnumber = ByteArray.toLong(ByteArray.fromHexString(ByteArray.toHexString( - infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber == 20); - - String num2 = "false" + "," + "10"; - txid = PublicMethed.triggerContract(contractAddress, - "select(bool,uint256)", num2, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Optional ById = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + ById.get().getRet(0)); - logger.info("getNumber:" + ById.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + ById.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + ById.get().getRet(0).getContractRet()); - - Assert.assertEquals(ById.get().getRet(0).getContractRet().getNumber(), - contractResult.SUCCESS_VALUE); - Assert.assertEquals(ById.get().getRet(0).getContractRetValue(), 1); - Assert.assertEquals(ById.get().getRet(0).getContractRet(), contractResult.SUCCESS); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), - "0000000000000000000000000000000000000000000000000000000000000064"); - Assert.assertEquals(contractResult.SUCCESS, infoById.get().getReceipt().getResult()); - - logger.info("ById:" + ById); - Assert.assertEquals(ById.get().getRet(0).getRet().getNumber(), 0); - Assert.assertEquals(ById.get().getRet(0).getRetValue(), 0); - - Long returnnumber2 = ByteArray.toLong(ByteArray.fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber2 == 100); - } - - @Test(enabled = true, description = "Ordinary library contract") - public void test2Grammar002() { - String filePath = "src/test/resources/soliditycode/contractGrammar001test2Grammar002.sol"; - String contractName = "Set"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid = ""; - String num = "1"; - byte[] contractAddress1 = null; - String filePath1 = "src/test/resources/soliditycode/contractGrammar001test2Grammar002.sol"; - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbiForLibrary(filePath1, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String library = retMap1.get("library").toString(); - String libraryAddress = library + Base58.encode58Check(contractAddress); - contractAddress1 = PublicMethed - .deployContractForLibrary(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, libraryAddress, testKeyForGrammarAddress, - grammarAddress, compilerVersion, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - txid = PublicMethed.triggerContract(contractAddress1, - "register(uint256)", num, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull1); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - } - - @Test(enabled = true, description = "Library contract") - public void test3Grammar003() { - String filePath = "src/test/resources/soliditycode/contractGrammar001test3Grammar003.sol"; - String contractName = "Set"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid = ""; - String num = "1"; - byte[] contractAddress1 = null; - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbiForLibrary(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String library = retMap1.get("library").toString(); - String libraryAddress = library - + Base58.encode58Check(contractAddress); - contractAddress1 = PublicMethed - .deployContractForLibrary(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, libraryAddress, testKeyForGrammarAddress, - grammarAddress, compilerVersion, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - txid = PublicMethed.triggerContract(contractAddress1, - "register(uint256)", num, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull1); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - } - - - @Test(enabled = true, description = "Extended type") - public void test4Grammar004() { - ecKey1 = new ECKey(Utils.getRandom()); - grammarAddress = ecKey1.getAddress(); - testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/contractGrammar001test4Grammar004.sol"; - String contractName = "Search"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - byte[] contractAddress1 = null; - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbiForLibrary(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String library = retMap1.get("library").toString(); - String libraryAddress = null; - libraryAddress = library - + Base58.encode58Check(contractAddress); - contractAddress1 = PublicMethed - .deployContractForLibrary(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, libraryAddress, testKeyForGrammarAddress, - grammarAddress, compilerVersion, blockingStubFull); - String txid = ""; - String num = "1"; - PublicMethed.waitProduceNextBlock(blockingStubFull); - txid = PublicMethed.triggerContract(contractAddress1, - "append(uint256)", num, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String num1 = "0"; - String txid1 = PublicMethed.triggerContract(contractAddress1, - "getData(uint256)", num1, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber == 1); - - String num2 = "1" + "," + "2"; - String txid2 = PublicMethed.triggerContract(contractAddress1, - "replace(uint256,uint256)", num2, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - String txid3 = PublicMethed.triggerContract(contractAddress1, - "getData(uint256)", num1, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - Long returnnumber1 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber1 == 2); - - } - - @Test(enabled = true, description = "Solidity assembly") - public void test5Grammar006() { - String filePath = "src/test/resources/soliditycode/contractGrammar001test5Grammar006.sol"; - String contractName = "InfoFeed"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid = ""; - String number = "1"; - final String txid1 = PublicMethed.triggerContract(contractAddress, - "f(uint256)", number, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - final String txid2 = PublicMethed.triggerContract(contractAddress, - "d(uint256)", number, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - final String txid3 = PublicMethed.triggerContract(contractAddress, - "d1(uint256)", number, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - final String txid4 = PublicMethed.triggerContract(contractAddress, - "d2(uint256)", number, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - final String txid5 = PublicMethed.triggerContract(contractAddress, - "d5(uint256)", number, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - final String txid6 = PublicMethed.triggerContract(contractAddress, - "d4(uint256)", number, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - final String txid8 = PublicMethed.triggerContract(contractAddress, - "d6(uint256)", number, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - - Optional infoById1 = PublicMethed - .getTransactionInfoById(txid1, blockingStubFull1); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - - Optional infoById2 = PublicMethed - .getTransactionInfoById(txid2, blockingStubFull1); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - - Optional infoById3 = PublicMethed - .getTransactionInfoById(txid3, blockingStubFull1); - Assert.assertTrue(infoById3.get().getResultValue() == 0); - - Optional infoById4 = PublicMethed - .getTransactionInfoById(txid4, blockingStubFull1); - Assert.assertTrue(infoById4.get().getResultValue() == 0); - - Optional infoById5 = PublicMethed - .getTransactionInfoById(txid5, blockingStubFull1); - Assert.assertTrue(infoById5.get().getResultValue() == 0); - - Optional infoById6 = PublicMethed - .getTransactionInfoById(txid6, blockingStubFull1); - Assert.assertTrue(infoById6.get().getResultValue() == 0); - - Optional infoById8 = PublicMethed - .getTransactionInfoById(txid8, blockingStubFull1); - Assert.assertTrue(infoById8.get().getResultValue() == 0); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar002.java b/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar002.java deleted file mode 100644 index a71da52602d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar002.java +++ /dev/null @@ -1,345 +0,0 @@ -package stest.tron.wallet.dailybuild.grammar; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractGrammar002 { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress2 = ecKey1.getAddress(); - String testKeyForGrammarAddress2 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress2); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - - @Test(enabled = true, description = "Interface type function") - public void test1Grammar007() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress2, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/contractGrammar002test1Grammar007_1.sol"; - String contractName = "Doug"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String initParmes = ByteArray.toHexString(contractAddress); - String filePath1 = "src/test/resources/soliditycode/contractGrammar002test1Grammar007_2.sol"; - String contractName1 = "main"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath1, contractName1); - String code1 = retMap1.get("byteCode").toString() + "0000000000000000000000" - + initParmes; - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - String txid = ""; - String number = "1"; - String txid1 = PublicMethed.triggerContract(contractAddress1, - "dougOfage(uint256)", number, false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById1 = PublicMethed - .getTransactionInfoById(txid1, blockingStubFull1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - - String number1 = "687777"; - String txid2 = PublicMethed.triggerContract(contractAddress1, - "uintOfName(bytes32)", number1, false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - // PublicMethed.waitProduceNextBlock(blockingStubFull); - // PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById2 = PublicMethed - .getTransactionInfoById(txid2, blockingStubFull1); - - Assert.assertTrue(infoById2.get().getResultValue() == 0); - } - - @Test(enabled = true, description = "Abstract function") - public void test2Grammar008() { - String filePath = "src/test/resources/soliditycode/contractGrammar002test2Grammar008.sol"; - String contractName = "Cat"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "getContractName()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - String returnString = ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()); - Assert.assertEquals(returnString, - "0000000000000000000000000000000000000000000000000000000000000020000000000000000000" - + "000000000000000000000000000000000000000000000646656c696e650000000000000000000000000" - + "000000000000000000000000000"); - String txid1 = PublicMethed.triggerContract(contractAddress, - "utterance()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - String returnString1 = ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()); - Assert.assertEquals(returnString1, - "6d69616f77000000000000000000000000000000000000000000000000000000"); - } - - @Test(enabled = true, description = "Gas, value test") - public void test3Grammar010() { - String filePath = "src/test/resources/soliditycode/contractGrammar002test3Grammar010.sol"; - String contractName = "Consumer"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 2000L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "InfoFeed"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - String txid = ""; - String initParmes = "\"" + Base58.encode58Check(contractAddress1) + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "setFeed(address)", initParmes, false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid1 = PublicMethed.triggerContract(contractAddress, - "callFeed()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid1, blockingStubFull1); - Assert.assertTrue(infoById.get().getResultValue() == 0); - } - - - @Test(enabled = true, description = "Call a named function") - public void test4Grammar011() { - String filePath = "src/test/resources/soliditycode/contractGrammar002test4Grammar011.sol"; - String contractName = "C"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - String number = "1" + "," + "2"; - String txid = PublicMethed.triggerContract(contractAddress, - "f(uint256,uint256)", number, false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(returnnumber == 1); - - Optional infoById1 = null; - String txid1 = PublicMethed.triggerContract(contractAddress, - "g()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - } - - - @Test(enabled = true, description = "Call a native function") - public void test5Grammar012() { - String filePath = "src/test/resources/soliditycode/contractGrammar002test4Grammar012.sol"; - String contractName = "rTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - String txid = PublicMethed.triggerContract(contractAddress, - "info()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - - } - - @Test(enabled = true, description = "Call a Destructor function") - public void test6Grammar013() { - String filePath = "src/test/resources/soliditycode/contractGrammar002test6Grammar013.sol"; - String contractName = "Counter"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - String txid = PublicMethed.triggerContract(contractAddress, - "getCount()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(returnnumber == 0); - - Optional infoById1 = null; - String txid1 = PublicMethed.triggerContract(contractAddress, - "increment()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Optional infoById2 = null; - String txid2 = PublicMethed.triggerContract(contractAddress, - "getCount()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - - Assert.assertTrue(infoById2.get().getResultValue() == 0); - - Long returnnumber1 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById2.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber1 == 10); - - Optional infoById3 = null; - String txid3 = PublicMethed.triggerContract(contractAddress, - "kill()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById3 = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - Assert.assertTrue(infoById3.get().getResultValue() == 0); - - Optional infoById4 = null; - String txid4 = PublicMethed.triggerContract(contractAddress, - "getCount()", "#", false, - 0, maxFeeLimit, grammarAddress2, testKeyForGrammarAddress2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(txid4 == null); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar003.java b/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar003.java deleted file mode 100644 index 1d334175767..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar003.java +++ /dev/null @@ -1,533 +0,0 @@ -package stest.tron.wallet.dailybuild.grammar; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractGrammar003 { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress3 = ecKey1.getAddress(); - String testKeyForGrammarAddress3 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress3); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - - @Test(enabled = true, description = "Complex structure") - public void test1Grammar014() { - ecKey1 = new ECKey(Utils.getRandom()); - grammarAddress3 = ecKey1.getAddress(); - testKeyForGrammarAddress3 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress3, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/contractGrammar003test1Grammar014.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "B"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid = PublicMethed.triggerContract(contractAddress, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid1 = PublicMethed.triggerContract(contractAddress1, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(returnnumber == 0); - - Long returnnumber1 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(returnnumber1 == 0); - Optional infoById4 = null; - String initParmes = "\"" + Base58.encode58Check(contractAddress1) + "\",\"1\""; - String txid4 = PublicMethed.triggerContract(contractAddress, - "callTest(address,uint256)", initParmes, false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById4 = PublicMethed.getTransactionInfoById(txid4, blockingStubFull); - - Assert.assertTrue(infoById4.get().getResultValue() == 0); - - String txid5 = PublicMethed.triggerContract(contractAddress, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById5 = null; - infoById5 = PublicMethed.getTransactionInfoById(txid5, blockingStubFull); - Long returnnumber5 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById5.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber5 == 0); - - String txid6 = PublicMethed.triggerContract(contractAddress1, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById6 = null; - infoById6 = PublicMethed.getTransactionInfoById(txid6, blockingStubFull); - Long returnnumber6 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById6.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber6 == 1); - - String txid7 = PublicMethed.triggerContract(contractAddress, - "callcodeTest(address,uint256)", initParmes, false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById7 = null; - infoById7 = PublicMethed.getTransactionInfoById(txid7, blockingStubFull); - - Assert.assertTrue(infoById7.get().getResultValue() == 0); - - String txid8 = PublicMethed.triggerContract(contractAddress, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById8 = null; - infoById8 = PublicMethed.getTransactionInfoById(txid8, blockingStubFull); - Long returnnumber8 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById8.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber8 == 1); - - String txid9 = PublicMethed.triggerContract(contractAddress1, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById9 = null; - infoById9 = PublicMethed.getTransactionInfoById(txid9, blockingStubFull); - Long returnnumber9 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById9.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber9 == 1); - - String txid10 = PublicMethed.triggerContract(contractAddress, - "delegatecallTest(address,uint256)", initParmes, false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById10 = null; - infoById10 = PublicMethed.getTransactionInfoById(txid10, blockingStubFull); - - Assert.assertTrue(infoById10.get().getResultValue() == 0); - - String txid11 = PublicMethed.triggerContract(contractAddress, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById11 = null; - infoById11 = PublicMethed.getTransactionInfoById(txid11, blockingStubFull); - Long returnnumber11 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById11.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber11 == 1); - - String txid12 = PublicMethed.triggerContract(contractAddress1, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById12 = null; - infoById12 = PublicMethed.getTransactionInfoById(txid12, blockingStubFull); - Long returnnumber12 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById12.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber12 == 1); - - String initParmes1 = "\"" + Base58.encode58Check(contractAddress1) + "\""; - String txid13 = PublicMethed.triggerContract(contractAddress, - "callAddTest(address)", initParmes1, false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById13 = null; - infoById13 = PublicMethed.getTransactionInfoById(txid13, blockingStubFull); - - Assert.assertTrue(infoById13.get().getResultValue() == 0); - - String txid14 = PublicMethed.triggerContract(contractAddress, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById14 = null; - infoById14 = PublicMethed.getTransactionInfoById(txid14, blockingStubFull); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById14.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber14 == 1); - - String txid15 = PublicMethed.triggerContract(contractAddress1, - "getnumberForB()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById15 = null; - infoById15 = PublicMethed.getTransactionInfoById(txid15, blockingStubFull); - Long returnnumber15 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById15.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber15 == 3); - } - - - @Test(enabled = true, description = "Fallback function ") - public void test2Grammar015() { - String filePath = "src/test/resources/soliditycode/contractGrammar003test2Grammar015.sol"; - String contractName = "ExecuteFallback"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - String txid = PublicMethed.triggerContract(contractAddress, - "callExistFunc()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - String i = ByteArray.toHexString(Hash.sha3("ExistFuncCalled(bytes,uint256)".getBytes())); - String resultvalue = ByteArray - .toHexString(infoById.get().getLogList().get(0).getTopicsList().get(0).toByteArray()); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertEquals(i, resultvalue); - - Optional infoById1 = null; - String txid1 = PublicMethed.triggerContract(contractAddress, - "callNonExistFunc()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - String value = ByteArray.toHexString(Hash.sha3("FallbackCalled(bytes)".getBytes())); - String resultvalue1 = ByteArray - .toHexString(infoById1.get().getLogList().get(0).getTopicsList().get(0).toByteArray()); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertEquals(value, resultvalue1); - - } - - @Test(enabled = true, description = "Permission control ") - public void test3Grammar016() { - String filePath = "src/test/resources/soliditycode/contractGrammar003test3Grammar016.sol"; - String contractName = "D"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - String txid = PublicMethed.triggerContract(contractAddress, - "readData()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - String contractName1 = "E"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - String txid1 = PublicMethed.triggerContract(contractAddress1, - "g()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - - Optional infoById2 = null; - String num = "3"; - String txid2 = PublicMethed.triggerContract(contractAddress1, - "setData(uint256)", num, false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - - Assert.assertTrue(infoById2.get().getResultValue() == 0); - - String txid3 = PublicMethed.triggerContract(contractAddress1, - "getData()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById3 = null; - infoById3 = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - Long returnnumber3 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById3.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber3 == 3); - Assert.assertTrue(infoById3.get().getResultValue() == 0); - - } - - @Test(enabled = true, description = "Structure") - public void test4Grammar017() { - String filePath = "src/test/resources/soliditycode/contractGrammar003test4Grammar017.sol"; - String contractName = "CrowdFunding"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress1 = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - String initParmes = "\"" + Base58.encode58Check(grammarAddress3) + "\",\"1\""; - Optional infoById = null; - String txid = PublicMethed.triggerContract(contractAddress1, - "candidate(address,uint256)", initParmes, false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long returnnumber1 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(returnnumber1 == 1); - - String txid1 = PublicMethed.triggerContract(contractAddress1, - "check(uint256)", "1", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = PublicMethed - .getTransactionInfoById(txid1, blockingStubFull1); - Long returnnumber2 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber2 == 1); - - String txid2 = PublicMethed.triggerContract(contractAddress1, - "vote(uint256)", "1", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById2 = PublicMethed - .getTransactionInfoById(txid2, blockingStubFull); - - Assert.assertTrue(infoById2.get().getResultValue() == 0); - - } - - @Test(enabled = true, description = "Built-in function") - public void test5Grammar018() { - String filePath = "src/test/resources/soliditycode/contractGrammar003test5Grammar018.sol"; - String contractName = "Grammar18"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - String txid = PublicMethed.triggerContract(contractAddress, - "testAddmod()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(returnnumber == 1); - Optional infoById1 = null; - String txid1 = PublicMethed.triggerContract(contractAddress, - "testMulmod()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Long returnnumber1 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(returnnumber1 == 2); - - String txid2 = PublicMethed.triggerContract(contractAddress, - "testKeccak256()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - - Assert.assertTrue(infoById2.get().getResultValue() == 0); - - String txid3 = PublicMethed.triggerContract(contractAddress, - "testSha256()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById3 = null; - infoById3 = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - - Assert.assertTrue(infoById3.get().getResultValue() == 0); - - String txid4 = PublicMethed.triggerContract(contractAddress, - "testSha3()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - Optional infoById4 = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById4 = PublicMethed.getTransactionInfoById(txid4, blockingStubFull); - Assert.assertTrue(infoById4.get().getResultValue() == 0); - } - - - @Test(enabled = true, description = "Time unit") - public void test6Grammar019() { - - String filePath = "src/test/resources/soliditycode/contractGrammar003test6Grammar019.sol"; - String contractName = "timetest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid = PublicMethed.triggerContract(contractAddress, - "timetest()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - - } - - - @Test(enabled = true, description = "Trx and sun unit conversion.") - public void test7Grammar020() { - String filePath = "src/test/resources/soliditycode/contractGrammar003test7Grammar020.sol"; - String contractName = "trxtest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - String txid = PublicMethed.triggerContract(contractAddress, - "test()", "#", false, - 0, maxFeeLimit, grammarAddress3, testKeyForGrammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar004.java b/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar004.java deleted file mode 100644 index a8266c67a9f..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/grammar/ContractGrammar004.java +++ /dev/null @@ -1,663 +0,0 @@ -package stest.tron.wallet.dailybuild.grammar; - -import static org.tron.protos.Protocol.Transaction.Result.contractResult.BAD_JUMP_DESTINATION_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.ILLEGAL_OPERATION_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.OUT_OF_ENERGY_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.OUT_OF_MEMORY_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.OUT_OF_TIME_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.REVERT_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.STACK_TOO_LARGE_VALUE; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.STACK_TOO_SMALL_VALUE; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractGrammar004 { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String compilerVersion = Configuration.getByPath("testng.conf") - .getString("defaultParameter.solidityCompilerVersion"); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress = ecKey1.getAddress(); - String testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true, description = "ContractResult is OUT_OF_TIME") - public void test1Grammar001() { - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - String filePath = "./src/test/resources/soliditycode/walletTestMutiSign004.sol"; - String contractName = "timeoutTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, grammarAddress, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - org.testng.Assert.assertTrue(smartContract.getAbi().toString() != null); - String txid = null; - Optional infoById = null; - String initParmes = "\"" + "100000" + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testUseCpu(uint256)", initParmes, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - logger.info("ById:" + byId); - - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), OUT_OF_TIME_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.OUT_OF_TIME); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert.assertEquals(contractResult.OUT_OF_TIME, infoById.get().getReceipt().getResult()); - - Assert.assertEquals(byId.get().getRet(0).getRet().getNumber(), 0); - Assert.assertEquals(byId.get().getRet(0).getRetValue(), 0); - - - } - - - @Test(enabled = true, description = "ContractResult is OUT_OF_MEMORY") - public void test2Grammar002() { - String filePath = "./src/test/resources/soliditycode/testOutOfMem.sol"; - String contractName = "Test"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, grammarAddress, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - org.testng.Assert.assertTrue(smartContract.getAbi().toString() != null); - String txid = null; - Optional infoById = null; - String initParmes = "\"" + "31457280" + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testOutOfMem(uint256)", initParmes, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - logger.info("ById:" + byId); - - logger.info("infoById:" + infoById); - - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), OUT_OF_MEMORY_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.OUT_OF_MEMORY); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert.assertEquals(contractResult.OUT_OF_MEMORY, infoById.get().getReceipt().getResult()); - - Assert.assertEquals(byId.get().getRet(0).getRet().getNumber(), 0); - Assert.assertEquals(byId.get().getRet(0).getRetValue(), 0); - - - } - - - @Test(enabled = true, description = "ContractResult is BAD_JUMP_DESTINATION") - public void test3Grammar003() { - String contractName = "Test"; - - String code = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600" - + "080fd5b5061011f8061003a6000396000f30060806040526004361060485763ffffffff7c01000000000000" - + "000000000000000000000000000000000000000000006000350416634ef5a0088114604d5780639093b95b1" - + "4608c575b600080fd5b348015605857600080fd5b50d38015606457600080fd5b50d28015607057600080fd" - + "5b50607a60043560b8565b60408051918252519081900360200190f35b348015609757600080fd5b50d3801" - + "560a357600080fd5b50d2801560af57600080fd5b5060b660ee565b005b6000606082604051908082528060" - + "20026020018201604052801560e5578160200160208202803883390190505b50905050919050565b6001805" - + "600a165627a7a7230582092ba162087e13f41c6d6c00ba493edc5a5a6250a3840ece5f99aa38b66366a7000" - + "29"; - String abi = "[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\"" - + ":\"testOutOfMem\",\"outputs\":[{\"name\":\"r\",\"type\":\"bytes32\"}],\"payable\":false" - + ",\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs" - + "\":[],\"name\":\"testBadJumpDestination\",\"outputs\":[],\"payable\":false,\"stateMutab" - + "ility\":\"nonpayable\",\"type\":\"function\"}]"; - - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, grammarAddress, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - org.testng.Assert.assertTrue(smartContract.getAbi().toString() != null); - String txid = null; - Optional infoById = null; - txid = PublicMethed.triggerContract(contractAddress, - "testBadJumpDestination()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - logger.info("ById:" + byId); - - logger.info("infoById:" + infoById); - - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), BAD_JUMP_DESTINATION_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.BAD_JUMP_DESTINATION); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert - .assertEquals(contractResult.BAD_JUMP_DESTINATION, infoById.get().getReceipt().getResult()); - - Assert.assertEquals(byId.get().getRet(0).getRet().getNumber(), 0); - Assert.assertEquals(byId.get().getRet(0).getRetValue(), 0); - - - } - - - @Test(enabled = true, description = "ContractResult is OUT_OF_ENERGY") - public void test4Grammar004() { - - String filePath = "src/test/resources/soliditycode/contractUnknownException.sol"; - String contractName = "testC"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 20L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - logger.info("ById:" + byId); - - logger.info("infoById:" + infoById); - - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), OUT_OF_ENERGY_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.OUT_OF_ENERGY); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert - .assertEquals(contractResult.OUT_OF_ENERGY, infoById.get().getReceipt().getResult()); - - Assert.assertEquals(byId.get().getRet(0).getRet().getNumber(), 0); - Assert.assertEquals(byId.get().getRet(0).getRetValue(), 0); - - } - - - @Test(enabled = true, description = "ContractResult is ILLEGAL_OPERATION") - public void test5Grammar005() { - - - String filePath = "src/test/resources/soliditycode/assertExceptiontest1DivideInt.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - String num = "4" + "," + "0"; - - txid = PublicMethed.triggerContract(contractAddress, - "divideIHaveArgsReturn(int256,int256)", num, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - - Assert.assertEquals(byId.get().getRet(0).getContractRet().getNumber(), - ILLEGAL_OPERATION_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), ILLEGAL_OPERATION_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.ILLEGAL_OPERATION); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert.assertEquals(contractResult.ILLEGAL_OPERATION, infoById.get().getReceipt().getResult()); - - } - - - @Test(enabled = true, description = "ContractResult is REVERT") - public void test6Grammar006() { - - String filePath = - "src/test/resources/soliditycode/requireExceptiontest1TestRequireContract.sol"; - String contractName = "TestThrowsContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final String txid = PublicMethed.triggerContract(contractAddress, - "testRequire()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - - Assert.assertEquals(byId.get().getRet(0).getContractRet().getNumber(), - REVERT_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), REVERT_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.REVERT); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - - } - - @Test(enabled = true, description = "ContractResult is SUCCESS") - public void test7Grammar007() { - - String filePath = "src/test/resources/soliditycode/assertExceptiontest1DivideInt.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - String num = "4" + "," + "2"; - - txid = PublicMethed.triggerContract(contractAddress, - "divideIHaveArgsReturn(int256,int256)", num, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - - Assert.assertEquals(byId.get().getRet(0).getContractRet().getNumber(), - contractResult.SUCCESS_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), contractResult.SUCCESS_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.SUCCESS); - - Assert.assertEquals(contractResult.SUCCESS, infoById.get().getReceipt().getResult()); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), - "0000000000000000000000000000000000000000000000000000000000000002"); - - } - - - @Test(enabled = true, description = "ContractResult is TRANSFER_FAILED") - public void test8Grammar008() { - String filePath = "src/test/resources/soliditycode/TransferFailed001.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(grammarAddress, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForGrammarAddress, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - String txid = ""; - String num = "1" + ",\"" + Base58.encode58Check(nonexistentAddress) + "\""; - - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTrxNonexistentTarget(uint256,address)", num, false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(testKeyForGrammarAddress, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(grammarAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer trx failed: Validate InternalTransfer error, no ToAccount." - + " And not allowed to create account in smart contract.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "ContractResult is STACK_TOO_SMALL") - public void test9Grammar009() { - - String contractName = "TestThrowsContract"; - String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"testStackTooSmall\",\"outputs\":[]" - + ",\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"}]"; - String code = "60606040523415600b57fe5b5b60608060196000396000f300606060405263ffffffff60e060020" - + "a6000350416632f3a24cc81146020575bfe5b3415602757fe5b602d602f565b005b50505b5600a165627a7a" - + "723058208184f2ff2627a8a490bfd1233a891f2f4605375d0fec375e237ffc188cdd7ec70029"; - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final String txid = PublicMethed.triggerContract(contractAddress, - "testStackTooSmall()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - - Assert.assertEquals(byId.get().getRet(0).getContractRet().getNumber(), - STACK_TOO_SMALL_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), STACK_TOO_SMALL_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.STACK_TOO_SMALL); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert.assertEquals(contractResult.STACK_TOO_SMALL, infoById.get().getReceipt().getResult()); - - } - - @Test(enabled = true, description = "ContractResult is STACK_TOO_LARGE") - public void test9Grammar010() { - - String contractName = "TestThrowsContract"; - String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"testStackTooLarge\",\"outputs\":[]" - + ",\"payable\":false,\"type\":\"function\",\"stateMutability\":\"nonpayable\"}]"; - String code = "6060604052341561000c57fe5b5b610b658061001c6000396000f300606060405263ffffffff60e" - + "060020a600035041663f7d9c5c68114610021575bfe5b341561002957fe5b610031610033565b005b600060" - + "0160026003600460056006600760086009600a600b600c600d600e600f60106011601260136014601560166" - + "01760186019601a601b601c601d601e601f6020602160226023602460256026602760286029602a602b602c" - + "602d602e602f6030603160326033603460356036603760386039603a603b603c603d603e603f60406041604" - + "26043604460456046604760486049604a604b604c604d604e604f6050605160526053605460556056605760" - + "586059605a605b605c605d605e605f6060606160626063606460656066606760686069606a606b606c606d6" - + "06e606f6070607160726073607460756076607760786079607a607b607c607d607e607f6080608160826083" - + "608460856086608760886089608a608b608c608d608e608f609060916092609360946095609660976098609" - + "9609a609b609c609d609e609f60a060a160a260a360a460a560a660a760a860a960aa60ab60ac60ad60ae60" - + "af60b060b160b260b360b460b560b660b760b860b960ba60bb60bc60bd60be60bf60c060c160c260c360c46" - + "0c560c660c760c860c960ca60cb60cc60cd60ce60cf60d060d160d260d360d460d560d660d760d860d960da" - + "60db60dc60dd60de60df60e060e160e260e360e460e560e660e760e860e960ea60eb60ec60ed60ee60ef60f" - + "060f160f260f360f460f560f660f760f860f960fa60fb60fc60fd60fe60ff61010061010161010261010361" - + "010461010561010661010761010861010961010a61010b61010c61010d61010e61010f61011061011161011" - + "261011361011461011561011661011761011861011961011a61011b61011c61011d61011e61011f61012061" - + "012161012261012361012461012561012661012761012861012961012a61012b61012c61012d61012e61012" - + "f61013061013161013261013361013461013561013661013761013861013961013a61013b61013c61013d61" - + "013e61013f61014061014161014261014361014461014561014661014761014861014961014a61014b61014" - + "c61014d61014e61014f61015061015161015261015361015461015561015661015761015861015961015a61" - + "015b61015c61015d61015e61015f61016061016161016261016361016461016561016661016761016861016" - + "961016a61016b61016c61016d61016e61016f61017061017161017261017361017461017561017661017761" - + "017861017961017a61017b61017c61017d61017e61017f61018061018161018261018361018461018561018" - + "661018761018861018961018a61018b61018c61018d61018e61018f61019061019161019261019361019461" - + "019561019661019761019861019961019a61019b61019c61019d61019e61019f6101a06101a16101a26101a" - + "36101a46101a56101a66101a76101a86101a96101aa6101ab6101ac6101ad6101ae6101af6101b06101b161" - + "01b26101b36101b46101b56101b66101b76101b86101b96101ba6101bb6101bc6101bd6101be6101bf6101c" - + "06101c16101c26101c36101c46101c56101c66101c76101c86101c96101ca6101cb6101cc6101cd6101ce61" - + "01cf6101d06101d16101d26101d36101d46101d56101d66101d76101d86101d96101da6101db6101dc6101d" - + "d6101de6101df6101e06101e16101e26101e36101e46101e56101e66101e76101e86101e96101ea6101eb61" - + "01ec6101ed6101ee6101ef6101f06101f16101f26101f36101f46101f56101f66101f76101f86101f96101f" - + "a6101fb6101fc6101fd6101fe6101ff61020061020161020261020361020461020561020661020761020861" - + "020961020a61020b61020c61020d61020e61020f61021061021161021261021361021461021561021661021" - + "761021861021961021a61021b61021c61021d61021e61021f61022061022161022261022361022461022561" - + "022661022761022861022961022a61022b61022c61022d61022e61022f61023061023161023261023361023" - + "461023561023661023761023861023961023a61023b61023c61023d61023e61023f61024061024161024261" - + "024361024461024561024661024761024861024961024a61024b61024c61024d61024e61024f61025061025" - + "161025261025361025461025561025661025761025861025961025a61025b61025c61025d61025e61025f61" - + "026061026161026261026361026461026561026661026761026861026961026a61026b61026c61026d61026" - + "e61026f61027061027161027261027361027461027561027661027761027861027961027a61027b61027c61" - + "027d61027e61027f61028061028161028261028361028461028561028661028761028861028961028a61028" - + "b61028c61028d61028e61028f61029061029161029261029361029461029561029661029761029861029961" - + "029a61029b61029c61029d61029e61029f6102a06102a16102a26102a36102a46102a56102a66102a76102a" - + "86102a96102aa6102ab6102ac6102ad6102ae6102af6102b06102b16102b26102b36102b46102b56102b661" - + "02b76102b86102b96102ba6102bb6102bc6102bd6102be6102bf6102c06102c16102c26102c36102c46102c" - + "56102c66102c76102c86102c96102ca6102cb6102cc6102cd6102ce6102cf6102d06102d16102d26102d361" - + "02d46102d56102d66102d76102d86102d96102da6102db6102dc6102dd6102de6102df6102e06102e16102e" - + "26102e36102e46102e56102e66102e76102e86102e96102ea6102eb6102ec6102ed6102ee6102ef6102f061" - + "02f16102f26102f36102f46102f56102f66102f76102f86102f96102fa6102fb6102fc6102fd6102fe6102f" - + "f61030061030161030261030361030461030561030661030761030861030961030a61030b61030c61030d61" - + "030e61030f61031061031161031261031361031461031561031661031761031861031961031a61031b61031" - + "c61031d61031e61031f61032061032161032261032361032461032561032661032761032861032961032a61" - + "032b61032c61032d61032e61032f61033061033161033261033361033461033561033661033761033861033" - + "961033a61033b61033c61033d61033e61033f61034061034161034261034361034461034561034661034761" - + "034861034961034a61034b61034c61034d61034e61034f61035061035161035261035361035461035561035" - + "661035761035861035961035a61035b61035c61035d61035e61035f61036061036161036261036361036461" - + "036561036661036761036861036961036a61036b61036c61036d61036e61036f61037061037161037261037" - + "361037461037561037661037761037861037961037a61037b61037c61037d61037e61037f61038061038161" - + "038261038361038461038561038661038761038861038961038a61038b61038c61038d61038e61038f61039" - + "061039161039261039361039461039561039661039761039861039961039a61039b61039c61039d61039e61" - + "039f6103a06103a16103a26103a36103a46103a56103a66103a76103a86103a96103aa6103ab6103ac6103a" - + "d6103ae6103af6103b06103b16103b26103b36103b46103b56103b66103b76103b86103b96103ba6103bb61" - + "03bc6103bd6103be6103bf6103c06103c16103c26103c36103c46103c56103c66103c76103c86103c96103c" - + "a6103cb6103cc6103cd6103ce6103cf6103d06103d16103d26103d36103d46103d56103d66103d76103d861" - + "03d96103da6103db6103dc6103dd6103de6103df6103e06103e16103e26103e36103e46103e56103e66103e" - + "76103e86103e96103ea6103eb6103ec6103ed6103ee6103ef6103f06103f16103f26103f36103f46103f561" - + "03f66103f76103f86103f96103fa6103fb6103fc6103fd6103fe6103ff6104005b5600a165627a7a7230582" - + "0998f09cc267db91352a3d0a4ab60ea08fc306fa8bc6dd78dc324a06109dcf0420029"; - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final String txid = PublicMethed.triggerContract(contractAddress, - "testStackTooLarge()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Optional byId = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("getRet:" + byId.get().getRet(0)); - logger.info("getNumber:" + byId.get().getRet(0).getContractRet().getNumber()); - logger.info("getContractRetValue:" + byId.get().getRet(0).getContractRetValue()); - logger.info("getContractRet:" + byId.get().getRet(0).getContractRet()); - - Assert.assertEquals(byId.get().getRet(0).getContractRet().getNumber(), - STACK_TOO_LARGE_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRetValue(), STACK_TOO_LARGE_VALUE); - Assert.assertEquals(byId.get().getRet(0).getContractRet(), contractResult.STACK_TOO_LARGE); - - Assert - .assertEquals(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()), ""); - Assert.assertEquals(contractResult.STACK_TOO_LARGE, infoById.get().getReceipt().getResult()); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount001.java deleted file mode 100644 index f12041bf62c..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount001.java +++ /dev/null @@ -1,91 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestAccount001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - - /** - * constructor. - */ - @Test(enabled = true, description = "Get account by http") - public void getAccount() { - response = HttpMethed.getAccount(httpnode, fromAddress); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.size() > 3); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get account from solidity by http") - public void getAccountFromSolidity() { - response = HttpMethed.getAccountFromSolidity(httpSoliditynode, fromAddress); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.size() > 3); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get accountNet by http") - public void getAccountNet() { - response = HttpMethed.getAccountNet(httpnode, fromAddress); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(Integer.parseInt(responseContent.get("freeNetLimit").toString()), 5000); - Assert.assertEquals( - Long.parseLong(responseContent.get("TotalNetLimit").toString()), 43200000000L); - Assert.assertTrue(responseContent.size() >= 2); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get accountResource by http") - public void getAccountResource() { - response = HttpMethed.getAccountReource(httpnode, fromAddress); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue( - Long.parseLong(responseContent.get("TotalEnergyLimit").toString()) >= 50000000000L); - Assert.assertTrue(responseContent.size() >= 3); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount002.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount002.java deleted file mode 100644 index 1dcba0fbd4e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount002.java +++ /dev/null @@ -1,258 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestAccount002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(1); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] freezeBalanceAddress = ecKey1.getAddress(); - String freezeBalanceKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverResourceAddress = ecKey2.getAddress(); - String receiverResourceKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - Long berforeBalance; - Long afterBalance; - - Long amount = 10000000L; - Long frozenBalance = 2000000L; - - /** - * constructor. - */ - @Test(enabled = true, description = "FreezeBalance for bandwidth by http") - public void test01FreezebalanceForBandwidth() { - PublicMethed.printAddress(freezeBalanceKey); - //Send trx to test account - response = HttpMethed.sendCoin(httpnode, fromAddress, freezeBalanceAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - - //Freeze balance - response = HttpMethed.freezeBalance(httpnode, freezeBalanceAddress, frozenBalance, 0, - 0, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(berforeBalance - afterBalance == frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "UnFreezeBalance for bandwidth by http") - public void test02UnFreezebalanceForBandwidth() { - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - - //UnFreeze balance for bandwidth - response = HttpMethed.unFreezeBalance(httpnode, freezeBalanceAddress, 0, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(afterBalance - berforeBalance == frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "FreezeBalance for energy by http") - public void test03FreezebalanceForEnergy() { - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - - //Freeze balance for energy - response = HttpMethed.freezeBalance(httpnode, freezeBalanceAddress, frozenBalance, 0, - 1, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(berforeBalance - afterBalance == frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "UnFreezeBalance for energy by http") - public void test04UnFreezebalanceForEnergy() { - - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - HttpMethed.waitToProduceOneBlock(httpnode); - //UnFreeze balance for energy - response = HttpMethed.unFreezeBalance(httpnode, freezeBalanceAddress, 1, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(afterBalance - berforeBalance == frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "FreezeBalance with bandwidth for others by http") - public void test05FreezebalanceOfBandwidthForOthers() { - response = HttpMethed - .sendCoin(httpnode, fromAddress, receiverResourceAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - - //Freeze balance with bandwidth for others - response = HttpMethed.freezeBalance(httpnode, freezeBalanceAddress, frozenBalance, 0, - 0, receiverResourceAddress, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(berforeBalance - afterBalance == frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get Delegated Resource by http") - public void test06GetDelegatedResource() { - response = HttpMethed.getDelegatedResource( - httpnode, freezeBalanceAddress, receiverResourceAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("delegatedResource").toString()); - Assert.assertTrue(jsonArray.size() >= 1); - Assert.assertEquals(jsonArray.getJSONObject(0).getString("from"), - ByteArray.toHexString(freezeBalanceAddress)); - Assert.assertEquals(jsonArray.getJSONObject(0).getString("to"), - ByteArray.toHexString(receiverResourceAddress)); - Assert.assertEquals(jsonArray.getJSONObject(0).getLong("frozen_balance_for_bandwidth"), - frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get Delegated Resource from solidity by http") - public void test07GetDelegatedResourceFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - response = HttpMethed.getDelegatedResourceFromSolidity( - httpSoliditynode, freezeBalanceAddress, receiverResourceAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("delegatedResource").toString()); - Assert.assertTrue(jsonArray.size() >= 1); - Assert.assertEquals(jsonArray.getJSONObject(0).getString("from"), - ByteArray.toHexString(freezeBalanceAddress)); - Assert.assertEquals(jsonArray.getJSONObject(0).getString("to"), - ByteArray.toHexString(receiverResourceAddress)); - Assert.assertEquals(jsonArray.getJSONObject(0).getLong("frozen_balance_for_bandwidth"), - frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get Delegated Resource Account Index by http") - public void test08GetDelegatedResourceAccountIndex() { - response = HttpMethed.getDelegatedResourceAccountIndex(httpnode, freezeBalanceAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertFalse(responseContent.get("toAccounts").toString().isEmpty()); - String toAddress = responseContent.getJSONArray("toAccounts").get(0).toString(); - Assert.assertEquals(toAddress, ByteArray.toHexString(receiverResourceAddress)); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get Delegated Resource Account Index from solidity by http") - public void test09GetDelegatedResourceAccountIndexFromSolidity() { - response = HttpMethed.getDelegatedResourceAccountIndexFromSolidity(httpSoliditynode, - freezeBalanceAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertFalse(responseContent.get("toAccounts").toString().isEmpty()); - String toAddress = responseContent.getJSONArray("toAccounts").get(0).toString(); - Assert.assertEquals(toAddress, ByteArray.toHexString(receiverResourceAddress)); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "UnFreezeBalance with bandwidth for others by http") - public void test10UnFreezebalanceOfBandwidthForOthers() { - HttpMethed.waitToProduceOneBlock(httpnode); - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - - //UnFreeze balance with bandwidth for others - response = HttpMethed.unFreezeBalance(httpnode, freezeBalanceAddress, 0, - receiverResourceAddress, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(afterBalance - berforeBalance == frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "FreezeBalance with energy for others by http") - public void test11FreezebalanceOfEnergyForOthers() { - response = HttpMethed - .sendCoin(httpnode, fromAddress, receiverResourceAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - - //Freeze balance with energy for others - response = HttpMethed.freezeBalance(httpnode, freezeBalanceAddress, frozenBalance, 0, - 1, receiverResourceAddress, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(berforeBalance - afterBalance == frozenBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "UnFreezeBalance with energy for others by http") - public void test12UnFreezebalanceOfEnergyForOthers() { - berforeBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - - //UnFreeze balance with energy for others - response = HttpMethed.unFreezeBalance(httpnode, freezeBalanceAddress, 1, - receiverResourceAddress, freezeBalanceKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - afterBalance = HttpMethed.getBalance(httpnode, freezeBalanceAddress); - Assert.assertTrue(afterBalance - berforeBalance == frozenBalance); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount003.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount003.java deleted file mode 100644 index ccca38383a8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount003.java +++ /dev/null @@ -1,203 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestAccount003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witness1Address = PublicMethed.getFinalAddress(witnessKey001); - private final String witnessKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - private final byte[] witness2Address = PublicMethed.getFinalAddress(witnessKey002); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] newAccountAddress = ecKey1.getAddress(); - String newAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] updateAccountAddress = ecKey2.getAddress(); - String updateAccountKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private final Long createWitnessAmount = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.createWitnessAmount"); - Long amount = 50000000L; - private static String updateAccountName = "updateAccount_" - + Long.toString(System.currentTimeMillis()); - private static String updateUrl = - "http://www.update.url" + Long.toString(System.currentTimeMillis()); - - JsonArray voteKeys = new JsonArray(); - JsonObject voteElement = new JsonObject(); - - - /** - * constructor. - */ - @Test(enabled = true, description = "Update account by http") - public void test1UpdateAccount() { - response = HttpMethed.sendCoin(httpnode, fromAddress, updateAccountAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.updateAccount(httpnode, updateAccountAddress, updateAccountName, - updateAccountKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, updateAccountAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.getString("account_name") - .equalsIgnoreCase(HttpMethed.str2hex(updateAccountName))); - - Assert.assertFalse(responseContent.getString("active_permission").isEmpty()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Vote witness account by http") - public void test2VoteWitnessAccount() { - //Freeze balance - response = HttpMethed.freezeBalance(httpnode, updateAccountAddress, 40000000L, 0, - 0, updateAccountKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - voteElement.addProperty("vote_address", ByteArray.toHexString(witness1Address)); - voteElement.addProperty("vote_count", 11); - voteKeys.add(voteElement); - - voteElement.remove("vote_address"); - voteElement.remove("vote_count"); - voteElement.addProperty("vote_address", ByteArray.toHexString(witness2Address)); - voteElement.addProperty("vote_count", 12); - voteKeys.add(voteElement); - - response = HttpMethed.voteWitnessAccount(httpnode, updateAccountAddress, voteKeys, - updateAccountKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAccount(httpnode, updateAccountAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("votes").isEmpty()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "List witnesses by http") - public void test3ListWitness() { - response = HttpMethed.listwitnesses(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("witnesses")); - Assert.assertTrue(jsonArray.size() >= 2); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "List witnesses from solidity by http") - public void test4ListWitnessFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - response = HttpMethed.listwitnessesFromSolidity(httpSoliditynode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("witnesses")); - Assert.assertTrue(jsonArray.size() >= 2); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Update witness by http") - public void test5UpdateWitness() { - response = HttpMethed.updateWitness(httpnode, witness1Address, updateUrl, witnessKey001); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.listwitnesses(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.getString("witnesses").indexOf(updateUrl) != -1); - //logger.info("result is " + responseContent.getString("witnesses").indexOf(updateUrl)); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Create account by http") - public void test6CreateAccount() { - PublicMethed.printAddress(newAccountKey); - response = HttpMethed.createAccount(httpnode, fromAddress, newAccountAddress, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAccount(httpnode, newAccountAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.getLong("create_time") > 3); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Create witness by http") - public void test7CreateWitness() { - response = HttpMethed.sendCoin(httpnode, fromAddress, newAccountAddress, createWitnessAmount, - testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - PublicMethed.printAddress(newAccountKey); - - response = HttpMethed.createWitness(httpnode, newAccountAddress, updateUrl); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("txID").isEmpty()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Withdraw by http") - public void test8Withdraw() { - response = HttpMethed.withdrawBalance(httpnode, witness1Address); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue( - responseContent.getString("Error").indexOf("is a guard representative") != -1); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount004.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount004.java deleted file mode 100644 index 3cf78125602..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount004.java +++ /dev/null @@ -1,100 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestAccount004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] setAccountIdAddress = ecKey1.getAddress(); - String setAccountIdKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Long amount = 10000000L; - String accountId; - - - /** - * constructor. - */ - @Test(enabled = true, description = "Set account by http") - public void test1setAccountId() { - response = HttpMethed.sendCoin(httpnode, fromAddress, setAccountIdAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - - response = HttpMethed.setAccountId(httpnode,setAccountIdAddress, - System.currentTimeMillis() + "id",false,setAccountIdKey); - Assert.assertFalse(HttpMethed.verificationResult(response)); - - - //Set account id. - accountId = System.currentTimeMillis() + "id"; - response = HttpMethed.setAccountId(httpnode,setAccountIdAddress, - accountId,true,setAccountIdKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get account by id via http") - public void test2getAccountId() { - response = HttpMethed.getAccountById(httpnode,accountId,true); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.get("account_id"), accountId); - Assert.assertTrue(responseContent.size() >= 10); - - response = HttpMethed.getAccountById(httpnode,accountId,false); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.size() <= 1); - - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get account by id via http") - public void test3getAccountIdFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode,httpSoliditynode); - response = HttpMethed.getAccountByIdFromSolidity(httpSoliditynode,accountId,true); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.get("account_id"), accountId); - Assert.assertTrue(responseContent.size() >= 10); - } - - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAsset001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAsset001.java deleted file mode 100644 index f79c626faf4..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAsset001.java +++ /dev/null @@ -1,254 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestAsset001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private JSONObject getAssetIssueByIdContent; - private JSONObject getAssetIssueByNameContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(1); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] assetAddress = ecKey1.getAddress(); - String assetKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] participateAddress = ecKey2.getAddress(); - String participateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Long amount = 2048000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue002_" + Long.toString(now); - private static final long totalSupply = now; - private static String assetIssueId; - private static String updateDescription = "Description_update_" + Long.toString(now); - private static String updateUrl = "Url_update_" + Long.toString(now); - - /** - * constructor. - */ - @Test(enabled = true, description = "Create asset issue by http") - public void test01CreateAssetIssue() { - response = HttpMethed.sendCoin(httpnode, fromAddress, assetAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed - .sendCoin(httpnode, fromAddress, participateAddress, 10000000L, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - //Create an asset issue - response = HttpMethed.assetIssue(httpnode, assetAddress, name, name, totalSupply, 1, 1, - System.currentTimeMillis() + 5000, System.currentTimeMillis() + 50000000, - 2, 3, description, url, 1000L, 1000L, assetKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAccount(httpnode, assetAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - assetIssueId = responseContent.getString("asset_issued_ID"); - logger.info(assetIssueId); - Assert.assertTrue(Integer.parseInt(assetIssueId) > 1000000); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetAssetIssueById by http") - public void test02GetAssetIssueById() { - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAssetIssueById(httpnode, assetIssueId); - getAssetIssueByIdContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(getAssetIssueByIdContent); - Assert.assertTrue(totalSupply == getAssetIssueByIdContent.getLong("total_supply")); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetAssetIssueById from solidity by http") - public void test03GetAssetIssueByIdFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - response = HttpMethed.getAssetIssueByIdFromSolidity(httpSoliditynode, assetIssueId); - getAssetIssueByIdContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(getAssetIssueByIdContent); - Assert.assertTrue(totalSupply == getAssetIssueByIdContent.getLong("total_supply")); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetAssetIssueByName by http") - public void test04GetAssetIssueByName() { - response = HttpMethed.getAssetIssueByName(httpnode, name); - getAssetIssueByNameContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(getAssetIssueByNameContent); - Assert.assertTrue(totalSupply == getAssetIssueByNameContent.getLong("total_supply")); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetAssetIssueByName from solidity by http") - public void test05GetAssetIssueByNameFromSolidity() { - response = HttpMethed.getAssetIssueByNameFromSolidity(httpSoliditynode, name); - getAssetIssueByNameContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(getAssetIssueByNameContent); - Assert.assertTrue(totalSupply == getAssetIssueByNameContent.getLong("total_supply")); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "TransferAsset by http") - public void test06TransferAsset() { - logger.info("Transfer asset."); - response = HttpMethed.transferAsset(httpnode, assetAddress, participateAddress, assetIssueId, - 100L, assetKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAccount(httpnode, participateAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("assetV2").isEmpty()); - //logger.info(responseContent.get("assetV2").toString()); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Participate asset issue by http") - public void test07ParticipateAssetIssue() { - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.participateAssetIssue(httpnode, assetAddress, participateAddress, - assetIssueId, 1000L, participateKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAccount(httpnode, participateAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Update asset issue by http") - public void test08UpdateAssetIssue() { - response = HttpMethed.updateAssetIssue(httpnode, assetAddress, updateDescription, updateUrl, - 290L, 390L, assetKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAssetIssueById(httpnode, assetIssueId); - getAssetIssueByIdContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(getAssetIssueByIdContent); - - Assert.assertTrue(getAssetIssueByIdContent - .getLong("public_free_asset_net_limit") == 390L); - Assert.assertTrue(getAssetIssueByIdContent - .getLong("free_asset_net_limit") == 290L); - Assert.assertTrue(getAssetIssueByIdContent - .getString("description").equalsIgnoreCase(HttpMethed.str2hex(updateDescription))); - Assert.assertTrue(getAssetIssueByIdContent - .getString("url").equalsIgnoreCase(HttpMethed.str2hex(updateUrl))); - } - - - /** - * * constructor. * - */ - @Test(enabled = true, description = "Get asset issue list by http") - public void test09GetAssetissueList() { - - response = HttpMethed.getAssetissueList(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("assetIssue")); - Assert.assertTrue(jsonArray.size() >= 1); - } - - - /** - * * constructor. * - */ - @Test(enabled = true, description = "Get asset issue list from solidity by http") - public void test10GetAssetissueListFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - response = HttpMethed.getAssetIssueListFromSolidity(httpSoliditynode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("assetIssue")); - Assert.assertTrue(jsonArray.size() >= 1); - } - - - /** - * * constructor. * - */ - @Test(enabled = true, description = "Get paginated asset issue list by http") - public void test11GetPaginatedAssetissueList() { - response = HttpMethed.getPaginatedAssetissueList(httpnode, 0, 1); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("assetIssue")); - Assert.assertTrue(jsonArray.size() == 1); - } - - - /** - * * constructor. * - */ - @Test(enabled = true, description = "Get paginated asset issue list from solidity by http") - public void test12GetPaginatedAssetissueListFromSolidity() { - response = HttpMethed.getPaginatedAssetissueListFromSolidity(httpSoliditynode, 0, 1); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("assetIssue")); - Assert.assertTrue(jsonArray.size() == 1); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestBlock001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestBlock001.java deleted file mode 100644 index 2aa9034f30a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestBlock001.java +++ /dev/null @@ -1,282 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestBlock001 { - - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - private Integer currentBlockNum; - private JSONObject blockContent; - private String blockId; - - /** - * constructor. - */ - @Test(enabled = true, description = "Get now block by http") - public void get01NowBlock() { - response = HttpMethed.getNowBlock(httpnode); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - blockContent = responseContent; - blockId = responseContent.get("blockID").toString(); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.size() >= 2); - responseContent = HttpMethed.parseStringContent(responseContent.get("block_header").toString()); - Assert.assertTrue(responseContent.size() >= 2); - Assert.assertFalse(responseContent.get("witness_signature").toString().isEmpty()); - HttpMethed.printJsonContent(responseContent); - responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString()); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(Integer.parseInt(responseContent.get("number").toString()) > 0); - currentBlockNum = Integer.parseInt(responseContent.get("number").toString()); - Assert.assertTrue(Long.parseLong(responseContent.get("timestamp").toString()) > 1550724114000L); - Assert.assertFalse(responseContent.get("witness_address").toString().isEmpty()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get now block from solidity by http") - public void get02NowBlockFromSolidity() { - response = HttpMethed.getNowBlockFromSolidity(httpSoliditynode); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - blockContent = responseContent; - blockId = responseContent.get("blockID").toString(); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.size() >= 2); - responseContent = HttpMethed.parseStringContent(responseContent.get("block_header").toString()); - Assert.assertTrue(responseContent.size() >= 2); - Assert.assertFalse(responseContent.get("witness_signature").toString().isEmpty()); - HttpMethed.printJsonContent(responseContent); - responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString()); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(Integer.parseInt(responseContent.get("number").toString()) > 0); - currentBlockNum = Integer.parseInt(responseContent.get("number").toString()); - Assert.assertTrue(Long.parseLong(responseContent.get("timestamp").toString()) > 1550724114000L); - Assert.assertFalse(responseContent.get("witness_address").toString().isEmpty()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get block by num by http") - public void get03BlockByNum() { - response = HttpMethed.getBlockByNum(httpnode, currentBlockNum); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - Assert.assertEquals(responseContent, blockContent); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get block by num from solidity by http") - public void get04BlockByNumFromSolidity() { - response = HttpMethed.getBlockByNumFromSolidity(httpSoliditynode, currentBlockNum); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - Assert.assertEquals(responseContent, blockContent); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetBlockByLimitNext by http") - public void get05BlockByLimitNext() { - response = HttpMethed.getBlockByLimitNext(httpnode, currentBlockNum - 10, currentBlockNum); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - logger.info(responseContent.get("block").toString()); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("block").toString()); - Assert.assertEquals(jsonArray.size(), 10); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetBlockByLastNum by http") - public void get06BlockByLastNum() { - response = HttpMethed.getBlockByLastNum(httpnode, 8); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - logger.info(responseContent.get("block").toString()); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("block").toString()); - Assert.assertEquals(jsonArray.size(), 8); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetBlockById by http") - public void get07BlockById() { - response = HttpMethed.getBlockById(httpnode, blockId); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(blockId, responseContent.get("blockID").toString()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetBlockById by http") - public void get08BlockByIdFromSolidity() { - response = HttpMethed.getBlockByIdFromSolidity(httpSoliditynode, blockId); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(blockId, responseContent.get("blockID").toString()); - } - - - - /** - * constructor. - */ - @Test(enabled = true, description = "List nodes by http") - public void get09ListNodes() { - response = HttpMethed.listNodes(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "get next maintenance time by http") - public void get10NextMaintaenanceTime() { - response = HttpMethed.getNextmaintenanceTime(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertFalse(responseContent.get("num").toString().isEmpty()); - Assert.assertTrue(responseContent.getLong("num") >= System.currentTimeMillis()); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "get chain parameter by http") - public void get11ChainParameter() { - response = HttpMethed.getChainParameter(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("chainParameter").toString()); - Assert.assertTrue(jsonArray.size() >= 26); - Boolean exsistDelegated = false; - for (int i = 0; i < jsonArray.size(); i++) { - if (jsonArray.getJSONObject(i).getString("key").equals("getAllowDelegateResource")) { - exsistDelegated = true; - Assert.assertTrue(jsonArray.getJSONObject(i).getString("value").equals("1")); - } - } - Assert.assertTrue(exsistDelegated); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "get Node Info by http") - public void get12NodeInfo() { - response = HttpMethed.getNodeInfo(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertFalse(responseContent.get("configNodeInfo").toString().isEmpty()); - Assert.assertTrue(responseContent.getString("configNodeInfo").contains("\"dbVersion\":2")); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get transaction count by blocknum from solidity by http") - public void get13TransactionCountByBlocknumFromSolidity() { - response = HttpMethed.getTransactionCountByBlocknumFromSolidity(httpSoliditynode, - currentBlockNum); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.size() == 1); - Assert.assertTrue(Integer.parseInt(responseContent.get("count").toString()) >= 0); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetBlockByLimitNext by http") - public void get14BlockByLimitNextFromSolidity() { - response = HttpMethed.getBlockByLimitNextFromSolidity(httpSoliditynode, - currentBlockNum - 10, currentBlockNum); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - logger.info(responseContent.get("block").toString()); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("block").toString()); - Assert.assertEquals(jsonArray.size(), 10); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetBlockByLastNum by http") - public void get15BlockByLastNumFromSolidity() { - response = HttpMethed.getBlockByLastNumFromSolidity(httpSoliditynode, 8); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - logger.info(responseContent.get("block").toString()); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("block").toString()); - Assert.assertEquals(jsonArray.size(), 8); - } - - /** - * constructor. - */ - @Test(enabled = false, description = "Get block by num by http") - public void get16TestResponse() { - Integer times = 1000; - String testKey002 = "7400E3D0727F8A61041A8E8BF86599FE5597CE19DE451E59AED07D60967A5E25"; - byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Long duration = HttpMethed.getBlockByNumForResponse(httpnode, 4942435, times); - /* Long duration = HttpMethed.getAccountForResponse(httpnode, fromAddress, times);*/ - /* Long duration = HttpMethed.getTransactionByIdForResponse(httpnode, - "a265fc457551fd9cfa55daec0550268b1a2da54018cc700f1559454836de411c", times);*/ - logger.info("Total duration : " + duration); - logger.info("Average duration: " + duration / times); - } - - - - - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestClearAbiContract001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestClearAbiContract001.java deleted file mode 100644 index 15deddf3160..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestClearAbiContract001.java +++ /dev/null @@ -1,167 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import static org.hamcrest.core.StringContains.containsString; - -import com.alibaba.fastjson.JSONObject; -import java.util.HashMap; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestClearAbiContract001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] assetOwnerAddress = ecKey2.getAddress(); - String assetOwnerKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - String contractAddress; - String abi; - Long amount = 2048000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue002_" + Long.toString(now); - private static final long totalSupply = now; - private static String assetIssueId; - private static String contractName; - - - /** - * constructor. - */ - @Test(enabled = true, description = "Deploy smart contract by http") - public void test1DeployContract() { - PublicMethed.printAddress(assetOwnerKey); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.sendCoin(httpnode, fromAddress, assetOwnerAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, assetOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - String filePath = "src/test/resources/soliditycode/TriggerConstant003.sol"; - contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - abi = retMap.get("abI").toString(); - logger.info("abi:" + abi); - logger.info("code:" + code); - - String txid = HttpMethed.deployContractGetTxid(httpnode, contractName, abi, code, 1000000L, - 1000000000L, 100, 11111111111111L, - 0L, 0, 0L, assetOwnerAddress, assetOwnerKey); - - HttpMethed.waitToProduceOneBlock(httpnode); - logger.info(txid); - response = HttpMethed.getTransactionById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("contract_address").isEmpty()); - contractAddress = responseContent.getString("contract_address"); - - response = HttpMethed.getTransactionInfoById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - String receiptString = responseContent.getString("receipt"); - Assert - .assertEquals(HttpMethed.parseStringContent(receiptString).getString("result"), "SUCCESS"); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get contract by http") - public void test2GetContract() { - response = HttpMethed.getContract(httpnode, contractAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("consume_user_resource_percent"), "100"); - Assert.assertEquals(responseContent.getString("contract_address"), contractAddress); - Assert.assertEquals(responseContent.getString("origin_address"), - ByteArray.toHexString(assetOwnerAddress)); - Assert - .assertThat(responseContent.getString("abi"), - containsString("testView")); - - Assert.assertEquals(responseContent.getString("origin_energy_limit"), "11111111111111"); - Assert.assertEquals(responseContent.getString("name"), contractName); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Trigger contract by http") - public void test3TriggerConstantContract() { - - HttpResponse httpResponse = HttpMethed - .triggerConstantContract(httpnode, assetOwnerAddress, contractAddress, - "testView()", - ""); - - responseContent = HttpMethed.parseResponseContent(httpResponse); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("result"), "{\"result\":true}"); - Assert.assertEquals(responseContent.getString("constant_result"), - "[\"0000000000000000000000000000000000000000000000000000000000000001\"]"); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Trigger contract by http") - public void test4ClearAbiContract() { - - HttpResponse httpResponse = HttpMethed - .clearABiGetTxid(httpnode, assetOwnerAddress, contractAddress, assetOwnerKey); - - responseContent = HttpMethed.parseResponseContent(httpResponse); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("result"), "true"); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get contract by http") - public void test5GetContract() { - response = HttpMethed.getContract(httpnode, contractAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("consume_user_resource_percent"), "100"); - Assert.assertEquals(responseContent.getString("contract_address"), contractAddress); - Assert.assertEquals(responseContent.getString("origin_address"), - ByteArray.toHexString(assetOwnerAddress)); - Assert.assertEquals(responseContent.getString("abi"), "{}"); - Assert.assertEquals(responseContent.getString("origin_energy_limit"), "11111111111111"); - Assert.assertEquals(responseContent.getString("name"), contractName); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestConstantContract001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestConstantContract001.java deleted file mode 100644 index c33c5e5b670..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestConstantContract001.java +++ /dev/null @@ -1,120 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import java.util.HashMap; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestConstantContract001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] assetOwnerAddress = ecKey2.getAddress(); - String assetOwnerKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - String contractAddress; - - Long amount = 2048000000L; - - private static String contractName; - - - /** - * constructor. - */ - @Test(enabled = true, description = "Deploy constant contract by http") - public void test1DeployConstantContract() { - PublicMethed.printAddress(assetOwnerKey); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.sendCoin(httpnode, fromAddress, assetOwnerAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - String filePath = "src/test/resources/soliditycode/constantContract001.sol"; - contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = HttpMethed.deployContractGetTxid(httpnode, contractName, abi, code, 1000000L, - 1000000000L, 100, 11111111111111L, - 0L, 0, 0L, assetOwnerAddress, assetOwnerKey); - - HttpMethed.waitToProduceOneBlock(httpnode); - logger.info(txid); - response = HttpMethed.getTransactionById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("contract_address").isEmpty()); - contractAddress = responseContent.getString("contract_address"); - - response = HttpMethed.getTransactionInfoById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - String receiptString = responseContent.getString("receipt"); - Assert - .assertEquals(HttpMethed.parseStringContent(receiptString).getString("result"), "SUCCESS"); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get constant contract by http") - public void test2GetConstantContract() { - response = HttpMethed.getContract(httpnode, contractAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("consume_user_resource_percent"), "100"); - Assert.assertEquals(responseContent.getString("contract_address"), contractAddress); - Assert.assertEquals(responseContent.getString("origin_address"), - ByteArray.toHexString(assetOwnerAddress)); - Assert.assertEquals(responseContent.getString("origin_energy_limit"), "11111111111111"); - Assert.assertEquals(responseContent.getString("name"), contractName); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Trigger constant contract without parameterString by http") - public void test3TriggerConstantContract() { - String param1 = "000000000000000000000000000000000000000000000000000000000000000" - + Integer.toHexString(3); - String param2 = "00000000000000000000000000000000000000000000000000000000000000" - + Integer.toHexString(30); - logger.info(param1); - logger.info(param2); - String param = param1 + param2; - logger.info(ByteArray.toHexString(assetOwnerAddress)); - response = HttpMethed.triggerConstantContract(httpnode, assetOwnerAddress, contractAddress, - "testPure(uint256,uint256)",param, 1000000000L, assetOwnerKey); - HttpMethed.waitToProduceOneBlock(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("transaction").isEmpty()); - JSONObject transactionObject = HttpMethed.parseStringContent( - responseContent.getString("transaction")); - Assert.assertTrue(!transactionObject.getString("raw_data").isEmpty()); - Assert.assertTrue(!transactionObject.getString("raw_data_hex").isEmpty()); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestEasyAccount001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestEasyAccount001.java deleted file mode 100644 index 4c9e92e0493..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestEasyAccount001.java +++ /dev/null @@ -1,294 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestEasyAccount001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private long now = System.currentTimeMillis(); - private String userPassword = "ps_" + Long.toString(now); - private String assetName = "httpEasyAsset_" + Long.toString(now); - private final long totalSupply = now; - private static String assetIssueId; - - private String easyAddress = null; - - private String generatePriKey = null; - private String generateAddress = null; - private String generateHexAddress = null; - - long beforeEasyBalance = 0L; - long afterEasyBalance = 0L; - - long beforeGenerateBalance = 0L; - long afterGenerateBalance = 0L; - - long beforeEasyAsset = 0L; - long afterEasyAsset = 0L; - - long beforeGenerateAsset = 0L; - long afterGenerateAsset = 0L; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] assetAddress = ecKey1.getAddress(); - String assetKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - /** - * constructor. - */ - @Test(enabled = true, description = "Create address by http") - public void test01CreateAddress() { - logger.info(userPassword); - response = HttpMethed.createAddress(httpnode, userPassword); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - easyAddress = responseContent.get("base58checkAddress").toString(); - - //Send trx to easy account - response = HttpMethed - .sendCoin(httpnode, fromAddress, Wallet.decodeFromBase58Check(easyAddress), 5000000L, - testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - beforeEasyBalance = HttpMethed.getBalance(httpnode, Wallet.decodeFromBase58Check(easyAddress)); - logger.info("beforeEasyBalance: " + beforeEasyBalance); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Generate address by http") - public void test02GenerateAddress() { - response = HttpMethed.generateAddress(httpnode); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - generateAddress = responseContent.get("address").toString(); - generateHexAddress = responseContent.get("hexAddress").toString(); - generatePriKey = responseContent.get("privateKey").toString(); - - //Send trx to easy account - response = HttpMethed - .sendCoin(httpnode, fromAddress, Wallet.decodeFromBase58Check(generateAddress), 5000000L, - testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - beforeGenerateBalance = HttpMethed - .getBalance(httpnode, Wallet.decodeFromBase58Check(generateAddress)); - logger.info("beforeGenerateBalance: " + beforeGenerateBalance); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "Validate address by http") - public void test03ValideteAddress() { - // Base58check format - response = HttpMethed.validateAddress(httpnode, generateAddress); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - // Hex string format - response = HttpMethed.validateAddress(httpnode, generateHexAddress); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "Easy transfer by http") - public void test04EasyTransfer() { - response = HttpMethed - .easyTransfer(httpnode, userPassword, Wallet.decodeFromBase58Check(generateAddress), - 1000000L); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - HttpMethed.waitToProduceOneBlock(httpnode); - - //Send trx to easy account - afterEasyBalance = HttpMethed.getBalance(httpnode, Wallet.decodeFromBase58Check(easyAddress)); - logger.info("afterEasyBalance: " + afterEasyBalance); - - afterGenerateBalance = HttpMethed - .getBalance(httpnode, Wallet.decodeFromBase58Check(generateAddress)); - logger.info("afterGenerateBalance: " + afterGenerateBalance); - - Assert.assertEquals(beforeEasyBalance - afterEasyBalance, - afterGenerateBalance - beforeGenerateBalance); - beforeEasyBalance = afterEasyBalance; - beforeGenerateBalance = afterGenerateBalance; - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Easy transfer by privateKey by http") - public void test05EasyTransferByPrivateKey() { - response = HttpMethed - .easyTransferByPrivate(httpnode, generatePriKey, - Wallet.decodeFromBase58Check(easyAddress), - 1000000L); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - HttpMethed.waitToProduceOneBlock(httpnode); - - //Send trx to easy account - afterEasyBalance = HttpMethed.getBalance(httpnode, Wallet.decodeFromBase58Check(easyAddress)); - logger.info("beforeEasyBalance: " + beforeEasyBalance); - logger.info("afterEasyBalance: " + afterEasyBalance); - - afterGenerateBalance = HttpMethed - .getBalance(httpnode, Wallet.decodeFromBase58Check(generateAddress)); - logger.info("beforeGenerateBalance: " + beforeGenerateBalance); - logger.info("afterGenerateBalance: " + afterGenerateBalance); - - Assert.assertEquals(beforeGenerateBalance - afterGenerateBalance, - afterEasyBalance - beforeEasyBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Create asset issue by http") - public void test06CreateAssetIssue() { - Long amount = 2048000000L; - response = HttpMethed.sendCoin(httpnode, fromAddress, assetAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - //Create an asset issue - response = HttpMethed - .assetIssue(httpnode, assetAddress, assetName, assetName, totalSupply, 1, 1, - System.currentTimeMillis() + 5000, System.currentTimeMillis() + 50000000, - 2, 3, description, url, 1000L, 1000L, assetKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, assetAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - assetIssueId = responseContent.getString("asset_issued_ID"); - logger.info(assetIssueId); - Assert.assertTrue(Integer.parseInt(assetIssueId) > 1000000); - - response = HttpMethed - .transferAsset(httpnode, assetAddress, - Wallet.decodeFromBase58Check(easyAddress), assetIssueId, 100L, assetKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, Wallet.decodeFromBase58Check(easyAddress)); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - beforeEasyAsset = responseContent.getJSONArray("assetV2").getJSONObject(0) - .getLongValue("value"); - logger.info("beforeEasyAsset:" + beforeEasyAsset); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Easy transfer asset by http") - public void test07EasyTransferAsset() { - response = HttpMethed - .easyTransferAsset(httpnode, userPassword, Wallet.decodeFromBase58Check(generateAddress), - 10L, assetIssueId); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, Wallet.decodeFromBase58Check(easyAddress)); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - afterEasyAsset = responseContent.getJSONArray("assetV2").getJSONObject(0) - .getLongValue("value"); - logger.info("afterEasyAsset:" + afterEasyAsset); - - response = HttpMethed.getAccount(httpnode, Wallet.decodeFromBase58Check(generateAddress)); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - beforeGenerateAsset = responseContent.getJSONArray("assetV2").getJSONObject(0) - .getLongValue("value"); - logger.info("beforeGenerateAsset:" + beforeGenerateAsset); - Assert.assertEquals(beforeEasyAsset - afterEasyAsset, beforeGenerateAsset); - beforeEasyAsset = afterEasyAsset; - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Easy transfer asset by private key by http") - public void test08EasyTransferAssetByPrivateKey() { - response = HttpMethed - .easyTransferAssetByPrivate(httpnode, generatePriKey, - Wallet.decodeFromBase58Check(easyAddress), - 5L, assetIssueId); - logger.info("code is " + response.getStatusLine().getStatusCode()); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, Wallet.decodeFromBase58Check(easyAddress)); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - afterEasyAsset = responseContent.getJSONArray("assetV2").getJSONObject(0) - .getLongValue("value"); - logger.info("beforeEasyAsset:" + beforeEasyAsset); - logger.info("afterEasyAsset:" + afterEasyAsset); - - response = HttpMethed.getAccount(httpnode, Wallet.decodeFromBase58Check(generateAddress)); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - afterGenerateAsset = responseContent.getJSONArray("assetV2").getJSONObject(0) - .getLongValue("value"); - logger.info("afterGenerateAsset:" + afterGenerateAsset); - Assert - .assertEquals(beforeGenerateAsset - afterGenerateAsset, afterEasyAsset - beforeEasyAsset); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestExchange001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestExchange001.java deleted file mode 100644 index 257c9233ed8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestExchange001.java +++ /dev/null @@ -1,274 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestExchange001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(1); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] exchangeOwnerAddress = ecKey1.getAddress(); - String exchangeOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] asset2Address = ecKey2.getAddress(); - String asset2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Long amount = 2048000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue002_" + Long.toString(now); - private static final long totalSupply = now; - private static String assetIssueId1; - private static String assetIssueId2; - private static Integer exchangeId; - private static Long beforeInjectBalance; - private static Long afterInjectBalance; - private static Long beforeWithdrawBalance; - private static Long afterWithdrawBalance; - private static Long beforeTransactionBalance; - private static Long afterTransactionBalance; - - /** - * constructor. - */ - @Test(enabled = true, description = "Create asset issue by http") - public void test01CreateExchange() { - response = HttpMethed.sendCoin(httpnode, fromAddress, exchangeOwnerAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.sendCoin(httpnode, fromAddress, asset2Address, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - //Create an asset issue - response = HttpMethed.assetIssue(httpnode, exchangeOwnerAddress, name, name, totalSupply, 1, 1, - System.currentTimeMillis() + 5000, System.currentTimeMillis() + 50000000, - 2, 3, description, url, 1000L, 1000L, exchangeOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.assetIssue(httpnode, asset2Address, name, name, totalSupply, 1, 1, - System.currentTimeMillis() + 5000, System.currentTimeMillis() + 50000000, - 2, 3, description, url, 1000L, 1000L, asset2Key); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, exchangeOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - assetIssueId1 = responseContent.getString("asset_issued_ID"); - Assert.assertTrue(Integer.parseInt(assetIssueId1) > 1000000); - - response = HttpMethed.getAccount(httpnode, asset2Address); - responseContent = HttpMethed.parseResponseContent(response); - assetIssueId2 = responseContent.getString("asset_issued_ID"); - Assert.assertTrue(Integer.parseInt(assetIssueId2) > 1000000); - - response = HttpMethed - .transferAsset(httpnode, asset2Address, exchangeOwnerAddress, assetIssueId2, - 10000000000L, asset2Key); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - //Create exchange. - response = HttpMethed.exchangeCreate(httpnode, exchangeOwnerAddress, assetIssueId1, - 1000000L, assetIssueId2, 1000000L, exchangeOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "List exchanges by http") - public void test02ListExchange() { - response = HttpMethed.listExchanges(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("exchanges")); - Assert.assertTrue(jsonArray.size() >= 1); - exchangeId = jsonArray.size(); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "List exchanges from solidity by http") - public void test03ListExchangeFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - response = HttpMethed.listExchangesFromSolidity(httpSoliditynode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("exchanges")); - Assert.assertTrue(jsonArray.size() >= 1); - exchangeId = jsonArray.size(); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetExchangeById by http") - public void test04GetExchangeById() { - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.getInteger("exchange_id") == exchangeId); - Assert.assertEquals(responseContent.getString("creator_address"), - ByteArray.toHexString(exchangeOwnerAddress)); - beforeInjectBalance = responseContent.getLong("first_token_balance"); - - logger.info("beforeInjectBalance" + beforeInjectBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetExchangeById from solidity by http") - public void test05GetExchangeByIdFromSolidity() { - response = HttpMethed.getExchangeByIdFromSolidity(httpSoliditynode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.getInteger("exchange_id") == exchangeId); - Assert.assertEquals(responseContent.getString("creator_address"), - ByteArray.toHexString(exchangeOwnerAddress)); - beforeInjectBalance = responseContent.getLong("first_token_balance"); - - logger.info("beforeInjectBalance" + beforeInjectBalance); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Inject exchange by http") - public void test06InjectExchange() { - //Inject exchange. - response = HttpMethed.exchangeInject(httpnode, exchangeOwnerAddress, exchangeId, assetIssueId1, - 300L, exchangeOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - afterInjectBalance = responseContent.getLong("first_token_balance"); - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - logger.info("afterInjectBalance" + afterInjectBalance); - Assert.assertTrue(afterInjectBalance - beforeInjectBalance == 300L); - beforeWithdrawBalance = afterInjectBalance; - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Withdraw exchange by http") - public void test07WithdrawExchange() { - //Withdraw exchange. - response = HttpMethed - .exchangeWithdraw(httpnode, exchangeOwnerAddress, exchangeId, assetIssueId1, - 170L, exchangeOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - afterWithdrawBalance = responseContent.getLong("first_token_balance"); - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(beforeWithdrawBalance - afterWithdrawBalance == 170L); - beforeTransactionBalance = afterWithdrawBalance; - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Transaction exchange by http") - public void test08TransactionExchange() { - //Transaction exchange. - response = HttpMethed.exchangeTransaction(httpnode, exchangeOwnerAddress, exchangeId, - assetIssueId1, 100L, 1L, exchangeOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - afterTransactionBalance = responseContent.getLong("first_token_balance"); - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(afterTransactionBalance - beforeTransactionBalance >= 1); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "Get asset issue list by name by http") - public void test09GetAssetIssueListByName() { - response = HttpMethed.getAssetIssueListByName(httpnode, name); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("assetIssue").toString()); - Assert.assertTrue(jsonArray.size() >= 2); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get asset issue list by name from solidity by http") - public void test10GetAssetIssueListByNameFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - response = HttpMethed.getAssetIssueListByNameFromSolidity(httpSoliditynode, name); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.get("assetIssue").toString()); - Assert.assertTrue(jsonArray.size() >= 2); - } - - /** - * * constructor. * - */ - @Test(enabled = true, description = "Get paginated exchange list by http") - public void test11GetPaginatedExchangeList() { - - response = HttpMethed.getPaginatedExchangeList(httpnode, 0, 1); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("exchanges")); - Assert.assertTrue(jsonArray.size() == 1); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestMutiSign001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestMutiSign001.java deleted file mode 100644 index e4f2df9ba03..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestMutiSign001.java +++ /dev/null @@ -1,235 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class HttpTestMutiSign001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(1); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey1.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] hexTestAddress = ecKey2.getAddress(); - String hexTestKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - String[] permissionKeyString; - - - Long amount = 1000000000L; - JsonArray keys = new JsonArray(); - JsonArray activeKeys = new JsonArray(); - JsonObject manager1Wight = new JsonObject(); - JsonObject manager2Wight = new JsonObject(); - JsonObject manager3Wight = new JsonObject(); - JsonObject manager4Wight = new JsonObject(); - JsonObject ownerObject = new JsonObject(); - JsonObject witnessObject = new JsonObject(); - JsonObject activeObject = new JsonObject(); - - private final String manager1Key = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] manager1Address = PublicMethed.getFinalAddress(manager1Key); - - private final String manager2Key = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] manager2Address = PublicMethed.getFinalAddress(manager2Key); - - private final String manager3Key = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] manager3Address = PublicMethed.getFinalAddress(manager3Key); - - private final String manager4Key = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - private final byte[] manager4Address = PublicMethed.getFinalAddress(manager4Key); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Account Permission Up Date by http") - public void test1AccountPermissionUpDate() { - PublicMethed.printAddress(ownerKey); - response = HttpMethed.sendCoin(httpnode, fromAddress, ownerAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - manager1Wight.addProperty("address", ByteArray.toHexString(manager1Address)); - manager1Wight.addProperty("weight", 1); - - logger.info(manager1Wight.toString()); - manager2Wight.addProperty("address", ByteArray.toHexString(manager2Address)); - manager2Wight.addProperty("weight", 1); - - logger.info(manager2Wight.toString()); - - keys.add(manager1Wight); - keys.add(manager2Wight); - - ownerObject.addProperty("type", 0); - ownerObject.addProperty("permission_name", "owner"); - ownerObject.addProperty("threshold", 2); - ownerObject.add("keys", keys); - - - manager3Wight.addProperty("address", ByteArray.toHexString(manager3Address)); - manager3Wight.addProperty("weight", 1); - - logger.info(manager3Wight.toString()); - manager4Wight.addProperty("address", ByteArray.toHexString(manager4Address)); - manager4Wight.addProperty("weight", 1); - - logger.info(manager4Wight.toString()); - - activeKeys.add(manager3Wight); - activeKeys.add(manager4Wight); - - - - activeObject.addProperty("type", 2); - activeObject.addProperty("permission_name", "active0"); - activeObject.addProperty("threshold", 2); - activeObject.addProperty("operations", - "7fff1fc0037e0000000000000000000000000000000000000000000000000000"); - activeObject.add("keys", activeKeys); - - response = HttpMethed.accountPermissionUpdate(httpnode, ownerAddress, ownerObject, - witnessObject, activeObject, ownerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Add transaction sign by http with permission id") - public void test2AddTransactionSign() { - - HttpMethed.waitToProduceOneBlock(httpnode); - permissionKeyString = new String[2]; - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - - String[] permissionKeyActive = new String[2]; - permissionKeyActive[0] = manager3Key; - permissionKeyActive[1] = manager4Key; - - response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 10L, 0,permissionKeyString); - Assert.assertTrue(HttpMethed.verificationResult(response)); - - response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 10L, 2,permissionKeyString); - Assert.assertFalse(HttpMethed.verificationResult(response)); - - logger.info("start permission id 2"); - response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 12L, 2,permissionKeyActive); - Assert.assertTrue(HttpMethed.verificationResult(response)); - - response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 12L, 0,permissionKeyActive); - Assert.assertFalse(HttpMethed.verificationResult(response)); - - response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 11L, 1,permissionKeyActive); - Assert.assertFalse(HttpMethed.verificationResult(response)); - - response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 11L, 3,permissionKeyString); - Assert.assertFalse(HttpMethed.verificationResult(response)); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Add broadcasthex http interface to " - + "broadcast hex transaction string") - public void test3Broadcasthex() { - PublicMethed.printAddress(hexTestKey); - String transactionHex = PublicMethed - .sendcoinGetTransactionHex(hexTestAddress, 1000L, fromAddress, testKey002, - blockingStubFull); - String wrongTransactionHex = transactionHex + "wrong"; - response = HttpMethed.broadcasthex(httpnode, wrongTransactionHex); - logger.info("transaction wrong:"); - Assert.assertFalse(HttpMethed.verificationResult(response)); - - //Wrong type of hex - response = HttpMethed.broadcasthex(httpnode, transactionHex); - Assert.assertTrue(HttpMethed.verificationResult(response)); - - //SingleSign for broadcastHex - response = HttpMethed.broadcasthex(httpnode, transactionHex); - Assert.assertFalse(HttpMethed.verificationResult(response)); - - //Mutisign for broadcastHex - String mutiSignTransactionHex = PublicMethedForMutiSign - .sendcoinGetTransactionHex(hexTestAddress, 999L, ownerAddress, ownerKey, blockingStubFull, - permissionKeyString); - response = HttpMethed.broadcasthex(httpnode, mutiSignTransactionHex); - Assert.assertTrue(HttpMethed.verificationResult(response)); - - //Hex is null - response = HttpMethed.broadcasthex(httpnode, ""); - Assert.assertFalse(HttpMethed.verificationResult(response)); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestProposal001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestProposal001.java deleted file mode 100644 index f1369a3862e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestProposal001.java +++ /dev/null @@ -1,152 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.utils.ByteArray; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestProposal001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private String httpnode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(0); - private JSONObject responseContent; - private HttpResponse response; - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witness1Address = PublicMethed.getFinalAddress(witnessKey001); - private final String witnessKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - private final byte[] witness2Address = PublicMethed.getFinalAddress(witnessKey002); - private static Integer proposalId; - - - /** - * constructor. - */ - @Test(enabled = true, description = "Create proposal by http") - public void test1CreateProposal() { - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.createProposal(httpnode, witness1Address, 21L, 1L, witnessKey001); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - } - - /** - * * constructor. * - */ - @Test(enabled = true, description = "List proposals by http") - public void test2ListProposals() { - response = HttpMethed.listProposals(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("proposals")); - Assert.assertTrue(jsonArray.size() >= 1); - proposalId = jsonArray.size(); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetProposalById by http") - public void test3GetExchangeById() { - response = HttpMethed.getProposalById(httpnode, proposalId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.getInteger("proposal_id") == proposalId); - Assert.assertEquals(responseContent.getString("proposer_address"), - ByteArray.toHexString(witness1Address)); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Approval proposal by http") - public void test4ApprovalProposal() { - response = HttpMethed.approvalProposal(httpnode, witness1Address, proposalId, - true, witnessKey001); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.approvalProposal(httpnode, witness2Address, proposalId, - true, witnessKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getProposalById(httpnode, proposalId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("approvals")); - Assert.assertTrue(jsonArray.size() == 2); - } - - - /** - * * constructor. * - */ - @Test(enabled = true, description = "Get paginated proposal list by http") - public void test5GetPaginatedProposalList() { - - response = HttpMethed.getPaginatedProposalList(httpnode, 0, 1); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("proposals")); - Assert.assertTrue(jsonArray.size() == 1); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Delete proposal by http") - public void test6DeleteProposal() { - response = HttpMethed.deleteProposal(httpnode, witness1Address, proposalId, witnessKey001); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getProposalById(httpnode, proposalId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("state"), "CANCELED"); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "Get chain parameters by http") - public void test7GetChainParameters() { - response = HttpMethed.getChainParameters(httpnode); - HttpMethed.waitToProduceOneBlock(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals("getMaintenanceTimeInterval", - responseContent.getJSONArray("chainParameter").getJSONObject(0) - .get("key")); - Assert.assertEquals(300000, responseContent.getJSONArray("chainParameter").getJSONObject(0) - .get("value")); - Assert.assertEquals("getCreateAccountFee", - responseContent.getJSONArray("chainParameter").getJSONObject(2) - .get("key")); - Assert.assertEquals(100000, responseContent.getJSONArray("chainParameter").getJSONObject(2) - .get("value")); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} - diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestSendCoin001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestSendCoin001.java deleted file mode 100644 index d5831d2aef4..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestSendCoin001.java +++ /dev/null @@ -1,126 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestSendCoin001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private String httpnode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(1); - private String httpSoliditynode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] receiverAddress = ecKey1.getAddress(); - String receiverKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Long amount = 1000L; - private JSONObject responseContent; - private HttpResponse response; - - /** - * constructor. - */ - @Test(enabled = true, description = "SendCoin by http") - public void test1SendCoin() { - response = HttpMethed.sendCoin(httpnode, fromAddress, receiverAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - Assert.assertEquals(HttpMethed.getBalance(httpnode, receiverAddress), amount); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get transaction by id from solidity by http") - public void test2GetTransactionByIdFromSolidity() { - String txid = HttpMethed.sendCoinGetTxid(httpnode, fromAddress, receiverAddress, amount, - testKey002); - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - - response = HttpMethed.getTransactionByIdFromSolidity(httpSoliditynode, txid); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String retString = responseContent.getString("ret"); - JSONArray array = JSONArray.parseArray(retString); - Assert.assertEquals(HttpMethed.parseStringContent(array.get(0).toString()).getString( - "contractRet"), "SUCCESS"); - Assert.assertTrue(responseContent.size() > 4); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get transaction info by id from solidity by http") - public void test3GetTransactionInfoByIdFromSolidity() { - String txid = HttpMethed.sendCoinGetTxid(httpnode, fromAddress, receiverAddress, amount, - testKey002); - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode); - - response = HttpMethed.getTransactionInfoByIdFromSolidity(httpSoliditynode, txid); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.size() > 4); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get transactions from this from solidity by http") - public void test4GetTransactionsFromThisFromSolidity() { - response = HttpMethed - .getTransactionsFromThisFromSolidity(httpSoliditynode, fromAddress, 0, 100); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONObject transactionObject = HttpMethed.parseStringContent(JSONArray.parseArray( - responseContent.getString("transaction")).get(0).toString()); - String retString = transactionObject.getString("ret"); - JSONArray array = JSONArray.parseArray(retString); - Assert.assertEquals(HttpMethed.parseStringContent(array.get(0).toString()) - .getString("contractRet"), "SUCCESS"); - Assert.assertTrue(responseContent.size() == 1); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get transactions to this from solidity by http") - public void test5GetTransactionsToThisFromSolidity() { - response = HttpMethed - .getTransactionsFromThisFromSolidity(httpSoliditynode, fromAddress, 0, 100); - Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONObject transactionObject = HttpMethed.parseStringContent( - JSONArray.parseArray(responseContent.getString("transaction")).get(0).toString()); - String retString = transactionObject.getString("ret"); - JSONArray array = JSONArray.parseArray(retString); - Assert.assertEquals(HttpMethed.parseStringContent(array.get(0).toString()).getString( - "contractRet"), "SUCCESS"); - Assert.assertTrue(responseContent.size() == 1); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } - -} - diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestSmartContract001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestSmartContract001.java deleted file mode 100644 index 742b856df90..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestSmartContract001.java +++ /dev/null @@ -1,245 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpTestSmartContract001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] assetOwnerAddress = ecKey2.getAddress(); - String assetOwnerKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] assetReceiverAddress = ecKey3.getAddress(); - String assetReceiverKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - String contractAddress; - - Long amount = 2048000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue002_" + Long.toString(now); - private static final long totalSupply = now; - private static String assetIssueId; - private static String contractName; - - - /** - * constructor. - */ - @Test(enabled = true, description = "Deploy smart contract by http") - public void test1DeployContract() { - PublicMethed.printAddress(assetOwnerKey); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.sendCoin(httpnode, fromAddress, assetOwnerAddress, amount, testKey002); - response = HttpMethed.sendCoin(httpnode, fromAddress, assetReceiverAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - //Create an asset issue - response = HttpMethed.freezeBalance(httpnode,assetOwnerAddress,100000000L,3,1,assetOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - response = HttpMethed.assetIssue(httpnode, assetOwnerAddress, name, name, totalSupply, 1, 1, - System.currentTimeMillis() + 5000, System.currentTimeMillis() + 50000000, - 2, 3, description, url, 1000L, 1000L, assetOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, assetOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - assetIssueId = responseContent.getString("asset_issued_ID"); - - contractName = "transferTokenContract"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_ContractTrcToken001_transferTokenContract"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_ContractTrcToken001_transferTokenContract"); - - - long tokenValue = 100000; - long callValue = 5000; - - //This deploy is test too large call_token_value will made the witness node cpu 100% - /*response = HttpMethed.deployContractGetTxidWithTooBigLong(httpnode, - contractName, abi, code, 1000000L,1000000000L, 100, 11111111111111L, - callValue, Integer.parseInt(assetIssueId), tokenValue, assetOwnerAddress, assetOwnerKey); - responseContent = HttpMethed.parseResponseContent(response); - Assert.assertTrue(responseContent.getString("Error").contains("Overflow"));*/ - - - - - String txid = HttpMethed.deployContractGetTxid(httpnode, contractName, abi, code, 1000000L, - 1000000000L, 100, 11111111111111L, - callValue, Integer.parseInt(assetIssueId), tokenValue, assetOwnerAddress, assetOwnerKey); - - HttpMethed.waitToProduceOneBlock(httpnode); - logger.info(txid); - response = HttpMethed.getTransactionById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("contract_address").isEmpty()); - contractAddress = responseContent.getString("contract_address"); - - response = HttpMethed.getTransactionInfoById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - String receiptString = responseContent.getString("receipt"); - Assert - .assertEquals(HttpMethed.parseStringContent(receiptString).getString("result"), "SUCCESS"); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get contract by http") - public void test2GetContract() { - response = HttpMethed.getContract(httpnode, contractAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("consume_user_resource_percent"), "100"); - Assert.assertEquals(responseContent.getString("contract_address"), contractAddress); - Assert.assertEquals(responseContent.getString("origin_address"), - ByteArray.toHexString(assetOwnerAddress)); - Assert.assertEquals(responseContent.getString("call_value"), "5000"); - Assert.assertEquals(responseContent.getString("origin_energy_limit"), "11111111111111"); - Assert.assertEquals(responseContent.getString("name"), contractName); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Trigger contract by http") - public void test3TriggerContract() { - - String hexReceiverAddress = ByteArray.toHexString(assetReceiverAddress); - String addressParam = "000000000000000000000000" + hexReceiverAddress.substring(2);//[0,3) - - String tokenIdParam = "00000000000000000000000000000000000000000000000000000000000" - + Integer.toHexString(Integer.parseInt(assetIssueId)); - - String tokenValueParam = "0000000000000000000000000000000000000000000000000000000000000001"; - logger.info(addressParam); - logger.info(tokenIdParam); - logger.info(tokenValueParam); - final Long beforeBalance = HttpMethed.getBalance(httpnode,assetOwnerAddress); - String param = addressParam + tokenIdParam + tokenValueParam; - Long callValue = 10L; - String txid = HttpMethed.triggerContractGetTxid(httpnode, assetOwnerAddress, contractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, 1000000000L, callValue, Integer.parseInt(assetIssueId), 20L, assetOwnerKey); - - HttpMethed.waitToProduceOneBlock(httpnode); - //String txid = "49a30653d6e648da1e9a104b051b1b55c185fcaa0c2885405ae1d2fb258e3b3c"; - logger.info(txid); - response = HttpMethed.getTransactionById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(txid, responseContent.getString("txID")); - Assert.assertTrue(!responseContent.getString("raw_data").isEmpty()); - Assert.assertTrue(!responseContent.getString("raw_data_hex").isEmpty()); - Long afterBalance = HttpMethed.getBalance(httpnode,assetOwnerAddress); - logger.info("beforeBalance: " + beforeBalance); - logger.info("afterBalance: " + afterBalance); - Assert.assertTrue(beforeBalance - afterBalance == callValue); - - - - response = HttpMethed.getTransactionInfoById(httpnode, txid); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - String receiptString = responseContent.getString("receipt"); - Assert - .assertEquals(HttpMethed.parseStringContent(receiptString).getString("result"), "SUCCESS"); - Assert.assertTrue(HttpMethed.parseStringContent(receiptString).getLong("energy_usage") > 0); - Assert.assertTrue(responseContent.getLong("blockNumber") > 0); - - response = HttpMethed.getAccount(httpnode, assetReceiverAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(!responseContent.getString("assetV2").isEmpty()); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "UpdateSetting contract by http") - public void test4UpdateSetting() { - - //assetOwnerAddress, assetOwnerKey - response = HttpMethed - .updateSetting(httpnode, assetOwnerAddress, contractAddress, 75, assetOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - response = HttpMethed.getContract(httpnode, contractAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("consume_user_resource_percent"), "75"); - Assert.assertEquals(responseContent.getString("contract_address"), contractAddress); - Assert.assertEquals(responseContent.getString("origin_address"), - ByteArray.toHexString(assetOwnerAddress)); - Assert.assertEquals(responseContent.getString("call_value"), "5000"); - Assert.assertEquals(responseContent.getString("origin_energy_limit"), "11111111111111"); - Assert.assertEquals(responseContent.getString("name"), contractName); - } - - - /** - * constructor. - */ - @Test(enabled = true, description = "UpdateEnergyLimit contract by http") - public void test5UpdateEnergyLimit() { - - //assetOwnerAddress, assetOwnerKey - response = HttpMethed - .updateEnergyLimit(httpnode, assetOwnerAddress, contractAddress, 1234567, assetOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - response = HttpMethed.getContract(httpnode, contractAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertEquals(responseContent.getString("consume_user_resource_percent"), "75"); - Assert.assertEquals(responseContent.getString("contract_address"), contractAddress); - Assert.assertEquals(responseContent.getString("origin_address"), - ByteArray.toHexString(assetOwnerAddress)); - Assert.assertEquals(responseContent.getString("call_value"), "5000"); - Assert.assertEquals(responseContent.getString("origin_energy_limit"), "1234567"); - Assert.assertEquals(responseContent.getString("name"), contractName); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken001.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken001.java deleted file mode 100644 index fe614cba773..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken001.java +++ /dev/null @@ -1,382 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Note; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.config.args.Args; -import org.tron.core.zen.address.DiversifierT; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; -import stest.tron.wallet.common.client.utils.ShieldNoteInfo; - -@Slf4j -public class HttpTestZenToken001 { - - private String httpnode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(0); - private String httpSolidityNode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private String tokenId = zenTokenId; - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - - List shieldOutList = new ArrayList<>(); - Optional shieldAddressOptionalInfo1; - Optional shieldAddressOptionalInfo2; - Optional shieldAddressOptionalInfo3; - ShieldAddressInfo shieldAddressInfo1 = new ShieldAddressInfo(); - ShieldAddressInfo shieldAddressInfo2 = new ShieldAddressInfo(); - ShieldAddressInfo shieldAddressInfo3 = new ShieldAddressInfo(); - String assetIssueId; - ShieldNoteInfo shieldNote1; - ShieldNoteInfo shieldNote2; - ShieldNoteInfo shieldNote3; - String memo; - String sk; - String d1; - String d2; - String d3; - String ask; - String nsk; - String ovk; - String ak; - String nk; - String ivk; - String pkD1; - String pkD2; - String pkD3; - String paymentAddress1; - String paymentAddress2; - String paymentAddress3; - String rcm; - - private Long costTokenAmount = 20 * zenTokenFee; - private Long sendTokenAmount = 8 * zenTokenFee; - private JSONObject responseContent; - private HttpResponse response; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - } - - @Test(enabled = true, description = "Get spending key by http") - public void test01GetSpendingKey() { - response = HttpMethed.getSpendingKey(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - sk = responseContent.getString("value"); - logger.info("sk: " + sk); - - } - - @Test(enabled = true, description = "Get diversifier by http") - public void test02GetDiversifier() { - response = HttpMethed.getDiversifier(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - d1 = responseContent.getString("d"); - logger.info("d1: " + d1); - - response = HttpMethed.getDiversifier(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - d2 = responseContent.getString("d"); - logger.info("d2: " + d2); - - response = HttpMethed.getDiversifier(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - d3 = responseContent.getString("d"); - logger.info("d3: " + d3); - } - - @Test(enabled = true, description = "Get expanded spending key by http") - public void test03GetExpandedSpendingKey() { - response = HttpMethed.getExpandedSpendingKey(httpnode, sk); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - ask = responseContent.getString("ask"); - nsk = responseContent.getString("nsk"); - ovk = responseContent.getString("ovk"); - logger.info("ask: " + ask); - logger.info("nsk: " + nsk); - logger.info("ovk: " + ovk); - } - - @Test(enabled = true, description = "Get AK from ASK by http") - public void test04GetAkFromAsk() { - response = HttpMethed.getAkFromAsk(httpnode, ask); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - ak = responseContent.getString("value"); - logger.info("ak: " + ak); - } - - @Test(enabled = true, description = "Get Nk from Nsk by http") - public void test05GetNkFromNsk() { - response = HttpMethed.getNkFromNsk(httpnode, nsk); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - nk = responseContent.getString("value"); - logger.info("nk: " + nk); - } - - @Test(enabled = true, description = "Get incoming viewing Key by http") - public void test06GetIncomingViewingKey() { - response = HttpMethed.getIncomingViewingKey(httpnode, ak, nk); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - ivk = responseContent.getString("ivk"); - logger.info("ivk: " + ivk); - } - - @Test(enabled = true, description = "Get Zen Payment Address by http") - public void test07GetZenPaymentAddress() { - response = HttpMethed.getZenPaymentAddress(httpnode, ivk, d1); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - pkD1 = responseContent.getString("pkD"); - paymentAddress1 = responseContent.getString("payment_address"); - System.out.println("pkd1: " + pkD1); - System.out.println("address1: " + paymentAddress1); - shieldAddressInfo1.setSk(ByteArray.fromHexString(sk)); - shieldAddressInfo1.setD(new DiversifierT(ByteArray.fromHexString(d1))); - shieldAddressInfo1.setIvk(ByteArray.fromHexString(ivk)); - shieldAddressInfo1.setOvk(ByteArray.fromHexString(ovk)); - shieldAddressInfo1.setPkD(ByteArray.fromHexString(pkD1)); - shieldAddressOptionalInfo1 = Optional.of(shieldAddressInfo1); - - response = HttpMethed.getZenPaymentAddress(httpnode, ivk, d2); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - pkD2 = responseContent.getString("pkD"); - paymentAddress2 = responseContent.getString("payment_address"); - System.out.println("pkd2: " + pkD2); - System.out.println("address2: " + paymentAddress2); - shieldAddressInfo2.setSk(ByteArray.fromHexString(sk)); - shieldAddressInfo2.setD(new DiversifierT(ByteArray.fromHexString(d2))); - shieldAddressInfo2.setIvk(ByteArray.fromHexString(ivk)); - shieldAddressInfo2.setOvk(ByteArray.fromHexString(ovk)); - shieldAddressInfo2.setPkD(ByteArray.fromHexString(pkD2)); - shieldAddressOptionalInfo2 = Optional.of(shieldAddressInfo2); - - response = HttpMethed.getZenPaymentAddress(httpnode, ivk, d3); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - pkD3 = responseContent.getString("pkD"); - paymentAddress3 = responseContent.getString("payment_address"); - System.out.println("pkd3: " + pkD3); - System.out.println("address3: " + paymentAddress3); - shieldAddressInfo3.setSk(ByteArray.fromHexString(sk)); - shieldAddressInfo3.setD(new DiversifierT(ByteArray.fromHexString(d3))); - shieldAddressInfo3.setIvk(ByteArray.fromHexString(ivk)); - shieldAddressInfo3.setOvk(ByteArray.fromHexString(ovk)); - shieldAddressInfo3.setPkD(ByteArray.fromHexString(pkD3)); - shieldAddressOptionalInfo3 = Optional.of(shieldAddressInfo3); - } - - @Test(enabled = true, description = "Get rcm by http") - public void test08GetRcm() { - response = HttpMethed.getRcm(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - rcm = responseContent.getString("value"); - logger.info("rcm: " + rcm); - } - - @Test(enabled = true, description = "Public to shield transaction withoutask by http") - public void test09PublicToShieldTransactionWithoutAsk() { - response = HttpMethed - .transferAsset(httpnode, foundationZenTokenAddress, zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenKey); - org.junit.Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - - response = HttpMethed.getAccount(httpnode, foundationZenTokenAddress); - responseContent = HttpMethed.parseResponseContent(response); - assetIssueId = responseContent.getString("asset_issued_ID"); - - final Long beforeAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsed = responseContent.getLong("freeNetUsed"); - - String memo1 = "Shield memo11 in " + System.currentTimeMillis(); - String memo2 = "Shield memo22 in " + System.currentTimeMillis(); - Long sendSheldAddressAmount1 = zenTokenFee * 2; - Long sendSheldAddressAmount2 = zenTokenFee * 3; - Long sendAmount = sendSheldAddressAmount1 + sendSheldAddressAmount2 + zenTokenFee; - shieldOutList.clear(); - shieldOutList = HttpMethed - .addShieldOutputList(httpnode, shieldOutList, shieldAddressOptionalInfo1.get().getAddress(), - "" + sendSheldAddressAmount1, memo1); - shieldOutList = HttpMethed - .addShieldOutputList(httpnode, shieldOutList, shieldAddressOptionalInfo2.get().getAddress(), - "" + sendSheldAddressAmount2, memo2); - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - response = HttpMethed - .sendShieldCoinWithoutAsk(httpnode, httpSolidityNode, zenTokenOwnerAddress, sendAmount, - null, null, shieldOutList, null, 0, zenTokenOwnerKey); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - HttpMethed.waitToProduceOneBlock(httpnode); - Long afterAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterNetUsed = responseContent.getLong("freeNetUsed"); - - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == sendAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - - String memo3 = "Shield memo33 in " + System.currentTimeMillis(); - Long sendSheldAddressAmount3 = costTokenAmount - sendAmount - zenTokenFee; - shieldOutList.clear(); - shieldOutList = HttpMethed - .addShieldOutputList(httpnode, shieldOutList, shieldAddressOptionalInfo3.get().getAddress(), - "" + sendSheldAddressAmount3, memo3); - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - response = HttpMethed - .sendShieldCoinWithoutAsk(httpnode, httpSolidityNode, zenTokenOwnerAddress, - sendSheldAddressAmount3 + zenTokenFee, null, null, shieldOutList, null, 0, - zenTokenOwnerKey); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - List shieldNoteInfoByIvkList = HttpMethed - .scanNoteByIvk(httpnode, shieldAddressOptionalInfo1.get()); - Assert.assertTrue(shieldNoteInfoByIvkList.size() == 3); - List shieldNoteInfoByMarkList = HttpMethed - .scanAndMarkNoteByIvk(httpnode, shieldAddressOptionalInfo2.get()); - Assert.assertTrue(shieldNoteInfoByMarkList.size() == 3); - - shieldNote1 = shieldNoteInfoByIvkList.get(0); - shieldNote2 = shieldNoteInfoByIvkList.get(1); - shieldNote3 = shieldNoteInfoByIvkList.get(2); - Assert.assertTrue(shieldNote1.getValue() == sendSheldAddressAmount1); - Assert.assertEquals(memo1.getBytes(), shieldNote1.getMemo()); - Assert.assertTrue(shieldNote2.getValue() == sendSheldAddressAmount2); - Assert.assertEquals(memo2.getBytes(), shieldNote2.getMemo()); - Assert.assertTrue(shieldNote3.getValue() == sendSheldAddressAmount3); - Assert.assertEquals(memo3.getBytes(), shieldNote3.getMemo()); - Assert.assertFalse(shieldNoteInfoByMarkList.get(0).getIsSpend()); - Assert.assertFalse(shieldNoteInfoByMarkList.get(1).getIsSpend()); - Assert.assertFalse(shieldNoteInfoByMarkList.get(2).getIsSpend()); - } - - @Test(enabled = true, description = "Shield to shield transaction withoutask by http") - public void test10ShieldToShieldTransactionWithoutAsk() { - Optional receiverShieldAddressInfo1 = HttpMethed - .generateShieldAddress(httpnode); - String receiverShieldAddress1 = receiverShieldAddressInfo1.get().getAddress(); - logger.info("receiverShieldAddress1:" + receiverShieldAddress1); - Optional receiverShieldAddressInfo2 = HttpMethed - .generateShieldAddress(httpnode); - String receiverShieldAddress2 = receiverShieldAddressInfo2.get().getAddress(); - logger.info("receiverShieldAddress2:" + receiverShieldAddress2); - Optional receiverShieldAddressInfo3 = HttpMethed - .generateShieldAddress(httpnode); - String receiverShieldAddress3 = receiverShieldAddressInfo3.get().getAddress(); - logger.info("receiverShieldAddress3:" + receiverShieldAddress3); - - shieldOutList.clear(); - String receiverMemo1 = "Shield memo1 in " + System.currentTimeMillis(); - shieldOutList = HttpMethed - .addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress1, - "" + (shieldNote1.getValue() - zenTokenFee), receiverMemo1); - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - response = HttpMethed - .sendShieldCoinWithoutAsk(httpnode, httpSolidityNode, null, 0, - shieldAddressOptionalInfo1.get(), shieldNote1, shieldOutList, null, 0, null); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - /*shieldOutList.clear(); - String receiverMemo2 = "Shield memo2 in " + System.currentTimeMillis(); - shieldOutList = HttpMethed - .addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress2, - "" + (shieldNote2.getValue() - zenTokenFee), receiverMemo2); - response = HttpMethed - .sendShieldCoinWithoutAsk(httpnode, null, 0, shieldAddressOptionalInfo2.get(), shieldNote2, - shieldOutList, - null, 0, null); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent);*/ - shieldOutList.clear(); - String receiverMemo3 = "Shield memo3 in " + System.currentTimeMillis(); - shieldOutList = HttpMethed - .addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress3, - "" + (shieldNote3.getValue() - zenTokenFee), receiverMemo3); - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - response = HttpMethed - .sendShieldCoinWithoutAsk(httpnode, httpSolidityNode, null, 0, - shieldAddressOptionalInfo3.get(), shieldNote3, shieldOutList, null, 0, null); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - HttpMethed.waitToProduceOneBlock(httpnode); - - List shieldNoteInfoByOvkList = HttpMethed - .scanNoteByOvk(httpnode, shieldAddressOptionalInfo3.get()); - Assert.assertTrue(shieldNoteInfoByOvkList.size() == 2); - List shieldNoteInfoByMarkList = HttpMethed - .scanAndMarkNoteByIvk(httpnode, shieldAddressOptionalInfo2.get()); - Assert.assertTrue(shieldNoteInfoByMarkList.size() == 3); - - Assert.assertTrue( - shieldNoteInfoByOvkList.get(0).getValue() == shieldNote1.getValue() - zenTokenFee); - Assert.assertEquals(receiverMemo1.getBytes(), shieldNoteInfoByOvkList.get(0).getMemo()); - /*Assert.assertTrue( - shieldNoteInfoByOvkList.get(1).getValue() == shieldNote2.getValue() - zenTokenFee); - Assert.assertEquals(receiverMemo2.getBytes(), shieldNoteInfoByOvkList.get(1).getMemo());*/ - Assert.assertTrue( - shieldNoteInfoByOvkList.get(1).getValue() == shieldNote3.getValue() - zenTokenFee); - Assert.assertEquals(receiverMemo3.getBytes(), shieldNoteInfoByOvkList.get(1).getMemo()); - Assert.assertTrue(shieldNoteInfoByMarkList.get(0).getIsSpend()); - Assert.assertFalse(shieldNoteInfoByMarkList.get(1).getIsSpend()); - Assert.assertTrue(shieldNoteInfoByMarkList.get(2).getIsSpend()); - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - final Long assetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - HttpMethed - .transferAsset(httpnode, zenTokenOwnerAddress, foundationZenTokenAddress, assetIssueId, - assetBalance, zenTokenOwnerKey); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken002.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken002.java deleted file mode 100644 index 05fe004dd3e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken002.java +++ /dev/null @@ -1,283 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Note; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; -import stest.tron.wallet.common.client.utils.ShieldNoteInfo; - -@Slf4j -public class HttpTestZenToken002 { - - private String httpnode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(0); - private String httpSolidityNode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - - Optional sendShieldAddressInfo; - Optional receiverShieldAddressInfo; - String sendShieldAddress; - String receiverShieldAddress; - List shieldOutList = new ArrayList<>(); - String memo1; - String memo2; - ShieldNoteInfo sendNote; - ShieldNoteInfo receiverNote; - ShieldNoteInfo noteByOvk; - ShieldNoteInfo noteByIvk; - String assetIssueId; - - private Long sendTokenAmount = 7 * zenTokenFee; - private JSONObject responseContent; - private HttpResponse response; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - response = HttpMethed - .transferAsset(httpnode, foundationZenTokenAddress, zenTokenOwnerAddress, zenTokenId, - sendTokenAmount, foundationZenTokenKey); - org.junit.Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - - } - - @Test(enabled = true, description = "Public to shield transaction by http") - public void test01PublicToShieldTransaction() { - response = HttpMethed.getAccount(httpnode, foundationZenTokenAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - assetIssueId = responseContent.getString("asset_issued_ID"); - - final Long beforeAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsed = responseContent.getLong("freeNetUsed"); - - sendShieldAddressInfo = HttpMethed.generateShieldAddress(httpnode); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddress:" + sendShieldAddress); - memo1 = "Shield memo1 in " + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, sendShieldAddress, - "" + (sendTokenAmount - zenTokenFee), memo1); - - response = HttpMethed - .sendShieldCoin(httpnode, zenTokenOwnerAddress, sendTokenAmount, null, null, shieldOutList, - null, 0, zenTokenOwnerKey); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - Long afterAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterNetUsed = responseContent.getLong("freeNetUsed"); - - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == sendTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - - sendNote = HttpMethed.scanNoteByIvk(httpnode, sendShieldAddressInfo.get()).get(0); - Assert.assertTrue(sendNote.getValue() == sendTokenAmount - zenTokenFee); - Assert.assertEquals(memo1.getBytes(), sendNote.getMemo()); - - ShieldNoteInfo scanAndMarkNoteSendNote = HttpMethed - .scanAndMarkNoteByIvk(httpnode, sendShieldAddressInfo.get()) - .get(0); - Assert.assertFalse(scanAndMarkNoteSendNote.getIsSpend()); - } - - @Test(enabled = true, description = "Shield to shield transaction by http") - public void test02ShieldToShieldTransaction() { - receiverShieldAddressInfo = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress = receiverShieldAddressInfo.get().getAddress(); - - shieldOutList.clear(); - memo2 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress, - "" + (sendNote.getValue() - zenTokenFee), memo2); - - response = HttpMethed - .sendShieldCoin(httpnode, null, 0, sendShieldAddressInfo.get(), sendNote, shieldOutList, - null, 0, null); - org.junit.Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - HttpMethed.waitToProduceOneBlock(httpnode); - Long afterAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - - receiverNote = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo.get()).get(0); - - Assert.assertTrue(receiverNote.getValue() == sendNote.getValue() - zenTokenFee); - Assert.assertEquals(ByteArray.toHexString(memo2.getBytes()), - ByteArray.toHexString(receiverNote.getMemo())); - - Assert.assertTrue(HttpMethed.getSpendResult(httpnode, sendShieldAddressInfo.get(), sendNote)); - Assert.assertFalse( - HttpMethed.getSpendResult(httpnode, receiverShieldAddressInfo.get(), receiverNote)); - } - - @Test(enabled = true, description = "Scan note by ivk and scan not by ivk on FullNode by http") - public void test03ScanNoteByIvkAndOvk() { - //Scan sender note by ovk equals scan receiver note by ivk on FullNode - noteByOvk = HttpMethed.scanNoteByOvk(httpnode, sendShieldAddressInfo.get()).get(0); - noteByIvk = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo.get()).get(0); - Assert.assertEquals(noteByIvk.getValue(), noteByOvk.getValue()); - Assert.assertEquals(noteByIvk.getMemo(), noteByOvk.getMemo()); - Assert.assertEquals(noteByIvk.getR(), noteByOvk.getR()); - Assert.assertEquals(noteByIvk.getPaymentAddress(), noteByOvk.getPaymentAddress()); - } - - @Test(enabled = true, description = "Scan note by ivk and scan not by ivk on Solidity by http") - public void test04ScanNoteByIvkAndOvkFromSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - //Scan sender note by ovk equals scan receiver note by ivk on Solidity - noteByOvk = HttpMethed.scanNoteByOvkFromSolidity(httpSolidityNode, sendShieldAddressInfo.get()) - .get(0); - noteByIvk = HttpMethed - .scanNoteByIvkFromSolidity(httpSolidityNode, receiverShieldAddressInfo.get()).get(0); - Assert.assertEquals(noteByIvk.getValue(), noteByOvk.getValue()); - Assert.assertEquals(noteByIvk.getMemo(), noteByOvk.getMemo()); - Assert.assertEquals(noteByIvk.getR(), noteByOvk.getR()); - Assert.assertEquals(noteByIvk.getPaymentAddress(), noteByOvk.getPaymentAddress()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Query whether note is spend on solidity by http") - public void test05QueryNoteIsSpendOnSolidity() { - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - Assert.assertTrue(HttpMethed - .getSpendResultFromSolidity(httpnode, httpSolidityNode, sendShieldAddressInfo.get(), - sendNote)); - Assert.assertFalse(HttpMethed - .getSpendResultFromSolidity(httpnode, httpSolidityNode, receiverShieldAddressInfo.get(), - receiverNote)); - } - - @Test(enabled = true, description = "Query note and spend status on fullnode") - public void test06QueryNoteAndSpendStatusOnFullnode() { - ShieldNoteInfo scanAndMarkNoteSendNote = HttpMethed - .scanAndMarkNoteByIvk(httpnode, sendShieldAddressInfo.get()) - .get(0); - Assert.assertTrue(scanAndMarkNoteSendNote.isSpend); - Assert.assertEquals(scanAndMarkNoteSendNote.getValue(), sendNote.getValue()); - Assert.assertEquals(scanAndMarkNoteSendNote.getMemo(), sendNote.getMemo()); - Assert.assertEquals(scanAndMarkNoteSendNote.getR(), sendNote.getR()); - Assert.assertEquals(scanAndMarkNoteSendNote.getPaymentAddress(), sendNote.getPaymentAddress()); - - ShieldNoteInfo scanAndMarkNoteReceiverNote = HttpMethed - .scanAndMarkNoteByIvk(httpnode, receiverShieldAddressInfo.get()) - .get(0); - Assert.assertFalse(scanAndMarkNoteReceiverNote.getIsSpend()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getValue(), receiverNote.getValue()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getMemo(), receiverNote.getMemo()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getR(), receiverNote.getR()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getPaymentAddress(), - receiverNote.getPaymentAddress()); - } - - @Test(enabled = true, description = "Query note and spend status on solidity") - public void test07QueryNoteAndSpendStatusOnSolidity() { - ShieldNoteInfo scanAndMarkNoteSendNote = HttpMethed - .scanAndMarkNoteByIvkFromSolidity(httpnode, httpSolidityNode, sendShieldAddressInfo.get()) - .get(0); - Assert.assertTrue(scanAndMarkNoteSendNote.isSpend); - Assert.assertEquals(scanAndMarkNoteSendNote.getValue(), sendNote.getValue()); - Assert.assertEquals(scanAndMarkNoteSendNote.getMemo(), sendNote.getMemo()); - Assert.assertEquals(scanAndMarkNoteSendNote.getR(), sendNote.getR()); - Assert.assertEquals(scanAndMarkNoteSendNote.getPaymentAddress(), sendNote.getPaymentAddress()); - - ShieldNoteInfo scanAndMarkNoteReceiverNote = HttpMethed - .scanAndMarkNoteByIvkFromSolidity(httpnode, httpSolidityNode, - receiverShieldAddressInfo.get()) - .get(0); - Assert.assertFalse(scanAndMarkNoteReceiverNote.getIsSpend()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getValue(), receiverNote.getValue()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getMemo(), receiverNote.getMemo()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getR(), receiverNote.getR()); - Assert.assertEquals(scanAndMarkNoteReceiverNote.getPaymentAddress(), - receiverNote.getPaymentAddress()); - - } - - @Test(enabled = true, description = "Shield to public transaction by http") - public void test08ShieldToPublicTransaction() { - final Long beforeAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsed = responseContent.getLong("freeNetUsed"); - - shieldOutList.clear(); - response = HttpMethed - .sendShieldCoin(httpnode, null, 0, receiverShieldAddressInfo.get(), receiverNote, - shieldOutList, - zenTokenOwnerAddress, receiverNote.getValue() - zenTokenFee, null); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - Long afterAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterNetUsed = responseContent.getLong("freeNetUsed"); - - logger.info("beforeAssetBalance:" + beforeAssetBalance); - logger.info("afterAssetBalance:" + afterAssetBalance); - Assert.assertTrue( - afterAssetBalance - beforeAssetBalance == receiverNote.getValue() - zenTokenFee); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - - Assert.assertTrue( - HttpMethed.getSpendResult(httpnode, receiverShieldAddressInfo.get(), receiverNote)); - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - final Long assetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - HttpMethed - .transferAsset(httpnode, zenTokenOwnerAddress, foundationZenTokenAddress, assetIssueId, - assetBalance, zenTokenOwnerKey); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken003.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken003.java deleted file mode 100644 index 96442201f95..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken003.java +++ /dev/null @@ -1,314 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Note; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; -import stest.tron.wallet.common.client.utils.ShieldNoteInfo; - -@Slf4j -public class HttpTestZenToken003 { - - private String httpnode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(0); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - - Optional receiverShieldAddressInfo1; - Optional receiverShieldAddressInfo2; - Optional receiverShieldAddressInfo3; - Optional receiverShieldAddressInfo4; - Optional receiverShieldAddressInfo5; - String receiverShieldAddress1; - String receiverShieldAddress2; - String receiverShieldAddress3; - String receiverShieldAddress4; - String receiverShieldAddress5; - List shieldOutList = new ArrayList<>(); - String memo1; - String memo2; - String memo3; - String memo4; - String memo5; - ShieldNoteInfo receiverNote1; - ShieldNoteInfo receiverNote2; - ShieldNoteInfo receiverNote3; - ShieldNoteInfo receiverNote4; - ShieldNoteInfo receiverNote5; - String assetIssueId; - - private Long sendTokenAmount = 8 * zenTokenFee; - private JSONObject responseContent; - private HttpResponse response; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverPublicAddress = ecKey2.getAddress(); - String receiverPublicKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - - } - - @Test(enabled = true, description = "Public to two shield transaction by http") - public void test01PublicToTwoShieldTransaction() { - response = HttpMethed - .transferAsset(httpnode, foundationZenTokenAddress, zenTokenOwnerAddress, zenTokenId, - sendTokenAmount, foundationZenTokenKey); - HttpMethed.waitToProduceOneBlock(httpnode); - - receiverShieldAddressInfo1 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddressInfo2 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress1 = receiverShieldAddressInfo1.get().getAddress(); - receiverShieldAddress2 = receiverShieldAddressInfo2.get().getAddress(); - logger.info("receiverShieldAddress1:" + receiverShieldAddress1); - logger.info("receiverShieldAddress2:" + receiverShieldAddress2); - memo1 = "Shield memo1 in " + System.currentTimeMillis(); - memo2 = "Shield memo2 in " + System.currentTimeMillis(); - Long sendToShiledAddress1Amount = 1 * zenTokenFee; - Long sendToShiledAddress2Amount = - sendTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - - response = HttpMethed.getAccount(httpnode, foundationZenTokenAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - assetIssueId = responseContent.getString("asset_issued_ID"); - final Long beforeAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsed = responseContent.getLong("freeNetUsed"); - - response = HttpMethed - .sendShieldCoin(httpnode, zenTokenOwnerAddress, sendTokenAmount, null, null, shieldOutList, - null, 0, zenTokenOwnerKey); - org.junit.Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - HttpMethed.waitToProduceOneBlock(httpnode); - Long afterAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterNetUsed = responseContent.getLong("freeNetUsed"); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == sendTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - - receiverNote1 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo1.get()).get(0); - receiverNote2 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo2.get()).get(0); - Assert.assertTrue(receiverNote1.getValue() == sendToShiledAddress1Amount); - Assert.assertTrue(receiverNote2.getValue() == sendToShiledAddress2Amount); - Assert.assertEquals(memo1.getBytes(), receiverNote1.getMemo()); - Assert.assertEquals(memo2.getBytes(), receiverNote2.getMemo()); - } - - @Test(enabled = true, description = "Public to one public and one shield transaction by http") - public void test02ShieldToOneShieldAndOnePublicTransaction() { - response = HttpMethed - .transferAsset(httpnode, foundationZenTokenAddress, zenTokenOwnerAddress, zenTokenId, - sendTokenAmount, foundationZenTokenKey); - HttpMethed.waitToProduceOneBlock(httpnode); - - receiverShieldAddressInfo3 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress3 = receiverShieldAddressInfo3.get().getAddress(); - - final Long beforeAssetBalanceSendAddress = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsedSendAddress = responseContent.getLong("freeNetUsed"); - response = HttpMethed.getAccount(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long beforeBalanceSendAddress = responseContent.getLong("balance"); - - final Long beforeAssetBalanceReceiverAddress = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsedReceiverAddress = responseContent.getLong("freeNetUsed"); - - shieldOutList.clear(); - Long sendToPublicAddressAmount = 1 * zenTokenFee; - Long sendToShiledAddressAmount = sendTokenAmount - sendToPublicAddressAmount - zenTokenFee; - memo3 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress3, - "" + sendToShiledAddressAmount, memo3); - - PublicMethed.printAddress(receiverPublicKey); - response = HttpMethed - .sendShieldCoin(httpnode, zenTokenOwnerAddress, sendTokenAmount, null, null, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, zenTokenOwnerKey); - org.junit.Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - Long afterAssetBalanceSendAddress = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterNetUsedSendAddress = responseContent.getLong("freeNetUsed"); - response = HttpMethed.getAccount(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterBalanceSendAddress = responseContent.getLong("balance"); - - final Long afterAssetBalanceReceiverAddress = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long afterNetUsedReceiverAddress = responseContent.getLong("freeNetUsed"); - - Assert.assertTrue( - beforeAssetBalanceSendAddress - afterAssetBalanceSendAddress == sendTokenAmount); - Assert.assertTrue(beforeNetUsedSendAddress == afterNetUsedSendAddress); - Assert.assertTrue(beforeBalanceSendAddress == afterBalanceSendAddress); - - Assert.assertTrue( - afterAssetBalanceReceiverAddress - beforeAssetBalanceReceiverAddress - == sendToPublicAddressAmount); - Assert.assertTrue(beforeNetUsedReceiverAddress == afterNetUsedReceiverAddress); - - receiverNote3 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo3.get()).get(0); - - Assert.assertTrue(receiverNote3.getValue() == sendToShiledAddressAmount); - Assert.assertEquals(memo3.getBytes(), receiverNote3.getMemo()); - } - - @Test(enabled = true, description = "Public to one public and two shield transaction by http") - public void test03ShieldToOneShieldAndTwoPublicTransaction() { - response = HttpMethed - .transferAsset(httpnode, foundationZenTokenAddress, zenTokenOwnerAddress, zenTokenId, - sendTokenAmount, foundationZenTokenKey); - HttpMethed.waitToProduceOneBlock(httpnode); - - receiverShieldAddressInfo4 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress4 = receiverShieldAddressInfo4.get().getAddress(); - receiverShieldAddressInfo5 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress5 = receiverShieldAddressInfo5.get().getAddress(); - - final Long beforeAssetBalanceSendAddress = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsedSendAddress = responseContent.getLong("freeNetUsed"); - response = HttpMethed.getAccount(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long beforeBalanceSendAddress = responseContent.getLong("balance"); - - final Long beforeAssetBalanceReceiverAddress = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsedReceiverAddress = responseContent.getLong("freeNetUsed"); - - shieldOutList.clear(); - Long sendToPublicAddressAmount = 1 * zenTokenFee; - Long sendToShiledAddress1Amount = 2 * zenTokenFee; - Long sendToShiledAddress2Amount = - sendTokenAmount - sendToPublicAddressAmount - sendToShiledAddress1Amount - zenTokenFee; - memo4 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - memo5 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress4, - "" + sendToShiledAddress1Amount, memo4); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress5, - "" + sendToShiledAddress2Amount, memo5); - - PublicMethed.printAddress(receiverPublicKey); - response = HttpMethed - .sendShieldCoin(httpnode, zenTokenOwnerAddress, sendTokenAmount, null, null, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, zenTokenOwnerKey); - org.junit.Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - Long afterAssetBalanceSendAddress = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterNetUsedSendAddress = responseContent.getLong("freeNetUsed"); - response = HttpMethed.getAccount(httpnode, zenTokenOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - Long afterBalanceSendAddress = responseContent.getLong("balance"); - - final Long afterAssetBalanceReceiverAddress = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long afterNetUsedReceiverAddress = responseContent.getLong("freeNetUsed"); - - Assert.assertTrue( - beforeAssetBalanceSendAddress - afterAssetBalanceSendAddress == sendTokenAmount); - Assert.assertTrue(beforeNetUsedSendAddress == afterNetUsedSendAddress); - Assert.assertTrue(beforeBalanceSendAddress == afterBalanceSendAddress); - - Assert.assertTrue( - afterAssetBalanceReceiverAddress - beforeAssetBalanceReceiverAddress - == sendToPublicAddressAmount); - Assert.assertTrue(beforeNetUsedReceiverAddress == afterNetUsedReceiverAddress); - - receiverNote4 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo4.get()).get(0); - Assert.assertTrue(receiverNote4.getValue() == sendToShiledAddress1Amount); - Assert.assertEquals(memo4.getBytes(), receiverNote4.getMemo()); - - receiverNote5 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo5.get()).get(0); - Assert.assertTrue(receiverNote5.getValue() == sendToShiledAddress2Amount); - Assert.assertEquals(memo5.getBytes(), receiverNote5.getMemo()); - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - final Long assetBalance1 = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - HttpMethed - .transferAsset(httpnode, zenTokenOwnerAddress, foundationZenTokenAddress, assetIssueId, - assetBalance1, zenTokenOwnerKey); - - final Long assetBalance2 = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - HttpMethed - .transferAsset(httpnode, receiverPublicAddress, foundationZenTokenAddress, assetIssueId, - assetBalance2, receiverPublicKey); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken004.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken004.java deleted file mode 100644 index cbaf0fad380..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken004.java +++ /dev/null @@ -1,296 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Note; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; -import stest.tron.wallet.common.client.utils.ShieldNoteInfo; - -@Slf4j -public class HttpTestZenToken004 { - - private String httpnode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(0); - private String httpSolidityNode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - - Optional sendShieldAddressInfo; - Optional receiverShieldAddressInfo1; - Optional receiverShieldAddressInfo2; - Optional receiverShieldAddressInfo3; - Optional receiverShieldAddressInfo4; - Optional receiverShieldAddressInfo5; - String sendShieldAddress; - String receiverShieldAddress1; - String receiverShieldAddress2; - String receiverShieldAddress3; - String receiverShieldAddress4; - String receiverShieldAddress5; - List shieldOutList = new ArrayList<>(); - String memo1; - String memo2; - String memo3; - String memo4; - String memo5; - ShieldNoteInfo sendNote; - ShieldNoteInfo receiverNote1; - ShieldNoteInfo receiverNote2; - ShieldNoteInfo receiverNote3; - ShieldNoteInfo receiverNote4; - ShieldNoteInfo receiverNote5; - String assetIssueId; - - private Long sendTokenAmount = 8 * zenTokenFee; - private JSONObject responseContent; - private HttpResponse response; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] receiverPublicAddress = ecKey1.getAddress(); - String receiverPublicKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - } - - @Test(enabled = true, description = "Shield to two shield transaction by http") - public void test01ShieldToTwoShieldTransaction() { - sendShieldAddressInfo = HttpMethed.generateShieldAddress(httpnode); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddress:" + sendShieldAddress); - String memo = "Shield memo in " + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, sendShieldAddress, - "" + sendTokenAmount, memo); - response = HttpMethed - .sendShieldCoin(httpnode, foundationZenTokenAddress, sendTokenAmount + zenTokenFee, null, - null, - shieldOutList, - null, 0, foundationZenTokenKey); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - sendNote = HttpMethed.scanNoteByIvk(httpnode, sendShieldAddressInfo.get()).get(0); - - receiverShieldAddressInfo1 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddressInfo2 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress1 = receiverShieldAddressInfo1.get().getAddress(); - receiverShieldAddress2 = receiverShieldAddressInfo2.get().getAddress(); - logger.info("receiverShieldAddress1:" + receiverShieldAddress1); - logger.info("receiverShieldAddress2:" + receiverShieldAddress2); - memo1 = "Shield memo1 in " + System.currentTimeMillis(); - memo2 = "Shield memo2 in " + System.currentTimeMillis(); - Long sendToShiledAddress1Amount = 1 * zenTokenFee; - Long sendToShiledAddress2Amount = - sendTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - shieldOutList.clear(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - - response = HttpMethed - .sendShieldCoin(httpnode, null, 0, sendShieldAddressInfo.get(), sendNote, shieldOutList, - null, 0, null); - org.junit.Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - HttpMethed.waitToProduceOneBlock(httpnode); - - receiverNote1 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo1.get()).get(0); - receiverNote2 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo2.get()).get(0); - Assert.assertTrue(receiverNote1.getValue() == sendToShiledAddress1Amount); - Assert.assertTrue(receiverNote2.getValue() == sendToShiledAddress2Amount); - Assert.assertEquals(memo1.getBytes(), receiverNote1.getMemo()); - Assert.assertEquals(memo2.getBytes(), receiverNote2.getMemo()); - - Assert.assertTrue(HttpMethed.getSpendResult(httpnode, sendShieldAddressInfo.get(), sendNote)); - } - - @Test(enabled = true, description = "Shield to one public and one shield transaction by http") - public void test02ShieldToOnePublicAndOneShieldTransaction() { - sendShieldAddressInfo = HttpMethed.generateShieldAddress(httpnode); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddress:" + sendShieldAddress); - String memo = "Shield memo in " + System.currentTimeMillis(); - shieldOutList.clear(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, sendShieldAddress, - "" + sendTokenAmount, memo); - response = HttpMethed - .sendShieldCoin(httpnode, foundationZenTokenAddress, sendTokenAmount + zenTokenFee, null, - null, - shieldOutList, - null, 0, foundationZenTokenKey); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - sendNote = HttpMethed.scanNoteByIvk(httpnode, sendShieldAddressInfo.get()).get(0); - - receiverShieldAddressInfo3 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress3 = receiverShieldAddressInfo3.get().getAddress(); - - response = HttpMethed.getAccount(httpnode, foundationZenTokenAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - assetIssueId = responseContent.getString("asset_issued_ID"); - - final Long beforeAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsed = responseContent.getLong("freeNetUsed"); - - shieldOutList.clear(); - Long sendToPublicAddressAmount = 1 * zenTokenFee; - Long sendToShiledAddressAmount = sendTokenAmount - sendToPublicAddressAmount - zenTokenFee; - memo3 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress3, - "" + sendToShiledAddressAmount, memo3); - - PublicMethed.printAddress(receiverPublicKey); - response = HttpMethed - .sendShieldCoin(httpnode, null, 0, sendShieldAddressInfo.get(), sendNote, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, null); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - final Long afterAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long afterNetUsed = responseContent.getLong("freeNetUsed"); - - Assert.assertTrue(afterAssetBalance - beforeAssetBalance == sendToPublicAddressAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - - receiverNote3 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo3.get()).get(0); - Assert.assertTrue(receiverNote3.getValue() == sendToShiledAddressAmount); - Assert.assertEquals(memo3.getBytes(), receiverNote3.getMemo()); - - Assert.assertTrue(HttpMethed.getSpendResult(httpnode, sendShieldAddressInfo.get(), sendNote)); - - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - Assert.assertTrue(HttpMethed - .getSpendResultFromSolidity(httpnode, httpSolidityNode, sendShieldAddressInfo.get(), - sendNote)); - Assert.assertFalse(HttpMethed - .getSpendResultFromSolidity(httpnode, httpSolidityNode, receiverShieldAddressInfo3.get(), - receiverNote3)); - - Assert.assertTrue(HttpMethed - .scanAndMarkNoteByIvk(httpnode, sendShieldAddressInfo.get()) - .get(0).getIsSpend()); - Assert.assertFalse(HttpMethed - .scanAndMarkNoteByIvk(httpnode, receiverShieldAddressInfo3.get()) - .get(0).getIsSpend()); - } - - @Test(enabled = true, description = "Shield to one public and two shield transaction by http") - public void test03ShieldToOnePublicAndTwoShieldTransaction() { - sendShieldAddressInfo = HttpMethed.generateShieldAddress(httpnode); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddress:" + sendShieldAddress); - String memo = "Shield memo in " + System.currentTimeMillis(); - shieldOutList.clear(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, sendShieldAddress, - "" + sendTokenAmount, memo); - response = HttpMethed - .sendShieldCoin(httpnode, foundationZenTokenAddress, sendTokenAmount + zenTokenFee, null, - null, - shieldOutList, - null, 0, foundationZenTokenKey); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - sendNote = HttpMethed.scanNoteByIvk(httpnode, sendShieldAddressInfo.get()).get(0); - - receiverShieldAddressInfo4 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress4 = receiverShieldAddressInfo4.get().getAddress(); - receiverShieldAddressInfo5 = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress5 = receiverShieldAddressInfo5.get().getAddress(); - - final Long beforeAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long beforeNetUsed = responseContent.getLong("freeNetUsed"); - - shieldOutList.clear(); - Long sendToPublicAddressAmount = 1 * zenTokenFee; - Long sendToShiledAddress1Amount = 2 * zenTokenFee; - Long sendToShiledAddress2Amount = - sendTokenAmount - sendToPublicAddressAmount - sendToShiledAddress1Amount - zenTokenFee; - memo4 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - memo5 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress4, - "" + sendToShiledAddress1Amount, memo4); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress5, - "" + sendToShiledAddress2Amount, memo5); - - PublicMethed.printAddress(receiverPublicKey); - response = HttpMethed - .sendShieldCoin(httpnode, null, 0, sendShieldAddressInfo.get(), sendNote, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, null); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - final Long afterAssetBalance = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - response = HttpMethed.getAccountReource(httpnode, receiverPublicAddress); - responseContent = HttpMethed.parseResponseContent(response); - final Long afterNetUsed = responseContent.getLong("freeNetUsed"); - - Assert.assertTrue(afterAssetBalance - beforeAssetBalance == sendToPublicAddressAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - - receiverNote4 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo4.get()).get(0); - Assert.assertTrue(receiverNote4.getValue() == sendToShiledAddress1Amount); - Assert.assertEquals(memo4.getBytes(), receiverNote4.getMemo()); - - receiverNote5 = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo5.get()).get(0); - Assert.assertTrue(receiverNote5.getValue() == sendToShiledAddress2Amount); - Assert.assertEquals(memo5.getBytes(), receiverNote5.getMemo()); - - Assert.assertTrue(HttpMethed.getSpendResult(httpnode, sendShieldAddressInfo.get(), sendNote)); - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - final Long assetBalance = HttpMethed - .getAssetIssueValue(httpnode, receiverPublicAddress, assetIssueId); - HttpMethed - .transferAsset(httpnode, receiverPublicAddress, foundationZenTokenAddress, assetIssueId, - assetBalance, receiverPublicKey); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken005.java b/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken005.java deleted file mode 100644 index ce8b5e26395..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestZenToken005.java +++ /dev/null @@ -1,176 +0,0 @@ -package stest.tron.wallet.dailybuild.http; - -import com.alibaba.fastjson.JSONObject; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Note; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; -import stest.tron.wallet.common.client.utils.ShieldNoteInfo; - -@Slf4j -public class HttpTestZenToken005 { - - private String httpnode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(0); - private String httpSolidityNode = Configuration.getByPath("testng.conf") - .getStringList("httpnode.ip.list").get(2); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - - Optional sendShieldAddressInfo; - Optional receiverShieldAddressInfo; - String sendShieldAddress; - String receiverShieldAddress; - List shieldOutList = new ArrayList<>(); - String memo1; - String memo2; - ShieldNoteInfo sendNote; - ShieldNoteInfo receiveNote; - String assetIssueId; - - private Long sendTokenAmount = 7 * zenTokenFee; - private JSONObject responseContent; - private HttpResponse response; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - response = HttpMethed - .transferAsset(httpnode, foundationZenTokenAddress, zenTokenOwnerAddress, zenTokenId, - sendTokenAmount, foundationZenTokenKey); - org.junit.Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - sendShieldAddressInfo = HttpMethed.generateShieldAddress(httpnode); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddress:" + sendShieldAddress); - memo1 = "Shield memo1 in " + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, sendShieldAddress, - "" + (sendTokenAmount - zenTokenFee), memo1); - - response = HttpMethed - .sendShieldCoin(httpnode, zenTokenOwnerAddress, sendTokenAmount, null, null, shieldOutList, - null, 0, zenTokenOwnerKey); - org.junit.Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - shieldOutList.clear(); - HttpMethed.waitToProduceOneBlock(httpnode); - sendNote = HttpMethed.scanNoteByIvk(httpnode, sendShieldAddressInfo.get()).get(0); - } - - @Test(enabled = true, description = "Shield to shield transaction without ask by http") - public void test01ShieldToShieldWithoutAskTransaction() { - receiverShieldAddressInfo = HttpMethed.generateShieldAddress(httpnode); - receiverShieldAddress = receiverShieldAddressInfo.get().getAddress(); - - shieldOutList.clear(); - memo2 = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = HttpMethed.addShieldOutputList(httpnode, shieldOutList, receiverShieldAddress, - "" + (sendNote.getValue() - zenTokenFee), memo2); - - HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSolidityNode); - response = HttpMethed - .sendShieldCoinWithoutAsk(httpnode, httpSolidityNode, null, 0, sendShieldAddressInfo.get(), - sendNote, shieldOutList, null, 0, null); - org.junit.Assert.assertEquals(response.getStatusLine().getStatusCode(), 200); - logger.info("response:" + response); - responseContent = HttpMethed.parseResponseContent(response); - logger.info("responseContent:" + responseContent); - HttpMethed.printJsonContent(responseContent); - HttpMethed.waitToProduceOneBlock(httpnode); - - receiveNote = HttpMethed.scanNoteByIvk(httpnode, receiverShieldAddressInfo.get()).get(0); - - Assert.assertTrue(receiveNote.getValue() == sendNote.getValue() - zenTokenFee); - Assert.assertEquals(ByteArray.toHexString(memo2.getBytes()), - ByteArray.toHexString(receiveNote.getMemo())); - - Assert.assertTrue(HttpMethed.getSpendResult(httpnode, sendShieldAddressInfo.get(), sendNote)); - } - - @Test(enabled = true, description = "Get merkle tree voucher info by http") - public void test02GetMerkleTreeVoucherInfo() { - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed - .getMerkleTreeVoucherInfo(httpnode, sendNote.getTrxId(), sendNote.getIndex(), 1); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.toJSONString().contains("tree")); - Assert.assertTrue(responseContent.toJSONString().contains("rt")); - Assert.assertTrue(responseContent.toJSONString().contains("paths")); - - response = HttpMethed - .getMerkleTreeVoucherInfo(httpnode, receiveNote.getTrxId(), receiveNote.getIndex(), 1000); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.toJSONString().contains( - "synBlockNum is too large, cmBlockNum plus synBlockNum must be <= latestBlockNumber")); - } - - @Test(enabled = true, description = "Get merkle tree voucher info by http from solidity") - public void test03GetMerkleTreeVoucherInfoFromSolidity() { - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed - .getMerkleTreeVoucherInfoFromSolidity(httpSolidityNode, sendNote.getTrxId(), - sendNote.getIndex(), - 1); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.toJSONString().contains("tree")); - Assert.assertTrue(responseContent.toJSONString().contains("rt")); - Assert.assertTrue(responseContent.toJSONString().contains("paths")); - - response = HttpMethed - .getMerkleTreeVoucherInfoFromSolidity(httpSolidityNode, receiveNote.getTrxId(), - receiveNote.getIndex(), 1000); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - Assert.assertTrue(responseContent.toJSONString().contains( - "synBlockNum is too large, cmBlockNum plus synBlockNum must be <= latestBlockNumber")); - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - response = HttpMethed.getAccount(httpnode, foundationZenTokenAddress); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - assetIssueId = responseContent.getString("asset_issued_ID"); - final Long assetBalance = HttpMethed - .getAssetIssueValue(httpnode, zenTokenOwnerAddress, assetIssueId); - HttpMethed - .transferAsset(httpnode, zenTokenOwnerAddress, foundationZenTokenAddress, assetIssueId, - assetBalance, zenTokenOwnerKey); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction001.java b/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction001.java deleted file mode 100644 index 4813ef7c114..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction001.java +++ /dev/null @@ -1,514 +0,0 @@ -package stest.tron.wallet.dailybuild.internaltransaction; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j - -public class ContractInternalTransaction001 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] internalTxsAddress = ecKey1.getAddress(); - String testKeyForinternalTxsAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForinternalTxsAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - @Test(enabled = true, description = "Create->call.Two-level nesting") - public void testInternalTransaction001() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction001testInternalTransaction001.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - String initParmes = "\"" + Base58.encode58Check(contractAddress1) + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "test1(address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(7, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - String initParmes2 = "\"" + Base58.encode58Check(contractAddress1) + "\",\"1\""; - String txid1 = PublicMethed.triggerContract(contractAddress, - "test2(address,uint256)", initParmes2, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(10, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - for (int i = 0; i < transactionsCount1; i++) { - Assert.assertFalse(infoById1.get().getInternalTransactions(i).getRejected()); - } - } - - @Test(enabled = true, description = "There is one internalTransaction.Only call") - public void testInternalTransaction002() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction001testInternalTransaction002.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes2 = "\"" + Base58.encode58Check(contractAddress1) + "\",\"1\""; - String txid1 = PublicMethed.triggerContract(contractAddress, - "test2(address,uint256)", initParmes2, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(1, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - Assert.assertFalse(infoById1.get().getInternalTransactions(0).getRejected()); - String note = ByteArray - .toStr(infoById1.get().getInternalTransactions(0).getNote().toByteArray()); - Assert.assertEquals("call", note); - Assert.assertEquals(1, - infoById1.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue()); - - } - - @Test(enabled = true, description = "There is one internalTransaction.Only create") - public void testInternalTransaction003() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction001testInternalTransaction003.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid1 = PublicMethed.triggerContract(contractAddress, - "transfer()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(1, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - - Assert.assertFalse(infoById1.get().getInternalTransactions(0).getRejected()); - String note = ByteArray - .toStr(infoById1.get().getInternalTransactions(0).getNote().toByteArray()); - Assert.assertEquals("create", note); - Assert.assertEquals(10, - infoById1.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue()); - - } - - @Test(enabled = true, description = "Test suicide type in internalTransaction") - public void testInternalTransaction004() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction001testInternalTransaction004.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "B"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - String initParmes = "\"" + Base58.encode58Check(contractAddress) - + "\",\"" + Base58.encode58Check(contractAddress1) + "\""; - txid = PublicMethed.triggerContract(contractAddress1, - "kill(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("call", note); - Assert.assertEquals("suicide", note1); - Assert.assertTrue(0 == vaule1); - Assert.assertTrue(1000000L == vaule2); - - String txid1 = PublicMethed.triggerContract(contractAddress1, - "kill2()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(3, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - String note3 = ByteArray - .toStr(infoById1.get().getInternalTransactions(0).getNote().toByteArray()); - String note4 = ByteArray - .toStr(infoById1.get().getInternalTransactions(1).getNote().toByteArray()); - String note5 = ByteArray - .toStr(infoById1.get().getInternalTransactions(2).getNote().toByteArray()); - Assert.assertEquals("create", note3); - Assert.assertEquals("call", note4); - Assert.assertEquals("suicide", note5); - for (int i = 0; i < transactionsCount1; i++) { - Assert.assertFalse(infoById1.get().getInternalTransactions(i).getRejected()); - Assert.assertEquals(0, - infoById1.get().getInternalTransactions(i).getCallValueInfo(0).getCallValue()); - - } - } - - @Test(enabled = true, description = "Type is create call") - public void testInternalTransaction005() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction001testInternalTransaction005.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - - txid = PublicMethed.triggerContract(contractAddress, - "test1()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertTrue(infoById.get().getInternalTransactions(i).getRejected()); - } - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("create", note); - Assert.assertEquals("call", note1); - Assert.assertTrue(10 == vaule1); - Assert.assertTrue(0 == vaule2); - - String txid1 = PublicMethed.triggerContract(contractAddress, - "test2()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 1); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - - String note3 = ByteArray - .toStr(infoById1.get().getInternalTransactions(0).getNote().toByteArray()); - String note4 = ByteArray - .toStr(infoById1.get().getInternalTransactions(1).getNote().toByteArray()); - - Long vaule3 = infoById1.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule4 = infoById1.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertTrue(10 == vaule3); - Assert.assertTrue(0 == vaule4); - Assert.assertEquals("create", note3); - Assert.assertEquals("call", note4); - for (int i = 0; i < transactionsCount1; i++) { - Assert.assertTrue(infoById1.get().getInternalTransactions(i).getRejected()); - - - } - } - - @Test(enabled = true, description = "Type is create call call") - public void testInternalTransaction006() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction001testInternalTransaction006.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - - txid = PublicMethed.triggerContract(contractAddress, - "test1()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(3, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - - for (int i = 0; i < transactionsCount; i++) { - Assert.assertTrue(infoById.get().getInternalTransactions(i).getRejected()); - } - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - String note2 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Long vaule3 = infoById.get().getInternalTransactions(2).getCallValueInfo(0).getCallValue(); - - Assert.assertEquals("create", note); - Assert.assertEquals("call", note1); - Assert.assertEquals("call", note2); - Assert.assertTrue(10 == vaule1); - Assert.assertTrue(0 == vaule2); - Assert.assertTrue(0 == vaule3); - - String txid1 = PublicMethed.triggerContract(contractAddress, - "test2()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 1); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(3, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - - String note4 = ByteArray - .toStr(infoById1.get().getInternalTransactions(0).getNote().toByteArray()); - String note5 = ByteArray - .toStr(infoById1.get().getInternalTransactions(1).getNote().toByteArray()); - String note6 = ByteArray - .toStr(infoById1.get().getInternalTransactions(2).getNote().toByteArray()); - Long vaule4 = infoById1.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule5 = infoById1.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Long vaule6 = infoById1.get().getInternalTransactions(2).getCallValueInfo(0).getCallValue(); - - Assert.assertTrue(10 == vaule4); - Assert.assertTrue(0 == vaule5); - Assert.assertTrue(0 == vaule6); - Assert.assertEquals("create", note4); - Assert.assertEquals("call", note5); - Assert.assertEquals("call", note6); - - for (int i = 0; i < transactionsCount1; i++) { - Assert.assertTrue(infoById1.get().getInternalTransactions(i).getRejected()); - } - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - - /** - * constructor. - */ - - public void dupInternalTrsansactionHash( - List internalTransactionList) { - List hashList = new ArrayList<>(); - internalTransactionList.forEach( - internalTransaction -> hashList - .add(Hex.toHexString(internalTransaction.getHash().toByteArray()))); - List dupHash = hashList.stream() - .collect(Collectors.toMap(e -> e, e -> 1, (a, b) -> a + b)) - .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()) - .collect(Collectors.toList()); - Assert.assertEquals(dupHash.size(), 0); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction002.java b/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction002.java deleted file mode 100644 index e6f6f0926e8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction002.java +++ /dev/null @@ -1,595 +0,0 @@ -package stest.tron.wallet.dailybuild.internaltransaction; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j - -public class ContractInternalTransaction002 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] internalTxsAddress = ecKey1.getAddress(); - String testKeyForinternalTxsAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForinternalTxsAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - - @Test(enabled = true, description = "Type is create create call call") - public void test1InternalTransaction007() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction002test1InternalTransaction007.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) + "\""; - - String txid = ""; - - txid = PublicMethed.triggerContract(contractAddress, - "test1(address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertNotNull(infoById); - Assert.assertTrue(infoById.get().getResultValue() == 1); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(4, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertTrue(infoById.get().getInternalTransactions(i).getRejected()); - } - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - String note2 = ByteArray - .toStr(infoById.get().getInternalTransactions(2).getNote().toByteArray()); - String note3 = ByteArray - .toStr(infoById.get().getInternalTransactions(3).getNote().toByteArray()); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Long vaule3 = infoById.get().getInternalTransactions(2).getCallValueInfo(0).getCallValue(); - Long vaule4 = infoById.get().getInternalTransactions(3).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("create", note); - Assert.assertEquals("create", note1); - Assert.assertEquals("call", note2); - Assert.assertEquals("call", note3); - Assert.assertTrue(10 == vaule1); - Assert.assertTrue(0 == vaule2); - Assert.assertTrue(5 == vaule3); - Assert.assertTrue(0 == vaule4); - String initParmes1 = "\"" + Base58.encode58Check(contractAddress1) + "\",\"1\""; - String txid1 = PublicMethed.triggerContract(contractAddress, - "test2(address,uint256)", initParmes1, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(1, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - - String note5 = ByteArray - .toStr(infoById1.get().getInternalTransactions(0).getNote().toByteArray()); - Long vaule5 = infoById1.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Assert.assertTrue(1 == vaule5); - Assert.assertEquals("call", note5); - Assert.assertTrue(infoById1.get().getInternalTransactions(0).getRejected()); - - - } - - @Test(enabled = true, description = "Type is call call") - public void test2InternalTransaction008() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction002test2InternalTransaction008.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "B"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String initParmes = "\"" + Base58.encode58Check(contractAddress1) + "\",\"1\""; - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "testAssert(address,uint256)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - Assert.assertTrue(infoById.get().getInternalTransactions(0).getRejected()); - Assert.assertFalse(infoById.get().getInternalTransactions(1).getRejected()); - - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("call", note); - Assert.assertEquals("call", note1); - Assert.assertTrue(1 == vaule1); - Assert.assertTrue(1 == vaule2); - String contractName2 = "C"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - - byte[] contractAddress2 = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes1 = "\"" + Base58.encode58Check(contractAddress2) + "\",\"1\""; - String txid1 = PublicMethed.triggerContract(contractAddress, - "testRequire(address,uint256)", initParmes1, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - Assert.assertTrue(infoById1.get().getInternalTransactions(0).getRejected()); - Assert.assertFalse(infoById1.get().getInternalTransactions(1).getRejected()); - String note2 = ByteArray - .toStr(infoById1.get().getInternalTransactions(0).getNote().toByteArray()); - String note3 = ByteArray - .toStr(infoById1.get().getInternalTransactions(1).getNote().toByteArray()); - Long vaule3 = infoById1.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule4 = infoById1.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("call", note2); - Assert.assertEquals("call", note3); - Assert.assertTrue(1 == vaule3); - Assert.assertTrue(1 == vaule4); - - String txid2 = PublicMethed.triggerContract(contractAddress, - "testAssert1(address,uint256)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - int transactionsCount2 = infoById2.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount2); - dupInternalTrsansactionHash(infoById2.get().getInternalTransactionsList()); - Assert.assertFalse(infoById2.get().getInternalTransactions(0).getRejected()); - Assert.assertTrue(infoById2.get().getInternalTransactions(1).getRejected()); - - String note5 = ByteArray - .toStr(infoById2.get().getInternalTransactions(0).getNote().toByteArray()); - String note6 = ByteArray - .toStr(infoById2.get().getInternalTransactions(1).getNote().toByteArray()); - Long vaule5 = infoById2.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule6 = infoById2.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("call", note5); - Assert.assertEquals("call", note6); - Assert.assertTrue(1 == vaule5); - Assert.assertTrue(1 == vaule6); - - String txid3 = PublicMethed.triggerContract(contractAddress, - "testtRequire2(address,uint256)", initParmes1, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById3 = null; - infoById3 = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - Assert.assertTrue(infoById3.get().getResultValue() == 0); - int transactionsCount3 = infoById3.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount3); - dupInternalTrsansactionHash(infoById3.get().getInternalTransactionsList()); - - Assert.assertFalse(infoById3.get().getInternalTransactions(0).getRejected()); - Assert.assertTrue(infoById3.get().getInternalTransactions(1).getRejected()); - String note7 = ByteArray - .toStr(infoById3.get().getInternalTransactions(0).getNote().toByteArray()); - String note8 = ByteArray - .toStr(infoById3.get().getInternalTransactions(1).getNote().toByteArray()); - Long vaule7 = infoById3.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule8 = infoById3.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("call", note7); - Assert.assertEquals("call", note8); - Assert.assertTrue(1 == vaule7); - Assert.assertTrue(1 == vaule8); - - } - - @Test(enabled = true, description = "Test suicide type in internalTransaction after call") - public void test3InternalTransaction009() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction002test3InternalTransaction009.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "B"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "C"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - byte[] contractAddress2 = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName3 = "D"; - HashMap retMap3 = PublicMethed.getBycodeAbi(filePath, contractName3); - String code3 = retMap3.get("byteCode").toString(); - String abi3 = retMap3.get("abI").toString(); - byte[] contractAddress3 = PublicMethed - .deployContract(contractName3, abi3, code3, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String initParmes = "\"" + Base58.encode58Check(contractAddress2) - + "\",\"" + Base58.encode58Check(contractAddress3) + "\",\"" + Base58 - .encode58Check(contractAddress1) + "\""; - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "test1(address,address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(7, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - String note2 = ByteArray - .toStr(infoById.get().getInternalTransactions(6).getNote().toByteArray()); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Assert.assertEquals("create", note); - Assert.assertEquals("call", note1); - Assert.assertEquals("suicide", note2); - Assert.assertTrue(10 == vaule1); - Assert.assertTrue(5 == vaule2); - - String txid1 = ""; - txid1 = PublicMethed.triggerContract(contractAddress, - "test1(address,address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(6, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - - for (int i = 0; i < transactionsCount1; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - } - - @Test(enabled = false, description = "Test maxfeelimit can trigger create type max time") - public void test4InternalTransaction010() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction002test4InternalTransaction010.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "transfer()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(76, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - Assert.assertEquals("create", ByteArray - .toStr(infoById.get().getInternalTransactions(i).getNote().toByteArray())); - Assert.assertEquals(1, - infoById.get().getInternalTransactions(i).getCallValueInfo(0).getCallValue()); - } - PublicMethed.waitProduceNextBlock(blockingStubFull); - String txid1 = PublicMethed.triggerContract(contractAddress, - "transfer2()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 1); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - Assert.assertEquals(76, transactionsCount1); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - - for (int i = 0; i < transactionsCount1; i++) { - Assert.assertTrue(infoById1.get().getInternalTransactions(i).getRejected()); - Assert.assertEquals("create", ByteArray - .toStr(infoById1.get().getInternalTransactions(i).getNote().toByteArray())); - Assert.assertEquals(1, - infoById1.get().getInternalTransactions(i).getCallValueInfo(0).getCallValue()); - - } - - - } - - - @Test(enabled = true, description = "Type is call create->call->call.Three-level nesting") - public void test5InternalTransaction012() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction002test5InternalTransaction012.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "B"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "E"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap1.get("byteCode").toString(); - String abi2 = retMap1.get("abI").toString(); - byte[] contractAddress2 = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) - + "\",\"" + Base58.encode58Check(contractAddress2) + "\""; - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "test1(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(4, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - String note2 = ByteArray - .toStr(infoById.get().getInternalTransactions(2).getNote().toByteArray()); - String note3 = ByteArray - .toStr(infoById.get().getInternalTransactions(3).getNote().toByteArray()); - Assert.assertEquals("call", note); - Assert.assertEquals("create", note1); - Assert.assertEquals("call", note2); - Assert.assertEquals("call", note3); - - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Long vaule3 = infoById.get().getInternalTransactions(2).getCallValueInfo(0).getCallValue(); - Long vaule4 = infoById.get().getInternalTransactions(3).getCallValueInfo(0).getCallValue(); - Assert.assertTrue(1 == vaule1); - Assert.assertTrue(1000 == vaule2); - Assert.assertTrue(0 == vaule3); - Assert.assertTrue(1 == vaule4); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - - /** - * constructor. - */ - - public void dupInternalTrsansactionHash( - List internalTransactionList) { - List hashList = new ArrayList<>(); - internalTransactionList.forEach( - internalTransaction -> hashList - .add(Hex.toHexString(internalTransaction.getHash().toByteArray()))); - List dupHash = hashList.stream() - .collect(Collectors.toMap(e -> e, e -> 1, (a, b) -> a + b)) - .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()) - .collect(Collectors.toList()); - Assert.assertEquals(dupHash.size(), 0); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction003.java b/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction003.java deleted file mode 100644 index 7cbdd1e786d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/internaltransaction/ContractInternalTransaction003.java +++ /dev/null @@ -1,582 +0,0 @@ -package stest.tron.wallet.dailybuild.internaltransaction; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j - -public class ContractInternalTransaction003 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] internalTxsAddress = ecKey1.getAddress(); - String testKeyForinternalTxsAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForinternalTxsAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - - @Test(enabled = true, description = "Three-level nesting.Type is Create call->call->create") - public void testInternalTransaction013() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction003testInternalTransaction013.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "D"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) + "\""; - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "test1(address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(4, transactionsCount); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - String note2 = ByteArray - .toStr(infoById.get().getInternalTransactions(2).getNote().toByteArray()); - String note3 = ByteArray - .toStr(infoById.get().getInternalTransactions(3).getNote().toByteArray()); - Assert.assertEquals("create", note); - Assert.assertEquals("call", note1); - Assert.assertEquals("call", note2); - Assert.assertEquals("create", note3); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Long vaule3 = infoById.get().getInternalTransactions(2).getCallValueInfo(0).getCallValue(); - Long vaule4 = infoById.get().getInternalTransactions(3).getCallValueInfo(0).getCallValue(); - Assert.assertTrue(10 == vaule1); - Assert.assertTrue(0 == vaule2); - Assert.assertTrue(2 == vaule3); - Assert.assertTrue(5 == vaule4); - - - } - - - @Test(enabled = true, description = "Test delegatecall and callcode.") - public void testInternalTransaction014() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction003testInternalTransaction014.sol"; - String contractName = "callerContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "calledContract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "c"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - byte[] contractAddress2 = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) - + "\",\"" + Base58.encode58Check(contractAddress2) + "\""; - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "sendToB(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - Assert.assertEquals("call", ByteArray - .toStr(infoById.get().getInternalTransactions(i).getNote().toByteArray())); - } - Assert.assertEquals(ByteArray - .toHexString(infoById.get().getInternalTransactions(0).getCallerAddress() - .toByteArray()), - ByteArray.toHexString( - infoById.get().getInternalTransactions(0).getTransferToAddress().toByteArray())); - - Assert.assertEquals(ByteArray - .toHexString(contractAddress2), - ByteArray.toHexString( - infoById.get().getInternalTransactions(1).getTransferToAddress().toByteArray())); - String txid2 = ""; - txid2 = PublicMethed.triggerContract(contractAddress, - "sendToB2(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - int transactionsCount2 = infoById2.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount2); - for (int i = 0; i < transactionsCount2; i++) { - Assert.assertFalse(infoById2.get().getInternalTransactions(i).getRejected()); - Assert.assertEquals("call", ByteArray - .toStr(infoById2.get().getInternalTransactions(i).getNote().toByteArray())); - } - Assert.assertEquals(ByteArray - .toHexString(contractAddress), - ByteArray.toHexString( - infoById2.get().getInternalTransactions(0).getCallerAddress().toByteArray())); - Assert.assertEquals(ByteArray - .toHexString(contractAddress1), - ByteArray.toHexString( - infoById2.get().getInternalTransactions(0).getTransferToAddress().toByteArray())); - Assert.assertEquals(ByteArray - .toHexString(contractAddress1), - ByteArray.toHexString( - infoById2.get().getInternalTransactions(1).getCallerAddress().toByteArray())); - Assert.assertEquals(ByteArray - .toHexString(contractAddress2), - ByteArray.toHexString( - infoById2.get().getInternalTransactions(1).getTransferToAddress().toByteArray())); - - String txid3 = ""; - txid3 = PublicMethed.triggerContract(contractAddress, - "sendToB3(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById3 = null; - infoById3 = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - Assert.assertTrue(infoById3.get().getResultValue() == 0); - int transactionsCount3 = infoById3.get().getInternalTransactionsCount(); - Assert.assertEquals(2, transactionsCount3); - for (int i = 0; i < transactionsCount3; i++) { - Assert.assertFalse(infoById3.get().getInternalTransactions(i).getRejected()); - Assert.assertEquals("call", ByteArray - .toStr(infoById3.get().getInternalTransactions(i).getNote().toByteArray())); - } - Assert.assertEquals(ByteArray - .toHexString(infoById3.get().getInternalTransactions(0).getCallerAddress() - .toByteArray()), - ByteArray.toHexString( - infoById3.get().getInternalTransactions(0).getTransferToAddress().toByteArray())); - Assert.assertEquals(ByteArray - .toHexString(contractAddress2), - ByteArray.toHexString( - infoById3.get().getInternalTransactions(1).getTransferToAddress().toByteArray())); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - dupInternalTrsansactionHash(infoById2.get().getInternalTransactionsList()); - dupInternalTrsansactionHash(infoById3.get().getInternalTransactionsList()); - - } - - @Test(enabled = true, description = "Three-level nesting.Type " - + "is create call->call->create call->suicide") - public void testInternalTransaction015() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction003testInternalTransaction015.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "D"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "E"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - byte[] contractAddress2 = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) - + "\",\"" + Base58.encode58Check(contractAddress2) + "\""; - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "test1(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(6, transactionsCount); - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - - - } - - - @Test(enabled = false, description = "After create 80 times,then suicide") - public void testInternalTransaction016() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction003testInternalTransaction016.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "transfer()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(69, transactionsCount); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - Assert.assertEquals("suicide", ByteArray - .toStr(infoById.get().getInternalTransactions(68).getNote().toByteArray())); - Assert.assertEquals("call", ByteArray - .toStr(infoById.get().getInternalTransactions(67).getNote().toByteArray())); - Assert.assertEquals(0, - infoById.get().getInternalTransactions(67).getCallValueInfo(0).getCallValue()); - Assert.assertEquals(1, - infoById.get().getInternalTransactions(68).getCallValueInfo(0).getCallValue()); - for (int i = 0; i < transactionsCount - 2; i++) { - Assert.assertEquals("create", ByteArray - .toStr(infoById.get().getInternalTransactions(i).getNote().toByteArray())); - Assert.assertEquals(1, - infoById.get().getInternalTransactions(i).getCallValueInfo(0).getCallValue()); - } - String txid1 = ""; - txid1 = PublicMethed.triggerContract(contractAddress, - "transfer2()", "#", false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - int transactionsCount1 = infoById1.get().getInternalTransactionsCount(); - - Assert.assertEquals(68, transactionsCount1); - for (int i = 0; i < transactionsCount1; i++) { - Assert.assertTrue(infoById1.get().getInternalTransactions(i).getRejected()); - Assert.assertEquals("create", ByteArray - .toStr(infoById1.get().getInternalTransactions(i).getNote().toByteArray())); - - } - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - dupInternalTrsansactionHash(infoById1.get().getInternalTransactionsList()); - - } - - @Test(enabled = false, description = "After create 88 times,then suicide") - public void testInternalTransaction017() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction003testInternalTransaction017.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes = "\"" + Base58.encode58Check(contractAddress) + "\""; - - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "transfer(address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(77, transactionsCount); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - Assert.assertEquals("suicide", ByteArray - .toStr(infoById.get().getInternalTransactions(76).getNote().toByteArray())); - Assert.assertEquals(1000000 - 76, - infoById.get().getInternalTransactions(76).getCallValueInfo(0).getCallValue()); - for (int i = 0; i < transactionsCount - 1; i++) { - Assert.assertEquals("create", ByteArray - .toStr(infoById.get().getInternalTransactions(i).getNote().toByteArray())); - Assert.assertEquals(1, - infoById.get().getInternalTransactions(i).getCallValueInfo(0).getCallValue()); - } - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - } - - @Test(enabled = true, description = "Test maxfeelimit can trigger call create call max time") - public void testInternalTransaction018() { - Assert.assertTrue(PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/" - + "contractInternalTransaction003testInternalTransaction018.sol"; - String contractName = "A"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName1 = "B"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "E"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - byte[] contractAddress2 = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed - .sendcoin(internalTxsAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) - + "\",\"" + Base58.encode58Check(contractAddress2) + "\""; - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "test1(address,address)", initParmes, false, - 100000, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("InfoById:" + infoById); - Assert.assertTrue(infoById.get().getResultValue() == 0); - int transactionsCount = infoById.get().getInternalTransactionsCount(); - Assert.assertEquals(184, transactionsCount); - for (int i = 0; i < transactionsCount; i++) { - Assert.assertFalse(infoById.get().getInternalTransactions(i).getRejected()); - } - dupInternalTrsansactionHash(infoById.get().getInternalTransactionsList()); - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - String note1 = ByteArray - .toStr(infoById.get().getInternalTransactions(1).getNote().toByteArray()); - String note2 = ByteArray - .toStr(infoById.get().getInternalTransactions(2).getNote().toByteArray()); - String note3 = ByteArray - .toStr(infoById.get().getInternalTransactions(3).getNote().toByteArray()); - Long vaule1 = infoById.get().getInternalTransactions(0).getCallValueInfo(0).getCallValue(); - Long vaule2 = infoById.get().getInternalTransactions(1).getCallValueInfo(0).getCallValue(); - Long vaule3 = infoById.get().getInternalTransactions(2).getCallValueInfo(0).getCallValue(); - Long vaule4 = infoById.get().getInternalTransactions(3).getCallValueInfo(0).getCallValue(); - - Assert.assertEquals("call", note); - Assert.assertEquals("create", note1); - Assert.assertEquals("call", note2); - Assert.assertEquals("call", note3); - Assert.assertTrue(1 == vaule1); - Assert.assertTrue(100 == vaule2); - Assert.assertTrue(0 == vaule3); - Assert.assertTrue(1 == vaule4); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - - /** - * constructor. - */ - - public void dupInternalTrsansactionHash( - List internalTransactionList) { - List hashList = new ArrayList<>(); - internalTransactionList.forEach( - internalTransaction -> hashList - .add(Hex.toHexString(internalTransaction.getHash().toByteArray()))); - List dupHash = hashList.stream() - .collect(Collectors.toMap(e -> e, e -> 1, (a, b) -> a + b)) - .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()) - .collect(Collectors.toList()); - Assert.assertEquals(dupHash.size(), 0); - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage001.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage001.java deleted file mode 100644 index 3a87abf7eff..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage001.java +++ /dev/null @@ -1,349 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractLinkage001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] linkage001Address = ecKey1.getAddress(); - String linkage001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(linkage001Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - } - - @Test(enabled = true, description = "Deploy contract with valid or invalid value") - public void deployContentValue() { - Assert.assertTrue(PublicMethed.sendcoin(linkage001Address, 20000000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull); - info = PublicMethed.queryAccount(linkage001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeNetLimit = resourceInfo.getNetLimit(); - Long beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeEnergyLimit = resourceInfo.getEnergyLimit(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyLimit:" + beforeEnergyLimit); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeFreeNetLimit:" + beforeFreeNetLimit); - logger.info("beforeNetLimit:" + beforeNetLimit); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - //Value is equal balance,this will be failed.Only use FreeNet,Other not change. - String filePath = "./src/test/resources/soliditycode/contractLinkage001.sol"; - String contractName = "divideIHaveArgsReturnStorage"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String payableCode = retMap.get("byteCode").toString(); - String payableAbi = retMap.get("abI").toString(); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account accountGet = PublicMethed.queryAccount(linkage001Key, blockingStubFull); - Long accountBalance = accountGet.getBalance(); - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, payableAbi, - payableCode, "", maxFeeLimit, accountBalance, 100, null, - linkage001Key, linkage001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - Long fee = infoById.get().getFee(); - Long energyFee = infoById.get().getReceipt().getEnergyFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal:" + energyUsageTotal); - logger.info("fee:" + fee); - logger.info("energyFee:" + energyFee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - - Account infoafter = PublicMethed.queryAccount(linkage001Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyLimit = resourceInfoafter.getEnergyLimit(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterFreeNetLimit = resourceInfoafter.getFreeNetLimit(); - Long afterNetLimit = resourceInfoafter.getNetLimit(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyLimit:" + afterEnergyLimit); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterFreeNetLimit:" + afterFreeNetLimit); - logger.info("afterNetLimit:" + afterNetLimit); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertTrue(fee == 0); - Assert.assertTrue(afterNetUsed == 0); - Assert.assertTrue(afterEnergyUsed == 0); - Assert.assertTrue(afterFreeNetUsed > 0); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(linkage001Address, 50000000L, - 0, 1, linkage001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - maxFeeLimit = maxFeeLimit - 50000000L; - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull); - Account info1 = PublicMethed.queryAccount(linkage001Address, blockingStubFull); - Long beforeBalance1 = info1.getBalance(); - Long beforeEnergyLimit1 = resourceInfo1.getEnergyLimit(); - Long beforeEnergyUsed1 = resourceInfo1.getEnergyUsed(); - Long beforeFreeNetLimit1 = resourceInfo1.getFreeNetLimit(); - Long beforeNetLimit1 = resourceInfo1.getNetLimit(); - Long beforeNetUsed1 = resourceInfo1.getNetUsed(); - Long beforeFreeNetUsed1 = resourceInfo1.getFreeNetUsed(); - logger.info("beforeBalance1:" + beforeBalance1); - logger.info("beforeEnergyLimit1:" + beforeEnergyLimit1); - logger.info("beforeEnergyUsed1:" + beforeEnergyUsed1); - logger.info("beforeFreeNetLimit1:" + beforeFreeNetLimit1); - logger.info("beforeNetLimit1:" + beforeNetLimit1); - logger.info("beforeNetUsed1:" + beforeNetUsed1); - logger.info("beforeFreeNetUsed1:" + beforeFreeNetUsed1); - - //Value is 1,use BalanceGetEnergy,use FreeNet,fee==0. - txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, payableAbi, payableCode, - "", maxFeeLimit, 1L, 100, null, linkage001Key, - linkage001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - Long fee1 = infoById1.get().getFee(); - Long energyFee1 = infoById1.get().getReceipt().getEnergyFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - logger.info("fee1:" + fee1); - logger.info("energyFee1:" + energyFee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - - Account infoafter1 = PublicMethed.queryAccount(linkage001Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull1); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyLimit1 = resourceInfoafter1.getEnergyLimit(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterFreeNetLimit1 = resourceInfoafter1.getFreeNetLimit(); - Long afterNetLimit1 = resourceInfoafter1.getNetLimit(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyLimit1:" + afterEnergyLimit1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterFreeNetLimit1:" + afterFreeNetLimit1); - logger.info("afterNetLimit1:" + afterNetLimit1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - - Assert.assertTrue(beforeBalance1 - fee1 - 1L == afterBalance1); - byte[] contractAddress = infoById1.get().getContractAddress().toByteArray(); - Account account = PublicMethed.queryAccount(contractAddress, blockingStubFull); - Assert.assertTrue(account.getBalance() == 1L); - Assert.assertTrue(afterNetUsed1 == 0); - Assert.assertTrue(afterEnergyUsed1 > 0); - Assert.assertTrue(afterFreeNetUsed1 > 0); - - //Value is account all balance plus 1. balance is not sufficient,Nothing changde. - AccountResourceMessage resourceInfo2 = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull); - Account info2 = PublicMethed.queryAccount(linkage001Address, blockingStubFull); - Long beforeBalance2 = info2.getBalance(); - Long beforeEnergyLimit2 = resourceInfo2.getEnergyLimit(); - Long beforeEnergyUsed2 = resourceInfo2.getEnergyUsed(); - Long beforeFreeNetLimit2 = resourceInfo2.getFreeNetLimit(); - Long beforeNetLimit2 = resourceInfo2.getNetLimit(); - Long beforeNetUsed2 = resourceInfo2.getNetUsed(); - Long beforeFreeNetUsed2 = resourceInfo2.getFreeNetUsed(); - logger.info("beforeBalance2:" + beforeBalance2); - logger.info("beforeEnergyLimit2:" + beforeEnergyLimit2); - logger.info("beforeEnergyUsed2:" + beforeEnergyUsed2); - logger.info("beforeFreeNetLimit2:" + beforeFreeNetLimit2); - logger.info("beforeNetLimit2:" + beforeNetLimit2); - logger.info("beforeNetUsed2:" + beforeNetUsed2); - logger.info("beforeFreeNetUsed2:" + beforeFreeNetUsed2); - - account = PublicMethed.queryAccount(linkage001Key, blockingStubFull); - Long valueBalance = account.getBalance(); - contractAddress = PublicMethed.deployContract(contractName, payableAbi, payableCode, "", - maxFeeLimit, valueBalance + 1, 100, null, linkage001Key, - linkage001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(contractAddress == null); - Account infoafter2 = PublicMethed.queryAccount(linkage001Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull1); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyLimit2 = resourceInfoafter2.getEnergyLimit(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterFreeNetLimit2 = resourceInfoafter2.getFreeNetLimit(); - Long afterNetLimit2 = resourceInfoafter2.getNetLimit(); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - logger.info("afterBalance2:" + afterBalance2); - logger.info("afterEnergyLimit2:" + afterEnergyLimit2); - logger.info("afterEnergyUsed2:" + afterEnergyUsed2); - logger.info("afterFreeNetLimit2:" + afterFreeNetLimit2); - logger.info("afterNetLimit2:" + afterNetLimit2); - logger.info("afterNetUsed2:" + afterNetUsed2); - logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2); - Assert.assertTrue(afterNetUsed2 == 0); - Assert.assertTrue(afterEnergyUsed2 > 0); - Assert.assertTrue(afterFreeNetUsed2 > 0); - Assert.assertEquals(beforeBalance2, afterBalance2); - - //Value is account all balance.use freezeBalanceGetEnergy ,freezeBalanceGetNet .Balance ==0 - Assert.assertTrue(PublicMethed.freezeBalance(linkage001Address, 5000000L, - 0, linkage001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfo3 = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull); - Account info3 = PublicMethed.queryAccount(linkage001Address, blockingStubFull); - Long beforeBalance3 = info3.getBalance(); - Long beforeEnergyLimit3 = resourceInfo3.getEnergyLimit(); - Long beforeEnergyUsed3 = resourceInfo3.getEnergyUsed(); - Long beforeFreeNetLimit3 = resourceInfo3.getFreeNetLimit(); - Long beforeNetLimit3 = resourceInfo3.getNetLimit(); - Long beforeNetUsed3 = resourceInfo3.getNetUsed(); - Long beforeFreeNetUsed3 = resourceInfo3.getFreeNetUsed(); - logger.info("beforeBalance3:" + beforeBalance3); - logger.info("beforeEnergyLimit3:" + beforeEnergyLimit3); - logger.info("beforeEnergyUsed3:" + beforeEnergyUsed3); - logger.info("beforeFreeNetLimit3:" + beforeFreeNetLimit3); - logger.info("beforeNetLimit3:" + beforeNetLimit3); - logger.info("beforeNetUsed3:" + beforeNetUsed3); - logger.info("beforeFreeNetUsed3:" + beforeFreeNetUsed3); - account = PublicMethed.queryAccount(linkage001Key, blockingStubFull); - valueBalance = account.getBalance(); - txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, payableAbi, payableCode, - "", maxFeeLimit, valueBalance, 100, null, linkage001Key, - linkage001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - fee = infoById.get().getFee(); - Assert.assertTrue(infoById.get().getResultValue() == 0); - contractAddress = infoById.get().getContractAddress().toByteArray(); - Account infoafter3 = PublicMethed.queryAccount(linkage001Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(linkage001Address, - blockingStubFull1); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyLimit3 = resourceInfoafter3.getEnergyLimit(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterFreeNetLimit3 = resourceInfoafter3.getFreeNetLimit(); - Long afterNetLimit3 = resourceInfoafter3.getNetLimit(); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - logger.info("afterBalance3:" + afterBalance3); - logger.info("afterEnergyLimit3:" + afterEnergyLimit3); - logger.info("afterEnergyUsed3:" + afterEnergyUsed3); - logger.info("afterFreeNetLimit3:" + afterFreeNetLimit3); - logger.info("afterNetLimit3:" + afterNetLimit3); - logger.info("afterNetUsed3:" + afterNetUsed3); - logger.info("afterFreeNetUsed3:" + afterFreeNetUsed3); - - Assert.assertTrue(afterNetUsed3 > 0); - Assert.assertTrue(afterEnergyUsed3 > 0); - Assert.assertTrue(afterFreeNetUsed3 > 0); - Assert.assertTrue(beforeBalance2 - fee == afterBalance2); - Assert.assertTrue(afterBalance3 == 0); - Assert.assertTrue(PublicMethed.queryAccount(contractAddress, blockingStubFull) - .getBalance() == valueBalance); - PublicMethed - .unFreezeBalance(linkage001Address, linkage001Key, 1, - linkage001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage005.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage005.java deleted file mode 100644 index edb0805e426..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage005.java +++ /dev/null @@ -1,349 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractLinkage005 { - - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - String contractName; - String code; - String abi; - Long zeroForCycleCost; - Long firstForCycleCost; - Long secondForCycleCost; - Long thirdForCycleCost; - Long forthForCycleCost; - Long fifthForCycleCost; - Long zeroForCycleTimes = 498L; - Long firstForCycleTimes = 500L; - Long secondForCycleTimes = 502L; - Long thirdForCycleTimes = 504L; - Long forthForCycleTimes = 506L; - Long fifthForCycleTimes = 508L; - byte[] contractAddress; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] linkage005Address = ecKey1.getAddress(); - String linkage005Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(linkage005Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true, description = "Every same trigger use same energy and net") - public void testEnergyCostDetail() { - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Assert.assertTrue(PublicMethed.sendcoin(linkage005Address, 5000000000000L, fromAddress, - testKey003, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalance(linkage005Address, 250000000000L, - 0, linkage005Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(linkage005Address, 250000000000L, - 0, 1, linkage005Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(linkage005Address, - blockingStubFull); - Account info; - info = PublicMethed.queryAccount(linkage005Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyLimit = resourceInfo.getEnergyLimit(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - Long beforeNetLimit = resourceInfo.getNetLimit(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyLimit:" + beforeEnergyLimit); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeFreeNetLimit:" + beforeFreeNetLimit); - logger.info("beforeNetLimit:" + beforeNetLimit); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String filePath = "./src/test/resources/soliditycode/contractLinkage005.sol"; - String contractName = "timeoutTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit, 0L, 100, null, linkage005Key, - linkage005Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Account infoafter = PublicMethed.queryAccount(linkage005Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(linkage005Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyLimit = resourceInfoafter.getEnergyLimit(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterFreeNetLimit = resourceInfoafter.getFreeNetLimit(); - Long afterNetLimit = resourceInfoafter.getNetLimit(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyLimit:" + afterEnergyLimit); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterFreeNetLimit:" + afterFreeNetLimit); - logger.info("afterNetLimit:" + afterNetLimit); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("---------------:"); - long fee = infoById.get().getFee(); - - Assert.assertTrue(beforeBalance - fee == afterBalance); - //Assert.assertTrue(afterEnergyUsed > 0); - //Assert.assertTrue(afterFreeNetUsed > 0); - firstForCycleTimes = 1000L; - secondForCycleTimes = 1002L; - thirdForCycleTimes = 1004L; - - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(linkage005Address, - blockingStubFull); - Account info1 = PublicMethed.queryAccount(linkage005Address, blockingStubFull); - Long beforeBalance1 = info1.getBalance(); - Long beforeEnergyLimit1 = resourceInfo1.getEnergyLimit(); - Long beforeEnergyUsed1 = resourceInfo1.getEnergyUsed(); - Long beforeFreeNetLimit1 = resourceInfo1.getFreeNetLimit(); - Long beforeNetLimit1 = resourceInfo1.getNetLimit(); - Long beforeNetUsed1 = resourceInfo1.getNetUsed(); - Long beforeFreeNetUsed1 = resourceInfo1.getFreeNetUsed(); - logger.info("beforeBalance1:" + beforeBalance1); - logger.info("beforeEnergyLimit1:" + beforeEnergyLimit1); - logger.info("beforeEnergyUsed1:" + beforeEnergyUsed1); - logger.info("beforeFreeNetLimit1:" + beforeFreeNetLimit1); - logger.info("beforeNetLimit1:" + beforeNetLimit1); - logger.info("beforeNetUsed1:" + beforeNetUsed1); - logger.info("beforeFreeNetUsed1:" + beforeFreeNetUsed1); - byte[] contractAddress = infoById.get().getContractAddress().toByteArray(); - txid = PublicMethed.triggerContract(contractAddress, - "testUseCpu(uint256)", firstForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Account infoafter1 = PublicMethed.queryAccount(linkage005Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(linkage005Address, - blockingStubFull1); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyLimit1 = resourceInfoafter1.getEnergyLimit(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterFreeNetLimit1 = resourceInfoafter1.getFreeNetLimit(); - Long afterNetLimit1 = resourceInfoafter1.getNetLimit(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyLimit1:" + afterEnergyLimit1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterFreeNetLimit1:" + afterFreeNetLimit1); - logger.info("afterNetLimit1:" + afterNetLimit1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - logger.info("---------------:"); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - fee = infoById.get().getFee(); - firstForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - Assert.assertTrue((beforeBalance1 - fee) == afterBalance1); - Assert.assertTrue(afterEnergyUsed1 > beforeEnergyUsed1); - Assert.assertTrue(afterNetUsed1 > beforeNetUsed1); - //use EnergyUsed and NetUsed.balance not change - - String txid6 = PublicMethed.triggerContract(contractAddress, - "testUseCpu(uint256)", secondForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - final String txid7 = PublicMethed.triggerContract(contractAddress, - "testUseCpu(uint256)", thirdForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid6, blockingStubFull); - secondForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - infoById = PublicMethed.getTransactionInfoById(txid7, blockingStubFull); - thirdForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - Assert.assertTrue(thirdForCycleCost - secondForCycleCost - == secondForCycleCost - firstForCycleCost); - - zeroForCycleTimes = 498L; - firstForCycleTimes = 500L; - secondForCycleTimes = 502L; - thirdForCycleTimes = 504L; - forthForCycleTimes = 506L; - fifthForCycleTimes = 508L; - AccountResourceMessage resourceInfo4 = PublicMethed.getAccountResource(linkage005Address, - blockingStubFull); - Account info4 = PublicMethed.queryAccount(linkage005Address, blockingStubFull); - Long beforeBalance4 = info4.getBalance(); - Long beforeEnergyLimit4 = resourceInfo4.getEnergyLimit(); - Long beforeEnergyUsed4 = resourceInfo4.getEnergyUsed(); - Long beforeFreeNetLimit4 = resourceInfo4.getFreeNetLimit(); - Long beforeNetLimit4 = resourceInfo4.getNetLimit(); - Long beforeNetUsed4 = resourceInfo4.getNetUsed(); - Long beforeFreeNetUsed4 = resourceInfo4.getFreeNetUsed(); - logger.info("beforeBalance4:" + beforeBalance4); - logger.info("beforeEnergyLimit4:" + beforeEnergyLimit4); - logger.info("beforeEnergyUsed4:" + beforeEnergyUsed4); - logger.info("beforeFreeNetLimit4:" + beforeFreeNetLimit4); - logger.info("beforeNetLimit4:" + beforeNetLimit4); - logger.info("beforeNetUsed4:" + beforeNetUsed4); - logger.info("beforeFreeNetUsed4:" + beforeFreeNetUsed4); - txid = PublicMethed.triggerContract(contractAddress, - "testUseStorage(uint256)", zeroForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - fee = infoById.get().getFee(); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Account infoafter4 = PublicMethed.queryAccount(linkage005Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter4 = PublicMethed.getAccountResource(linkage005Address, - blockingStubFull1); - Long afterBalance4 = infoafter4.getBalance(); - Long afterEnergyLimit4 = resourceInfoafter4.getEnergyLimit(); - Long afterEnergyUsed4 = resourceInfoafter4.getEnergyUsed(); - Long afterFreeNetLimit4 = resourceInfoafter4.getFreeNetLimit(); - Long afterNetLimit4 = resourceInfoafter4.getNetLimit(); - Long afterNetUsed4 = resourceInfoafter4.getNetUsed(); - Long afterFreeNetUsed4 = resourceInfoafter4.getFreeNetUsed(); - logger.info("afterBalance4:" + afterBalance4); - logger.info("afterEnergyLimit4:" + afterEnergyLimit4); - logger.info("afterEnergyUsed4:" + afterEnergyUsed4); - logger.info("afterFreeNetLimit4:" + afterFreeNetLimit4); - logger.info("afterNetLimit4:" + afterNetLimit4); - logger.info("afterNetUsed4:" + afterNetUsed4); - logger.info("afterFreeNetUsed4:" + afterFreeNetUsed4); - logger.info("---------------:"); - Assert.assertTrue(beforeBalance4 - fee == afterBalance4); - Assert.assertTrue(afterEnergyUsed4 > beforeEnergyUsed4); - Assert.assertTrue(afterNetUsed4 > beforeNetUsed4); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - zeroForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - String txid1 = PublicMethed.triggerContract(contractAddress, - "testUseStorage(uint256)", firstForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - - final String txid2 = PublicMethed.triggerContract(contractAddress, - "testUseStorage(uint256)", secondForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - - final String txid3 = PublicMethed.triggerContract(contractAddress, - "testUseStorage(uint256)", thirdForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - - final String txid4 = PublicMethed.triggerContract(contractAddress, - "testUseStorage(uint256)", forthForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - - final String txid5 = PublicMethed.triggerContract(contractAddress, - "testUseStorage(uint256)", fifthForCycleTimes.toString(), false, - 0, 100000000L, linkage005Address, linkage005Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - firstForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - infoById = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - secondForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - infoById = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - thirdForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - infoById = PublicMethed.getTransactionInfoById(txid4, blockingStubFull); - forthForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - infoById = PublicMethed.getTransactionInfoById(txid5, blockingStubFull); - fifthForCycleCost = infoById.get().getReceipt().getEnergyUsageTotal(); - - Assert.assertTrue(thirdForCycleCost - secondForCycleCost - == secondForCycleCost - firstForCycleCost); - Assert.assertTrue(fifthForCycleCost - forthForCycleCost - == forthForCycleCost - thirdForCycleCost); - - PublicMethed.unFreezeBalance(linkage005Address, linkage005Key, 1, - linkage005Address, blockingStubFull); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage006.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage006.java deleted file mode 100644 index 60c40eaeee0..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractLinkage006.java +++ /dev/null @@ -1,329 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractLinkage006 { - - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - String contractName; - String code; - String abi; - byte[] contractAddress; - String txid; - Optional infoById; - String initParmes; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] linkage006Address = ecKey1.getAddress(); - String linkage006Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] linkage006Address2 = ecKey2.getAddress(); - String linkage006Key2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(linkage006Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true, description = "Deploy contract with stack function") - public void teststackOutByContract() { - - Assert.assertTrue(PublicMethed.sendcoin(linkage006Address, 20000000000L, fromAddress, - testKey003, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalance(linkage006Address, 1000000L, - 0, linkage006Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(linkage006Address, 1000000L, - 0, 1, linkage006Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(linkage006Address, - blockingStubFull); - Account info; - info = PublicMethed.queryAccount(linkage006Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyLimit = resourceInfo.getEnergyLimit(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - Long beforeNetLimit = resourceInfo.getNetLimit(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyLimit:" + beforeEnergyLimit); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeFreeNetLimit:" + beforeFreeNetLimit); - logger.info("beforeNetLimit:" + beforeNetLimit); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String filePath = "./src/test/resources/soliditycode/contractLinkage006.sol"; - String contractName = "AA"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - //success ,balnace change.use EnergyUsed and NetUsed - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit, 1000L, 100, null, linkage006Key, - linkage006Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("txid is " + txid); - contractAddress = infoById.get().getContractAddress().toByteArray(); - Long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - Long fee = infoById.get().getFee(); - Long energyFee = infoById.get().getReceipt().getEnergyFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal:" + energyUsageTotal); - logger.info("fee:" + fee); - logger.info("energyFee:" + energyFee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - Account infoafter = PublicMethed.queryAccount(linkage006Address, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(linkage006Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyLimit = resourceInfoafter.getEnergyLimit(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterFreeNetLimit = resourceInfoafter.getFreeNetLimit(); - Long afterNetLimit = resourceInfoafter.getNetLimit(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyLimit:" + afterEnergyLimit); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterFreeNetLimit:" + afterFreeNetLimit); - logger.info("afterNetLimit:" + afterNetLimit); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue((beforeBalance - fee - 1000L) == afterBalance); - Assert.assertTrue((beforeNetUsed + netUsed) >= afterNetUsed); - Assert.assertTrue((beforeEnergyUsed + energyUsed) >= afterEnergyUsed); - PublicMethed.unFreezeBalance(linkage006Address, linkage006Key, 1, - null, blockingStubFull); - } - - @Test(enabled = true, description = "Boundary value for contract stack(63 is the largest level)") - public void teststackOutByContract1() { - Assert.assertTrue(PublicMethed.sendcoin(linkage006Address2, 20000000000L, fromAddress, - testKey003, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalance(linkage006Address2, 1000000L, - 0, linkage006Key2, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(linkage006Address2, 1000000L, - 0, 1, linkage006Key2, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(linkage006Address2, - blockingStubFull); - Account info1 = PublicMethed.queryAccount(linkage006Address2, blockingStubFull); - Long beforeBalance1 = info1.getBalance(); - Long beforeEnergyLimit1 = resourceInfo1.getEnergyLimit(); - Long beforeEnergyUsed1 = resourceInfo1.getEnergyUsed(); - Long beforeFreeNetLimit1 = resourceInfo1.getFreeNetLimit(); - Long beforeNetLimit1 = resourceInfo1.getNetLimit(); - Long beforeNetUsed1 = resourceInfo1.getNetUsed(); - Long beforeFreeNetUsed1 = resourceInfo1.getFreeNetUsed(); - logger.info("beforeBalance1:" + beforeBalance1); - logger.info("beforeEnergyLimit1:" + beforeEnergyLimit1); - logger.info("beforeEnergyUsed1:" + beforeEnergyUsed1); - logger.info("beforeFreeNetLimit1:" + beforeFreeNetLimit1); - logger.info("beforeNetLimit1:" + beforeNetLimit1); - logger.info("beforeNetUsed1:" + beforeNetUsed1); - logger.info("beforeFreeNetUsed1:" + beforeFreeNetUsed1); - - //success ,balance change.use EnergyUsed and NetUsed - initParmes = "\"" + Base58.encode58Check(fromAddress) + "\",\"63\""; - txid = PublicMethed.triggerContract(contractAddress, - "init(address,uint256)", initParmes, false, - 0, 100000000L, linkage006Address2, linkage006Key2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - Long fee1 = infoById1.get().getFee(); - Long energyFee1 = infoById1.get().getReceipt().getEnergyFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - logger.info("fee1:" + fee1); - logger.info("energyFee1:" + energyFee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - Account infoafter1 = PublicMethed.queryAccount(linkage006Address2, blockingStubFull1); - AccountResourceMessage resourceInfoafter1 = PublicMethed - .getAccountResource(linkage006Address2, - blockingStubFull1); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyLimit1 = resourceInfoafter1.getEnergyLimit(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterFreeNetLimit1 = resourceInfoafter1.getFreeNetLimit(); - Long afterNetLimit1 = resourceInfoafter1.getNetLimit(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyLimit1:" + afterEnergyLimit1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterFreeNetLimit1:" + afterFreeNetLimit1); - logger.info("afterNetLimit1:" + afterNetLimit1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - logger.info("---------------:"); - Assert.assertTrue((beforeBalance1 - fee1) == afterBalance1); - Assert.assertTrue(afterNetUsed1 > beforeNetUsed1); - Assert.assertTrue((beforeEnergyUsed1 + energyUsed1) >= afterEnergyUsed1); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - } - - @Test(enabled = true, description = "Boundary value for contract stack" - + "(Trigger 64 level can't success)") - public void teststackOutByContract2() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - initParmes = "\"" + Base58.encode58Check(fromAddress) + "\",\"64\""; - AccountResourceMessage resourceInfo2 = PublicMethed.getAccountResource(linkage006Address2, - blockingStubFull); - Account info2 = PublicMethed.queryAccount(linkage006Address2, blockingStubFull); - Long beforeBalance2 = info2.getBalance(); - Long beforeEnergyLimit2 = resourceInfo2.getEnergyLimit(); - Long beforeEnergyUsed2 = resourceInfo2.getEnergyUsed(); - Long beforeFreeNetLimit2 = resourceInfo2.getFreeNetLimit(); - Long beforeNetLimit2 = resourceInfo2.getNetLimit(); - Long beforeNetUsed2 = resourceInfo2.getNetUsed(); - Long beforeFreeNetUsed2 = resourceInfo2.getFreeNetUsed(); - logger.info("beforeBalance2:" + beforeBalance2); - logger.info("beforeEnergyLimit2:" + beforeEnergyLimit2); - logger.info("beforeEnergyUsed2:" + beforeEnergyUsed2); - logger.info("beforeFreeNetLimit2:" + beforeFreeNetLimit2); - logger.info("beforeNetLimit2:" + beforeNetLimit2); - logger.info("beforeNetUsed2:" + beforeNetUsed2); - logger.info("beforeFreeNetUsed2:" + beforeFreeNetUsed2); - //failed ,use EnergyUsed and NetUsed - txid = PublicMethed.triggerContract(contractAddress, - "init(address,uint256)", initParmes, false, - 1000, 100000000L, linkage006Address2, linkage006Key2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById2 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Long energyUsageTotal2 = infoById2.get().getReceipt().getEnergyUsageTotal(); - Long fee2 = infoById2.get().getFee(); - Long energyFee2 = infoById2.get().getReceipt().getEnergyFee(); - Long netUsed2 = infoById2.get().getReceipt().getNetUsage(); - Long energyUsed2 = infoById2.get().getReceipt().getEnergyUsage(); - Long netFee2 = infoById2.get().getReceipt().getNetFee(); - logger.info("energyUsageTotal2:" + energyUsageTotal2); - logger.info("fee2:" + fee2); - logger.info("energyFee2:" + energyFee2); - logger.info("netUsed2:" + netUsed2); - logger.info("energyUsed2:" + energyUsed2); - logger.info("netFee2:" + netFee2); - - Account infoafter2 = PublicMethed.queryAccount(linkage006Address2, blockingStubFull1); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(linkage006Address2, - blockingStubFull1); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyLimit2 = resourceInfoafter2.getEnergyLimit(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterFreeNetLimit2 = resourceInfoafter2.getFreeNetLimit(); - Long afterNetLimit2 = resourceInfoafter2.getNetLimit(); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - logger.info("afterBalance2:" + afterBalance2); - logger.info("afterEnergyLimit2:" + afterEnergyLimit2); - logger.info("afterEnergyUsed2:" + afterEnergyUsed2); - logger.info("afterFreeNetLimit2:" + afterFreeNetLimit2); - logger.info("afterNetLimit2:" + afterNetLimit2); - logger.info("afterNetUsed2:" + afterNetUsed2); - logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2); - - Assert.assertTrue((beforeBalance2 - fee2) == afterBalance2); - Assert.assertTrue((beforeEnergyUsed2 + energyUsed2) >= afterEnergyUsed2); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - PublicMethed.unFreezeBalance(linkage006Address2, linkage006Key2, 1, - linkage006Address2, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario002.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario002.java deleted file mode 100644 index b5834aebb38..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario002.java +++ /dev/null @@ -1,152 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract002Address = ecKey1.getAddress(); - String contract002Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract002Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - } - - @Test(enabled = true, description = "Deploy contract with java-tron support interface") - public void deployTronNative() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract002Address = ecKey1.getAddress(); - String contract002Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(contract002Address, 500000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract002Address, 1000000L, - 0, 1, contract002Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract002Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Long balanceBefore = PublicMethed.queryAccount(contract002Key, blockingStubFull).getBalance(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - - String contractName = "TronNative"; - String filePath = "./src/test/resources/soliditycode/contractScenario002.sol"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 100, null, contract002Key, contract002Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - - logger.info(txid); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - com.google.protobuf.ByteString contractAddress = infoById.get().getContractAddress(); - SmartContract smartContract = PublicMethed - .getContract(contractAddress.toByteArray(), blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - accountResource = PublicMethed.getAccountResource(contract002Address, blockingStubFull1); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - Long balanceAfter = PublicMethed.queryAccount(contract002Address, blockingStubFull1) - .getBalance(); - - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - logger.info("after balance is " + Long.toString(balanceAfter)); - logger.info("transaction fee is " + Long.toString(infoById.get().getFee())); - - Assert.assertTrue(energyUsage > 0); - Assert.assertTrue(balanceBefore == balanceAfter + infoById.get().getFee()); - PublicMethed.unFreezeBalance(contract002Address, contract002Key, 1, - contract002Address, blockingStubFull); - - } - - @Test(enabled = true, description = "Get smart contract with invalid address") - public void getContractWithInvalidAddress() { - byte[] contractAddress = contract002Address; - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - logger.info(smartContract.getAbi().toString()); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario011.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario011.java deleted file mode 100644 index 438d270fb68..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario011.java +++ /dev/null @@ -1,517 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.springframework.util.StringUtils; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - - String kittyCoreAddressAndCut = ""; - byte[] kittyCoreContractAddress = null; - byte[] saleClockAuctionContractAddress = null; - byte[] siringClockAuctionContractAddress = null; - byte[] geneScienceInterfaceContractAddress = null; - Integer consumeUserResourcePercent = 50; - String txid = ""; - Optional infoById = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] deployAddress = ecKey1.getAddress(); - String deployKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] triggerAddress = ecKey2.getAddress(); - String triggerKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(deployKey); - PublicMethed.printAddress(triggerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.sendcoin(deployAddress, 50000000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.sendcoin(triggerAddress, 50000000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true, description = "Deploy Erc721 contract \"Kitty Core\"") - public void deployErc721KittyCore() { - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(deployAddress, 100000000L, - 0, 1, deployKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Assert.assertTrue(PublicMethed.freezeBalance(deployAddress, 100000000L, 0, - deployKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - Assert.assertTrue(PublicMethed.freezeBalance(triggerAddress, 100000000L, 0, - triggerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - Account account = PublicMethed.queryAccount(deployAddress, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - String contractName = "KittyCore"; - String filePath = "./src/test/resources/soliditycode/contractScenario011.sol"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - logger.info("Kitty Core"); - kittyCoreContractAddress = PublicMethed.deployContract(contractName, abi, code, "", - maxFeeLimit, 0L, consumeUserResourcePercent, null, deployKey, - deployAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(kittyCoreContractAddress, - blockingStubFull); - Assert.assertFalse(StringUtils.isEmpty(smartContract.getBytecode())); - - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - cpuUsage = accountResource.getEnergyUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - logger.info(ByteArray.toHexString(kittyCoreContractAddress)); - logger.info(ByteArray.toHexString(kittyCoreContractAddress).substring(2)); - - kittyCoreAddressAndCut = "000000000000000000000000" + ByteArray - .toHexString(kittyCoreContractAddress).substring(2); - kittyCoreAddressAndCut = kittyCoreAddressAndCut + "0000000000000000000000000000000000000000000" - + "000000000000000000100"; - } - - @Test(enabled = true, description = "Deploy Erc721 contract \"Sale Clock Auction\"") - public void deploySaleClockAuction() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - Account account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - String contractName = "SaleClockAuction"; - String filePath = "./src/test/resources/soliditycode/contractScenario011.sol"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - logger.info("Sale Clock Auction"); - //saleClockAuctionContractAddress; - String data = "\"" + Base58.encode58Check(kittyCoreContractAddress) + "\"," + 100; - String deplTxid = PublicMethed - .deployContractWithConstantParame(contractName, abi, code, "constructor(address,uint256)", - data, "", maxFeeLimit, 0L, consumeUserResourcePercent, null, deployKey, deployAddress, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional info = PublicMethed - .getTransactionInfoById(deplTxid, blockingStubFull); - Assert.assertTrue(info.get().getResultValue() == 0); - - saleClockAuctionContractAddress = info.get().getContractAddress().toByteArray(); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(saleClockAuctionContractAddress, - blockingStubFull); - Assert.assertFalse(StringUtils.isEmpty(smartContract.getBytecode())); - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - cpuUsage = accountResource.getEnergyUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - - String triggerTxid = PublicMethed - .triggerContract(saleClockAuctionContractAddress, "isSaleClockAuction()", "#", false, 0, - maxFeeLimit, deployAddress, deployKey, blockingStubFull); - Optional inFoByid = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Ttttt " + triggerTxid); - Assert.assertTrue(inFoByid.get().getResultValue() == 0); - } - - @Test(enabled = true, description = "Deploy Erc721 contract \"Siring Clock Auction\"") - public void deploySiringClockAuction() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - Account account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - String contractName = "SiringClockAuction"; - String filePath = "./src/test/resources/soliditycode/contractScenario011.sol"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String data = "\"" + Base58.encode58Check(kittyCoreContractAddress) + "\"," + 100; - String siringClockAuctionContractAddressTxid = PublicMethed - .deployContractWithConstantParame(contractName, abi, code, "constructor(address,uint256)", - data, - "", maxFeeLimit, 0L, consumeUserResourcePercent, null, deployKey, - deployAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional info2 = PublicMethed - .getTransactionInfoById(siringClockAuctionContractAddressTxid, blockingStubFull); - siringClockAuctionContractAddress = info2.get().getContractAddress().toByteArray(); - Assert.assertTrue(info2.get().getResultValue() == 0); - SmartContract smartContract = PublicMethed.getContract(siringClockAuctionContractAddress, - blockingStubFull); - Assert.assertFalse(StringUtils.isEmpty(smartContract.getBytecode())); - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - cpuUsage = accountResource.getEnergyUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - } - - @Test(enabled = true, description = "Deploy Erc721 contract \"Gene Science Interface\"") - public void deployGeneScienceInterface() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - Account account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - String contractName = "GeneScienceInterface"; - String filePath = "./src/test/resources/soliditycode/contractScenario011.sol"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, - "", maxFeeLimit, - 0L, consumeUserResourcePercent, null, deployKey, deployAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional info2 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - geneScienceInterfaceContractAddress = info2.get().getContractAddress().toByteArray(); - Assert.assertTrue(info2.get().getResultValue() == 0); - - SmartContract smartContract = PublicMethed.getContract(geneScienceInterfaceContractAddress, - blockingStubFull); - Assert.assertFalse(StringUtils.isEmpty(smartContract.getBytecode())); - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - cpuUsage = accountResource.getEnergyUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - } - - @Test(enabled = true, description = "Set three contract address for Kitty Core, " - + "set three CXO roles") - public void triggerToSetThreeContractAddressToKittyCore() { - //Set SaleAuctionAddress to kitty core. - String saleContractString = "\"" + Base58.encode58Check(saleClockAuctionContractAddress) + "\""; - txid = PublicMethed.triggerContract(kittyCoreContractAddress, "setSaleAuctionAddress(address)", - saleContractString, false, 0, 10000000L, deployAddress, deployKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - //Set SiringAuctionAddress to kitty core. - String siringContractString = "\"" + Base58.encode58Check(siringClockAuctionContractAddress) - + "\""; - txid = PublicMethed - .triggerContract(kittyCoreContractAddress, "setSiringAuctionAddress(address)", - siringContractString, false, 0, 10000000L, deployAddress, deployKey, blockingStubFull); - logger.info(txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - //Set gen contract to kitty core - String genContractString = "\"" + Base58.encode58Check(geneScienceInterfaceContractAddress) - + "\""; - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setGeneScienceAddress(address)", genContractString, - false, 0, 10000000L, deployAddress, deployKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - //Start the game. - Integer result = 1; - Integer times = 0; - while (result == 1) { - txid = PublicMethed.triggerContract(kittyCoreContractAddress, "unpause()", "", false, 0, - 10000000L, deployAddress, deployKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - result = infoById.get().getResultValue(); - if (times++ == 3) { - break; - } - } - - Assert.assertTrue(result == 0); - logger.info("start the game " + txid); - - //Create one gen0 cat. - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "createGen0Auction(uint256)", "-1000000000000000", false, - 0, 100000000L, deployAddress, deployKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "gen0CreatedCount()", "#", false, - 0, 100000000L, deployAddress, deployKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "getKitty(uint256)", "1", false, 0, 10000000, triggerAddress, - triggerKey, blockingStubFull); - logger.info("getKitty " + txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - String newCxoAddress = "\"" + Base58.encode58Check(triggerAddress) - + "\""; - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCOO(address)", newCxoAddress, false, 0, 10000000, deployAddress, - deployKey, blockingStubFull); - logger.info("COO " + txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCFO(address)", newCxoAddress, false, 0, 10000000, deployAddress, - deployKey, blockingStubFull); - logger.info("CFO " + txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCEO(address)", newCxoAddress, false, 0, 1000000, deployAddress, - deployKey, blockingStubFull); - logger.info("CEO " + txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - } - - @Test(enabled = true, description = "Create Gen0 cat") - public void triggerUseTriggerEnergyUsage() { - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] triggerUseTriggerEnergyUsageAddress = ecKey3.getAddress(); - final String triggerUseTriggerEnergyUsageKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - Assert.assertTrue( - PublicMethed.sendcoin(triggerUseTriggerEnergyUsageAddress, 100000000000L, - fromAddress, testKey002, blockingStubFull)); - String newCxoAddress = "\"" + Base58.encode58Check(triggerUseTriggerEnergyUsageAddress) - + "\""; - PublicMethed.waitProduceNextBlock(blockingStubFull); - final String txid1; - final String txid2; - final String txid3; - txid1 = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCOO(address)", newCxoAddress, false, 0, maxFeeLimit, triggerAddress, - triggerKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("COO " + txid); - - txid2 = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCFO(address)", newCxoAddress, false, 0, maxFeeLimit, triggerAddress, - triggerKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("CFO " + txid); - - txid3 = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCEO(address)", newCxoAddress, false, 0, maxFeeLimit, triggerAddress, - triggerKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("CEO " + txid); - - infoById = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - infoById = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - infoById = PublicMethed.getTransactionInfoById(txid3, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long beforeBalance = PublicMethed - .queryAccount(triggerUseTriggerEnergyUsageKey, blockingStubFull).getBalance(); - logger.info("before balance is " + Long.toString(beforeBalance)); - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "createGen0Auction(uint256)", "0", false, - 0, 100000000L, triggerUseTriggerEnergyUsageAddress, triggerUseTriggerEnergyUsageKey, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull1); - logger.info("Q " + Long - .toString(infoById.get().getReceipt().getEnergyFee())); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsage() == 0); - Assert.assertTrue(infoById.get().getReceipt().getEnergyFee() > 10000); - // Assert.assertTrue(infoById.get().getReceipt().getOriginEnergyUsage() > 10000); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() - == infoById.get().getReceipt().getEnergyFee() / 100 + infoById.get().getReceipt() - .getOriginEnergyUsage()); - - Long fee = infoById.get().getFee(); - Long afterBalance = PublicMethed - .queryAccount(triggerUseTriggerEnergyUsageKey, blockingStubFull1).getBalance(); - logger.info("after balance is " + Long.toString(afterBalance)); - logger.info("fee is " + Long.toString(fee)); - Assert.assertTrue(beforeBalance == afterBalance + fee); - - logger.info("before EnergyUsage is " + infoById.get().getReceipt().getEnergyUsage()); - logger.info("before EnergyFee is " + infoById.get().getReceipt().getEnergyFee()); - logger.info("before OriginEnergyUsage is " + infoById.get().getReceipt() - .getOriginEnergyUsage()); - logger.info("before EnergyTotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue( - PublicMethed.freezeBalanceGetEnergy(triggerUseTriggerEnergyUsageAddress, 100000000L, - 0, 1, triggerUseTriggerEnergyUsageKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - beforeBalance = PublicMethed.queryAccount(triggerUseTriggerEnergyUsageKey, blockingStubFull) - .getBalance(); - logger.info("before balance is " + Long.toString(beforeBalance)); - - AccountResourceMessage accountResource = PublicMethed - .getAccountResource(triggerUseTriggerEnergyUsageAddress, blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - logger.info("before EnergyLimit is " + Long.toString(energyLimit)); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "createGen0Auction(uint256)", "0", false, - 0, 100000000L, triggerUseTriggerEnergyUsageAddress, triggerUseTriggerEnergyUsageKey, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull1); - logger.info("after EnergyUsage is " + infoById.get().getReceipt().getEnergyUsage()); - logger.info("after EnergyFee is " + infoById.get().getReceipt().getEnergyFee()); - logger.info("after OriginEnergyUsage is " + infoById.get().getReceipt().getOriginEnergyUsage()); - logger.info("after EnergyTotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - fee = infoById.get().getFee(); - afterBalance = PublicMethed.queryAccount(triggerUseTriggerEnergyUsageKey, blockingStubFull1) - .getBalance(); - logger.info("after balance is " + Long.toString(afterBalance)); - logger.info("fee is " + Long.toString(fee)); - - accountResource = PublicMethed - .getAccountResource(triggerUseTriggerEnergyUsageAddress, blockingStubFull1); - energyLimit = accountResource.getEnergyLimit(); - - logger.info("after EnergyLimit is " + Long.toString(energyLimit)); - - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsage() > 10000); - Assert.assertTrue(infoById.get().getReceipt().getEnergyFee() == 0); - - //Assert.assertTrue(infoById.get().getReceipt().getOriginEnergyUsage() > 10000); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() == infoById.get() - .getReceipt().getEnergyUsage() + infoById.get().getReceipt().getOriginEnergyUsage()); - // Assert.assertTrue(infoById.get().getReceipt().getEnergyUsage() == infoById.get() - // .getReceipt().getOriginEnergyUsage()); - - Assert.assertTrue(beforeBalance == afterBalance + fee); - PublicMethed.unFreezeBalance(deployAddress, deployKey, 1, - deployAddress, blockingStubFull); - PublicMethed.unFreezeBalance(triggerAddress, triggerKey, 1, - triggerAddress, blockingStubFull); - - PublicMethed - .unFreezeBalance(triggerUseTriggerEnergyUsageAddress, triggerUseTriggerEnergyUsageKey, 1, - triggerUseTriggerEnergyUsageAddress, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario014.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario014.java deleted file mode 100644 index 456fdf57b46..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario014.java +++ /dev/null @@ -1,242 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario014 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - byte[] contractAddress1 = null; - byte[] contractAddress2 = null; - byte[] contractAddress3 = null; - String txid = ""; - Optional infoById = null; - String contractName = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract014Address = ecKey1.getAddress(); - String contract014Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - String priKey014 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverAddress = ecKey2.getAddress(); - String receiverKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Triple trigger in smart contract") - public void testTripleTrigger() { - - ecKey2 = new ECKey(Utils.getRandom()); - receiverAddress = ecKey2.getAddress(); - receiverKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - PublicMethed.printAddress(contract014Key); - PublicMethed.printAddress(receiverKey); - - Assert.assertTrue(PublicMethed.sendcoin(contract014Address, 5000000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceGetEnergy(contract014Address, 1000000000000L, 0, 1, priKey014, - blockingStubFull)); - - logger.info("contract014Address : == " + contract014Key); - //Deploy contract1, contract1 has a function to transaction 5 sun to target account - String contractName = "Contract1"; - String filePath = "./src/test/resources/soliditycode/contractScenario014.sol"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 100, null, contract014Key, contract014Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - contractAddress1 = infoById.get().getContractAddress().toByteArray(); - - //Deploy contract2, contract2 has a function to call contract1 transaction sun function. - // and has a revert function. - contractName = "contract2"; - String filePath1 = "./src/test/resources/soliditycode/contractScenario014.sol"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath1, contractName); - - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String parame = "\"" + Base58.encode58Check(contractAddress1) + "\""; - - txid = PublicMethed.deployContractWithConstantParame(contractName, abi1, code1, - "constructor(address)", parame, "", maxFeeLimit, 0L, 100, null, - contract014Key, contract014Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - contractAddress2 = infoById.get().getContractAddress().toByteArray(); - - //Deploy contract3, trigger contrct2 function. - contractName = "contract3"; - String filePath2 = "./src/test/resources/soliditycode/contractScenario014.sol"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath2, contractName); - - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - parame = "\"" + Base58.encode58Check(contractAddress2) + "\""; - - txid = PublicMethed.deployContractWithConstantParame(contractName, abi2, code2, - "constructor(address)", parame, "", maxFeeLimit, 0L, 100, null, - contract014Key, contract014Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - contractAddress3 = infoById.get().getContractAddress().toByteArray(); - - Assert.assertTrue(PublicMethed.sendcoin(contractAddress1, 1000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(receiverAddress, 1000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(contractAddress2, 1000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(contractAddress3, 1000000L, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Test contract2 trigger contract1 to test call function - Account contract2AccountInfo = PublicMethed.queryAccount(contractAddress2, blockingStubFull); - final Long contract2BeforeBalance = contract2AccountInfo.getBalance(); - Account receiverAccountInfo = PublicMethed.queryAccount(receiverAddress, blockingStubFull); - Long receiverBeforeBalance = receiverAccountInfo.getBalance(); - Account contract1AccountInfo = PublicMethed.queryAccount(contractAddress1, blockingStubFull); - Long contract1BeforeBalance = contract1AccountInfo.getBalance(); - logger.info("before contract1 balance is " + Long.toString(contract1BeforeBalance)); - logger.info("before receiver balance is " + Long.toString(receiverBeforeBalance)); - String receiveAddress = "\"" + Base58.encode58Check(receiverAddress) + "\""; - txid = PublicMethed.triggerContract(contractAddress2, - "triggerContract1(address)", receiveAddress, false, - 0, maxFeeLimit, contract014Address, contract014Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - contract2AccountInfo = PublicMethed.queryAccount(contractAddress2, blockingStubFull); - final Long contract2AfterBalance = contract2AccountInfo.getBalance(); - //contract2AccountInfo.getAccountResource().getFrozenBalanceForEnergy(); - receiverAccountInfo = PublicMethed.queryAccount(receiverAddress, blockingStubFull); - Long receiverAfterBalance = receiverAccountInfo.getBalance(); - contract1AccountInfo = PublicMethed.queryAccount(contractAddress1, blockingStubFull); - Long contract1AfterBalance = contract1AccountInfo.getBalance(); - logger.info("after contract1 balance is " + Long.toString(contract1AfterBalance)); - Assert.assertTrue(receiverAfterBalance - receiverBeforeBalance == 5); - Assert.assertTrue(contract2BeforeBalance - contract2AfterBalance == 0); - Assert.assertTrue(contract1BeforeBalance - contract1AfterBalance == 5); - - //Test contract2 trigger contract1 but revert - contract1AccountInfo = PublicMethed.queryAccount(contractAddress1, blockingStubFull); - contract1BeforeBalance = contract1AccountInfo.getBalance(); - receiverAccountInfo = PublicMethed.queryAccount(receiverAddress, blockingStubFull); - receiverBeforeBalance = receiverAccountInfo.getBalance(); - receiveAddress = "\"" + Base58.encode58Check(receiverAddress) + "\""; - txid = PublicMethed.triggerContract(contractAddress2, - "triggerContract1ButRevert(address)", receiveAddress, false, - 0, 10000000L, contract014Address, contract014Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - contract1AccountInfo = PublicMethed.queryAccount(contractAddress1, blockingStubFull); - contract1AfterBalance = contract1AccountInfo.getBalance(); - receiverAccountInfo = PublicMethed.queryAccount(receiverAddress, blockingStubFull); - receiverAfterBalance = receiverAccountInfo.getBalance(); - logger.info("after receiver balance is " + Long.toString(receiverAfterBalance)); - Assert.assertTrue(receiverAfterBalance - receiverBeforeBalance == 0); - Assert.assertTrue(contract1BeforeBalance - contract1AfterBalance == 0); - - //Test contract3 trigger contract2 to call contract1 - contract1AccountInfo = PublicMethed.queryAccount(contractAddress1, blockingStubFull); - contract1BeforeBalance = contract1AccountInfo.getBalance(); - Account contract3AccountInfo = PublicMethed.queryAccount(contractAddress3, blockingStubFull); - final Long contract3BeforeBalance = contract3AccountInfo.getBalance(); - receiverAccountInfo = PublicMethed.queryAccount(receiverAddress, blockingStubFull); - receiverBeforeBalance = receiverAccountInfo.getBalance(); - logger.info("before receiver balance is " + Long.toString(receiverBeforeBalance)); - logger.info("before contract3 balance is " + Long.toString(contract3BeforeBalance)); - receiveAddress = "\"" + Base58.encode58Check(receiverAddress) + "\""; - txid = PublicMethed.triggerContract(contractAddress3, - "triggerContract2(address)", receiveAddress, false, - 0, 10000000L, contract014Address, contract014Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - contract3AccountInfo = PublicMethed.queryAccount(contractAddress3, blockingStubFull); - final Long contract3AfterBalance = contract3AccountInfo.getBalance(); - receiverAccountInfo = PublicMethed.queryAccount(receiverAddress, blockingStubFull); - receiverAfterBalance = receiverAccountInfo.getBalance(); - logger.info("after receiver balance is " + Long.toString(receiverAfterBalance)); - logger.info("after contract3 balance is " + Long.toString(contract3AfterBalance)); - contract1AccountInfo = PublicMethed.queryAccount(contractAddress1, blockingStubFull); - contract1AfterBalance = contract1AccountInfo.getBalance(); - - Assert.assertTrue(receiverAfterBalance - receiverBeforeBalance == 5); - Assert.assertTrue(contract3BeforeBalance - contract3AfterBalance == 0); - Assert.assertTrue(contract1BeforeBalance - contract1AfterBalance == 5); - - - } - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario015.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario015.java deleted file mode 100644 index a8a4fcfe35b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractScenario015.java +++ /dev/null @@ -1,140 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractScenario015 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - byte[] contractAddress1 = null; - byte[] contractAddress2 = null; - byte[] contractAddress3 = null; - String txid = ""; - Optional infoById = null; - String contractName = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract014Address = ecKey1.getAddress(); - String contract014Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverAddress = ecKey2.getAddress(); - String receiverKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "TRON TRC20 transfer token") - public void trc20Tron() { - ecKey1 = new ECKey(Utils.getRandom()); - contract014Address = ecKey1.getAddress(); - contract014Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - receiverAddress = ecKey2.getAddress(); - receiverKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - PublicMethed.printAddress(contract014Key); - PublicMethed.printAddress(receiverKey); - - Assert.assertTrue(PublicMethed.sendcoin(contract014Address, 500000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Deploy contract1, contract1 has a function to transaction 5 sun to target account - String contractName = "TRON TRC20"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_Scenario015_TRC20_TRON"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_Scenario015_TRC20_TRON"); - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 100, null, contract014Key, contract014Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - contractAddress1 = infoById.get().getContractAddress().toByteArray(); - //Set SiringAuctionAddress to kitty core. - String siringContractString = "\"" + Base58.encode58Check(fromAddress) + "\""; - txid = PublicMethed - .triggerContract(contractAddress1, "balanceOf(address)", siringContractString, - false, 0, 10000000L, contract014Address, contract014Key, blockingStubFull); - logger.info(txid); - - siringContractString = "\"" + Base58.encode58Check(fromAddress) + "\",\"" + 17 + "\""; - txid = PublicMethed.triggerContract(contractAddress1,"transfer(address,uint256)", - siringContractString,false, 0, 10000000L, contract014Address, - contract014Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - siringContractString = "\"" + Base58.encode58Check(fromAddress) + "\""; - txid = PublicMethed - .triggerContract(contractAddress1, "balanceOf(address)", - siringContractString, false, 0, 10000000L, contract014Address, - contract014Key, blockingStubFull); - logger.info(txid); - } - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractUnknownException.java b/src/test/java/stest/tron/wallet/dailybuild/manual/ContractUnknownException.java deleted file mode 100644 index f16cc9c45e5..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/ContractUnknownException.java +++ /dev/null @@ -1,345 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractUnknownException { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress = ecKey1.getAddress(); - String testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] grammarAddress2 = ecKey2.getAddress(); - String testKeyForGrammarAddress2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] grammarAddress3 = ecKey3.getAddress(); - String testKeyForGrammarAddress3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] grammarAddress4 = ecKey4.getAddress(); - String testKeyForGrammarAddress4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - @Test(enabled = true, description = "trigger selfdestruct method") - public void testGrammar001() { - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(grammarAddress, 204800000, - 0, 1, testKeyForGrammarAddress, blockingStubFull)); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(grammarAddress, - blockingStubFull); - info = PublicMethed.queryAccount(grammarAddress, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - long beforeenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeenergyLimit:" + beforeenergyLimit); - String filePath = "src/test/resources/soliditycode/contractUnknownException.sol"; - String contractName = "testA"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 20L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - final String s = infoById.get().getResMessage().toStringUtf8(); - long fee = infoById.get().getFee(); - long energyUsage = infoById.get().getReceipt().getEnergyUsage(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - Account infoafter = PublicMethed.queryAccount(grammarAddress, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(grammarAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfo.getNetUsed(); - Long afterFreeNetUsed = resourceInfo.getFreeNetUsed(); - long aftereenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterenergyLimit:" + aftereenergyLimit); - Assert.assertThat(s, containsString("REVERT opcode executed")); - - } - - @Test(enabled = true, description = "trigger revert method") - public void testGrammar002() { - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress2, 100000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(grammarAddress2, 10000000L, - 0, 1, testKeyForGrammarAddress2, blockingStubFull)); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(grammarAddress2, - blockingStubFull); - info = PublicMethed.queryAccount(grammarAddress2, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - long beforeenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeenergyLimit:" + beforeenergyLimit); - String filePath = "src/test/resources/soliditycode/contractUnknownException.sol"; - String contractName = "testB"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 20L, 100, null, testKeyForGrammarAddress2, - grammarAddress2, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - final long fee = infoById.get().getFee(); - final long energyUsage = infoById.get().getReceipt().getEnergyUsage(); - final long energyFee = infoById.get().getReceipt().getEnergyFee(); - - final String s = infoById.get().getResMessage().toStringUtf8(); - - Account infoafter = PublicMethed.queryAccount(grammarAddress2, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(grammarAddress2, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfo.getNetUsed(); - Long afterFreeNetUsed = resourceInfo.getFreeNetUsed(); - long aftereenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterenergyLimit:" + aftereenergyLimit); - Assert.assertThat(s, containsString("REVERT opcode executed")); - Assert.assertFalse(energyFee == 1000000000); - - Assert.assertTrue(beforeBalance - fee == afterBalance); - - } - - @Test(enabled = true, description = "trigger assert method") - public void testGrammar003() { - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress3, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(grammarAddress3, 1000000000L, - 0, 1, testKeyForGrammarAddress3, blockingStubFull)); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(grammarAddress3, - blockingStubFull); - info = PublicMethed.queryAccount(grammarAddress3, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - long beforeenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeenergyLimit:" + beforeenergyLimit); - String filePath = "src/test/resources/soliditycode/contractUnknownException.sol"; - String contractName = "testC"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 20L, 100, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - final long fee = infoById.get().getFee(); - final long energyUsage = infoById.get().getReceipt().getEnergyUsage(); - final long energyFee = infoById.get().getReceipt().getEnergyFee(); - String s = infoById.get().getResMessage().toStringUtf8(); - Account infoafter = PublicMethed.queryAccount(grammarAddress3, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(grammarAddress3, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfo.getNetUsed(); - Long afterFreeNetUsed = resourceInfo.getFreeNetUsed(); - long aftereenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterenergyLimit:" + aftereenergyLimit); - logger.info("s:" + s); - Assert.assertThat(s, containsString("Not enough energy for")); - - Assert.assertTrue(beforeBalance - fee == afterBalance); - - } - - - @Test(enabled = true, description = "trigger require method") - public void testGrammar004() { - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress4, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(grammarAddress4, 100000000L, - 0, 1, testKeyForGrammarAddress4, blockingStubFull)); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(grammarAddress4, - blockingStubFull); - info = PublicMethed.queryAccount(grammarAddress4, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - long beforeenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeenergyLimit:" + beforeenergyLimit); - String filePath = "src/test/resources/soliditycode/contractUnknownException.sol"; - String contractName = "testD"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 20L, 100, null, testKeyForGrammarAddress4, - grammarAddress4, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - final String s = infoById.get().getResMessage().toStringUtf8(); - final long fee = infoById.get().getFee(); - long energyUsage = infoById.get().getReceipt().getEnergyUsage(); - final long energyFee = infoById.get().getReceipt().getEnergyFee(); - - Account infoafter = PublicMethed.queryAccount(grammarAddress4, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(grammarAddress4, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfo.getNetUsed(); - Long afterFreeNetUsed = resourceInfo.getFreeNetUsed(); - long aftereenergyLimit = resourceInfo.getEnergyLimit(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterenergyLimit:" + aftereenergyLimit); - Assert.assertThat(s, containsString("REVERT opcode executed")); - Assert.assertTrue(beforeBalance - fee == afterBalance); - Assert.assertFalse(energyFee == 1000000000); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/RequireException.java b/src/test/java/stest/tron/wallet/dailybuild/manual/RequireException.java deleted file mode 100644 index 58e811ca094..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/RequireException.java +++ /dev/null @@ -1,806 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class RequireException { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - private ManagedChannel channelFull2 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull2 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset016Address = ecKey1.getAddress(); - String testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForAssetIssue016); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Require Exception") - public void test1TestRequireContract() { - ecKey1 = new ECKey(Utils.getRandom()); - asset016Address = ecKey1.getAddress(); - testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(asset016Address, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - String filePath = - "src/test/resources/soliditycode/requireExceptiontest1TestRequireContract.sol"; - String contractName = "TestThrowsContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - final String txid = PublicMethed.triggerContract(contractAddress, - "testRequire()", "#", false, - 0, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = true, description = "Throw Exception") - public void test2TestThrowsContract() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontest2TestThrowsContract.sol"; - String contractName = "TestThrowsContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - final String txid = PublicMethed.triggerContract(contractAddress, - "testThrow()", "#", false, - 0, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testTestThrowsContract"); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - } - - - @Test(enabled = true, description = "Call Revert ") - public void test3TestRevertContract() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontest3TestRevertContract.sol"; - String contractName = "TestThrowsContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - final String txid = PublicMethed.triggerContract(contractAddress, - "testRevert()", "#", false, - 0, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = false, description = "No payable function call value") - public void test4noPayableContract() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontest4noPayableContract_1.sol"; - String contractName = "noPayableContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - final String txid = PublicMethed.triggerContract(contractAddress, - "noPayable()", "#", false, - 22, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = false, description = "No payable Constructor") - public void test5noPayableConstructor() { - - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String filePath = - "src/test/resources/soliditycode/requireExceptiontest5noPayableConstructor_1.sol"; - String contractName = "MyContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - final String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 22L, 100, null, - testKeyForAssetIssue016, asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - - } - - @Test(enabled = true, description = "Transfer failed") - public void test6transferTestContract() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontest6transferTestContract.sol"; - String contractName = "transferTestContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - final Account info; - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String newCxoAddress = "\"" + Base58.encode58Check(testNetAccountAddress) - + "\""; - final String txid = PublicMethed.triggerContract(contractAddress, - "tranferTest(address) ", newCxoAddress, false, - 5, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("transferTestContract"); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = true, description = "No payable fallback call value") - public void test7payableFallbakContract() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontest7payableFallbakContract.sol"; - String contractName = "Caller"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Integer times = 0; - String contractName1 = "Test"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] contractAddress1; - contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, 0L, - 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Account info; - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String saleContractString = "\"" + Base58.encode58Check(contractAddress) + "\""; - final String txid = PublicMethed.triggerContract(contractAddress1, - "callTest(address)", saleContractString, false, - 5, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = true, description = "New contract gas not enough") - public void test8newContractGasNoenough() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontest8newContractGasNoenough.sol"; - String contractName = "Account"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "Initialize"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - - final byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, null, - testKeyForAssetIssue016, asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - final String txid = PublicMethed.triggerContract(contractAddress1, - "newAccount()", "#", false, - 0, 5226000, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - - } - - @Test(enabled = true, description = "Message used error") - public void test9MessageUsedErrorFeed() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontest9MessageUsedErrorFeed.sol"; - String contractName = "MathedFeed"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final String saleContractString = "\"" + Base58.encode58Check(contractAddress) + "\""; - String contractName1 = "MathedUseContract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - - final byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 100, null, - testKeyForAssetIssue016, asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - final String txid = PublicMethed.triggerContract(contractAddress1, - "messageUse(address)", saleContractString, false, - 0, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - @Test(enabled = true, description = "Function used error") - public void testFunctionUsedErrorFeed() { - String filePath = - "src/test/resources/soliditycode/requireExceptiontestFunctionUsedErrorFeed.sol"; - String contractName = "MessageFeed"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final String saleContractString = "\"" + Base58.encode58Check(contractAddress) + "\""; - - String contractName1 = "MessageUseContract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - final byte[] contractAddress1 = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, 0L, - 100, null, testKeyForAssetIssue016, - asset016Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - final String txid = PublicMethed.triggerContract(contractAddress1, - "messageUse(address)", saleContractString, false, - 0, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - - Account infoafter = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(asset016Address, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount002.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount002.java deleted file mode 100644 index 2a050d11b7e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount002.java +++ /dev/null @@ -1,168 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Comparator; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - } - - /* @Test(enabled = true) - public void TestGetAllAccount(){ - GrpcAPI.AccountList accountlist = - blockingStubFull.listAccounts(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(accountlist); - if (result.isPresent()) { - GrpcAPI.AccountList accountList = result.get(); - List list = accountList.getAccountsList(); - List newList = new ArrayList(); - newList.addAll(list); - newList.sort(new AccountComparator()); - GrpcAPI.AccountList.Builder builder = GrpcAPI.AccountList.newBuilder(); - newList.forEach(account -> builder.addAccounts(account)); - result = Optional.of(builder.build()); - } - Assert.assertTrue(result.get().getAccountsCount() > 0); - logger.info(Integer.toString(result.get().getAccountsCount())); - for (int j = 0; j < result.get().getAccountsCount(); j++){ - Assert.assertFalse(result.get().getAccounts(j).getAddress().isEmpty()); - } - - - }*/ - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - class AccountComparator implements Comparator { - - public int compare(Object o1, Object o2) { - return Long.compare(((Account) o2).getBalance(), ((Account) o1).getBalance()); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount010.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount010.java deleted file mode 100644 index 5348964f7d6..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount010.java +++ /dev/null @@ -1,138 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount010 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] account010Address = ecKey1.getAddress(); - String account010Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] account010SecondAddress = ecKey2.getAddress(); - String account010SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] account010InvalidAddress = ecKey3.getAddress(); - String account010InvalidKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - PublicMethed.printAddress(account010Key); - PublicMethed.printAddress(account010SecondKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test(enabled = false) - public void testGetStorage() { - Assert.assertTrue(PublicMethed.sendcoin(account010Address, 100000000, - fromAddress, testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(account010SecondAddress, 100000000, - fromAddress, testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(account010InvalidAddress, 100000000, - fromAddress, testKey002, blockingStubFull)); - Account account010Info = PublicMethed.queryAccount(account010Key, blockingStubFull); - Assert.assertTrue(account010Info.getAccountResource().getStorageLimit() == 0); - Assert.assertTrue(account010Info.getAccountResource().getLatestExchangeStorageTime() == 0); - - Assert.assertTrue(PublicMethed.buyStorage(100000000L, account010Address, account010Key, - blockingStubFull)); - - account010Info = PublicMethed.queryAccount(account010Key, blockingStubFull); - Assert.assertTrue(account010Info.getAccountResource().getStorageLimit() > 0); - Assert.assertTrue(account010Info.getAccountResource().getLatestExchangeStorageTime() > 0); - - AccountResourceMessage account010Resource = PublicMethed.getAccountResource(account010Address, - blockingStubFull); - Assert.assertTrue(account010Resource.getStorageLimit() > 0); - } - - @Test(enabled = false) - public void testSellStorage() { - AccountResourceMessage account010Resource = PublicMethed.getAccountResource(account010Address, - blockingStubFull); - Long storageLimit = account010Resource.getStorageLimit(); - Account account001Info = PublicMethed.queryAccount(account010Key, blockingStubFull); - Assert.assertTrue(account001Info.getBalance() == 0); - //When there is no enough storage,sell failed. - Assert.assertFalse(PublicMethed.sellStorage(storageLimit + 1, account010Address, account010Key, - blockingStubFull)); - //Can not sell 0 storage - Assert.assertFalse(PublicMethed.sellStorage(0, account010Address, account010Key, - blockingStubFull)); - //Sell all storage. - Assert.assertTrue(PublicMethed.sellStorage(storageLimit, account010Address, account010Key, - blockingStubFull)); - account010Resource = PublicMethed.getAccountResource(account010Address, - blockingStubFull); - storageLimit = account010Resource.getStorageLimit(); - Assert.assertTrue(storageLimit == 0); - account001Info = PublicMethed.queryAccount(account010Key, blockingStubFull); - Assert.assertTrue(account001Info.getBalance() > 0); - - - } - - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount012.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount012.java deleted file mode 100644 index f282f68cfef..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount012.java +++ /dev/null @@ -1,196 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount012 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("mainWitness.key25"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("mainWitness.key2"); - private final byte[] testAddress003 = PublicMethed.getFinalAddress(testKey003); - - private final String testKey004 = Configuration.getByPath("testng.conf") - .getString("mainWitness.key3"); - private final byte[] testAddress004 = PublicMethed.getFinalAddress(testKey004); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - ArrayList txidList = new ArrayList(); - - Optional infoById = null; - Long beforeTime; - Long afterTime; - Long beforeBlockNum; - Long afterBlockNum; - Block currentBlock; - Long currentBlockNum; - - //get account - - - /** - * constructor. - */ - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKey002); - PublicMethed.printAddress(testKey003); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - currentBlock = blockingStubFull1.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - beforeTime = System.currentTimeMillis(); - } - - @Test(enabled = false, threadPoolSize = 20, invocationCount = 20) - public void storageAndCpu() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset011Address = ecKey1.getAddress(); - String testKeyForAssetIssue011 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(testKeyForAssetIssue011); - - PublicMethed - .sendcoin(asset011Address, 100000000000000L, fromAddress, testKey002, blockingStubFull); - Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - randNum = rand.nextInt(4000); - - Long maxFeeLimit = 1000000000L; - String contractName = "StorageAndCpu" + Integer.toString(randNum); - String code = Configuration.getByPath("testng.conf") - .getString("code.code_WalletTestAccount012_storageAndCpu"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_WalletTestAccount012_storageAndCpu"); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, testKeyForAssetIssue011, asset011Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - String txid; - - Integer i = 1; - AccountResourceMessage accountResource = PublicMethed.getAccountResource(asset011Address, - blockingStubFull); - accountResource = PublicMethed.getAccountResource(asset011Address, - blockingStubFull); - Long beforeEnergyLimit = accountResource.getEnergyLimit(); - Long afterEnergyLimit; - Long beforeTotalEnergyLimit = accountResource.getTotalEnergyLimit(); - Account account = PublicMethed.queryAccount(testKeyForAssetIssue011, blockingStubFull); - Long afterTotalEnergyLimit; - while (i++ < 20000) { - accountResource = PublicMethed.getAccountResource(asset011Address, - blockingStubFull); - beforeEnergyLimit = accountResource.getEnergyLimit(); - beforeTotalEnergyLimit = accountResource.getTotalEnergyLimit(); - String initParmes = "\"" + "21" + "\""; - /* txid = PublicMethed.triggerContract(contractAddress, - "storage8Char()", "", false, - 0, maxFeeLimit, asset011Address, testKeyForAssetIssue011, blockingStubFull);*/ - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - txid = PublicMethed.triggerContract(contractAddress, - "add2(uint256)", initParmes, false, - 0, maxFeeLimit, asset011Address, testKeyForAssetIssue011, blockingStubFull); - accountResource = PublicMethed.getAccountResource(asset011Address, - blockingStubFull); - //logger.info("Current limit is " + accountResource.getTotalEnergyLimit()); - //PublicMethed.freezeBalanceGetEnergy(asset011Address,1000000L,3, - // 1,testKeyForAssetIssue011,blockingStubFull); - - accountResource = PublicMethed.getAccountResource(asset011Address, - blockingStubFull); - afterEnergyLimit = accountResource.getEnergyLimit(); - afterTotalEnergyLimit = accountResource.getTotalEnergyLimit(); - - logger.info("Total energy limit is " + (float) afterTotalEnergyLimit / 50000000000L); - Float rate = - (float) (afterTotalEnergyLimit - beforeTotalEnergyLimit) / beforeTotalEnergyLimit; - //logger.info("rate is " + rate); - //Assert.assertTrue(rate >= 0.001001000 && rate <= 0.001001002); - //txidList.add(txid); - try { - Thread.sleep(30); - } catch (InterruptedException e) { - e.printStackTrace(); - } - account = PublicMethed.queryAccount(testKeyForAssetIssue011, blockingStubFull); - Float energyrate = (float) (beforeEnergyLimit) / account.getAccountResource() - .getFrozenBalanceForEnergy().getFrozenBalance(); - //logger.info("energy rate is " + energyrate); - if (i % 20 == 0) { - PublicMethed.freezeBalanceForReceiver(fromAddress, 1000000L, 3, 1, - ByteString.copyFrom(asset011Address), testKey002, blockingStubFull); - } - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount014.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount014.java deleted file mode 100644 index 87a39489edb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestAccount014.java +++ /dev/null @@ -1,237 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAccount014 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private ManagedChannel channelSoliInFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSoliInFull = null; - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - private String soliInFullnode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] account014Address = ecKey1.getAddress(); - String account014Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] account014SecondAddress = ecKey2.getAddress(); - String account014SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKey002); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - channelSoliInFull = ManagedChannelBuilder.forTarget(soliInFullnode) - .usePlaintext(true) - .build(); - blockingStubSoliInFull = WalletSolidityGrpc.newBlockingStub(channelSoliInFull); - } - - @Test(enabled = true, description = "Query freeNetUsage in 50061") - public void fullAndSoliMerged1ForFreeNetUsage() { - //Create account014 - ecKey1 = new ECKey(Utils.getRandom()); - account014Address = ecKey1.getAddress(); - account014Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - ecKey2 = new ECKey(Utils.getRandom()); - account014SecondAddress = ecKey2.getAddress(); - account014SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(account014Key); - PublicMethed.printAddress(account014SecondKey); - Assert.assertTrue(PublicMethed.sendcoin(account014Address, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - - //Test freeNetUsage in fullnode and soliditynode. - Assert.assertTrue(PublicMethed.sendcoin(account014SecondAddress, 5000000L, - account014Address, account014Key, - blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(account014SecondAddress, 5000000L, - account014Address, account014Key, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account account014 = PublicMethed.queryAccount(account014Address, blockingStubFull); - final long freeNetUsageInFullnode = account014.getFreeNetUsage(); - final long createTimeInFullnode = account014.getCreateTime(); - final long lastOperationTimeInFullnode = account014.getLatestOprationTime(); - final long lastCustomeFreeTimeInFullnode = account014.getLatestConsumeFreeTime(); - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSoliInFull); - account014 = PublicMethed.queryAccount(account014Address, blockingStubSoliInFull); - final long freeNetUsageInSoliInFull = account014.getFreeNetUsage(); - final long createTimeInSoliInFull = account014.getCreateTime(); - final long lastOperationTimeInSoliInFull = account014.getLatestOprationTime(); - final long lastCustomeFreeTimeInSoliInFull = account014.getLatestConsumeFreeTime(); - //PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull,blockingStubSolidity); - account014 = PublicMethed.queryAccount(account014Address, blockingStubSolidity); - final long freeNetUsageInSolidity = account014.getFreeNetUsage(); - final long createTimeInSolidity = account014.getCreateTime(); - final long lastOperationTimeInSolidity = account014.getLatestOprationTime(); - final long lastCustomeFreeTimeInSolidity = account014.getLatestConsumeFreeTime(); - Assert.assertTrue(freeNetUsageInSoliInFull > 0 && freeNetUsageInSolidity > 0 - && freeNetUsageInFullnode > 0); - Assert.assertTrue(freeNetUsageInFullnode <= freeNetUsageInSoliInFull + 5 - && freeNetUsageInFullnode >= freeNetUsageInSoliInFull - 5); - Assert.assertTrue(freeNetUsageInFullnode <= freeNetUsageInSolidity + 5 - && freeNetUsageInFullnode >= freeNetUsageInSolidity - 5); - Assert.assertTrue(createTimeInFullnode == createTimeInSolidity && createTimeInFullnode - == createTimeInSoliInFull); - Assert.assertTrue(createTimeInSoliInFull != 0); - Assert.assertTrue(lastOperationTimeInFullnode == lastOperationTimeInSolidity - && lastOperationTimeInFullnode == lastOperationTimeInSoliInFull); - Assert.assertTrue(lastOperationTimeInSoliInFull != 0); - Assert.assertTrue(lastCustomeFreeTimeInFullnode == lastCustomeFreeTimeInSolidity - && lastCustomeFreeTimeInFullnode == lastCustomeFreeTimeInSoliInFull); - Assert.assertTrue(lastCustomeFreeTimeInSoliInFull != 0); - } - - @Test(enabled = true, description = "Query net usage in 50061") - public void fullAndSoliMerged2ForNetUsage() { - - Assert.assertTrue(PublicMethed.freezeBalance(account014Address, 1000000L, 3, - account014Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(account014SecondAddress, 1000000L, - account014Address, account014Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(account014Address, 1000000, - 3, 1, account014Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(account014Address, 1000000, - 3, 0, ByteString.copyFrom( - account014SecondAddress), account014Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(account014Address, 1000000, - 3, 1, ByteString.copyFrom( - account014SecondAddress), account014Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(account014SecondAddress, 1000000, - 3, 0, ByteString.copyFrom( - account014Address), account014SecondKey, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(account014SecondAddress, 1000000, - 3, 1, ByteString.copyFrom( - account014Address), account014SecondKey, blockingStubFull)); - - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSoliInFull); - Account account014 = PublicMethed.queryAccount(account014Address, blockingStubFull); - final long lastCustomeTimeInFullnode = account014.getLatestConsumeTime(); - final long netUsageInFullnode = account014.getNetUsage(); - final long acquiredForBandwidthInFullnode = account014 - .getAcquiredDelegatedFrozenBalanceForBandwidth(); - final long delegatedBandwidthInFullnode = account014.getDelegatedFrozenBalanceForBandwidth(); - final long acquiredForEnergyInFullnode = account014 - .getAccountResource().getAcquiredDelegatedFrozenBalanceForEnergy(); - final long delegatedForEnergyInFullnode = account014 - .getAccountResource().getDelegatedFrozenBalanceForEnergy(); - logger.info("delegatedForEnergyInFullnode " + delegatedForEnergyInFullnode); - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSoliInFull); - account014 = PublicMethed.queryAccount(account014Address, blockingStubSoliInFull); - final long lastCustomeTimeInSoliInFull = account014.getLatestConsumeTime(); - logger.info("freeNetUsageInSoliInFull " + lastCustomeTimeInSoliInFull); - final long netUsageInSoliInFull = account014.getNetUsage(); - final long acquiredForBandwidthInSoliInFull = account014 - .getAcquiredDelegatedFrozenBalanceForBandwidth(); - final long delegatedBandwidthInSoliInFull = account014.getDelegatedFrozenBalanceForBandwidth(); - final long acquiredForEnergyInSoliInFull = account014 - .getAccountResource().getAcquiredDelegatedFrozenBalanceForEnergy(); - final long delegatedForEnergyInSoliInFull = account014 - .getAccountResource().getDelegatedFrozenBalanceForEnergy(); - logger.info("delegatedForEnergyInSoliInFull " + delegatedForEnergyInSoliInFull); - //PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull,blockingStubSolidity); - account014 = PublicMethed.queryAccount(account014Address, blockingStubSolidity); - final long netUsageInSolidity = account014.getNetUsage(); - final long lastCustomeTimeInSolidity = account014.getLatestConsumeTime(); - final long acquiredForBandwidthInSolidity = account014 - .getAcquiredDelegatedFrozenBalanceForBandwidth(); - final long delegatedBandwidthInSolidity = account014.getDelegatedFrozenBalanceForBandwidth(); - final long acquiredForEnergyInSolidity = account014.getAccountResource() - .getAcquiredDelegatedFrozenBalanceForEnergy(); - final long delegatedForEnergyInSolidity = account014.getAccountResource() - .getDelegatedFrozenBalanceForEnergy(); - - logger.info("delegatedForEnergyInSolidity " + delegatedForEnergyInSolidity); - Assert.assertTrue(netUsageInSoliInFull > 0 && netUsageInSolidity > 0 - && netUsageInFullnode > 0); - Assert.assertTrue(netUsageInFullnode <= netUsageInSoliInFull + 5 - && netUsageInFullnode >= netUsageInSoliInFull - 5); - Assert.assertTrue(netUsageInFullnode <= netUsageInSolidity + 5 - && netUsageInFullnode >= netUsageInSolidity - 5); - Assert.assertTrue(acquiredForBandwidthInFullnode == acquiredForBandwidthInSoliInFull - && acquiredForBandwidthInFullnode == acquiredForBandwidthInSolidity); - Assert.assertTrue(delegatedBandwidthInFullnode == delegatedBandwidthInSoliInFull - && delegatedBandwidthInFullnode == delegatedBandwidthInSolidity); - Assert.assertTrue(acquiredForEnergyInFullnode == acquiredForEnergyInSoliInFull - && acquiredForEnergyInFullnode == acquiredForEnergyInSolidity); - Assert.assertTrue(delegatedForEnergyInFullnode == delegatedForEnergyInSoliInFull - && delegatedForEnergyInFullnode == delegatedForEnergyInSolidity); - Assert.assertTrue(acquiredForBandwidthInSoliInFull == 1000000 - && delegatedBandwidthInSoliInFull == 1000000 && acquiredForEnergyInSoliInFull == 1000000 - && delegatedForEnergyInSoliInFull == 1000000); - logger.info("lastCustomeTimeInSoliInFull " + lastCustomeTimeInSoliInFull); - Assert.assertTrue(lastCustomeTimeInFullnode == lastCustomeTimeInSolidity - && lastCustomeTimeInFullnode == lastCustomeTimeInSoliInFull); - logger.info("lastCustomeTimeInSoliInFull " + lastCustomeTimeInSoliInFull); - Assert.assertTrue(lastCustomeTimeInSoliInFull != 0); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestBlock001.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestBlock001.java deleted file mode 100644 index 310da233462..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestBlock001.java +++ /dev/null @@ -1,182 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; - -@Slf4j -public class WalletTestBlock001 { - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get now block from fullnode") - public void testCurrentBlock() { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(currentBlock.hasBlockHeader()); - Assert.assertFalse(currentBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getNumber() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("test getcurrentblock is " + Long.toString(currentBlock.getBlockHeader() - .getRawData().getNumber())); - - //Improve coverage. - currentBlock.equals(currentBlock); - Block newBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - newBlock.equals(currentBlock); - newBlock.hashCode(); - newBlock.getSerializedSize(); - newBlock.getTransactionsCount(); - newBlock.getTransactionsList(); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get now block from solidity") - public void testCurrentBlockFromSolidity() { - Block currentBlock = blockingStubSolidity - .getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(currentBlock.hasBlockHeader()); - Assert.assertFalse(currentBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getNumber() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("test getcurrentblock in soliditynode is " + Long.toString(currentBlock - .getBlockHeader().getRawData().getNumber())); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestBlock002.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestBlock002.java deleted file mode 100644 index e70dc71c78e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestBlock002.java +++ /dev/null @@ -1,248 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; - -@Slf4j -public class WalletTestBlock002 { - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "GetBlockByNum from fullnode") - public void testGetBlockByNum() { - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - if (currentBlockNum == 1) { - logger.info("Now has very little block, Please test this case by manual"); - Assert.assertTrue(currentBlockNum == 1); - } - - //The number is large than the currently number, there is no exception when query this number. - Long outOfCurrentBlockNum = currentBlockNum + 10000L; - NumberMessage.Builder builder1 = NumberMessage.newBuilder(); - builder1.setNum(outOfCurrentBlockNum); - Block outOfCurrentBlock = blockingStubFull.getBlockByNum(builder1.build()); - Assert.assertFalse(outOfCurrentBlock.hasBlockHeader()); - - //Query the first block. - NumberMessage.Builder builder2 = NumberMessage.newBuilder(); - builder2.setNum(1); - Block firstBlock = blockingStubFull.getBlockByNum(builder2.build()); - Assert.assertTrue(firstBlock.hasBlockHeader()); - Assert.assertFalse(firstBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getNumber() == 1); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - - //Query the second latest block. - NumberMessage.Builder builder3 = NumberMessage.newBuilder(); - builder3.setNum(currentBlockNum - 1); - Block lastSecondBlock = blockingStubFull.getBlockByNum(builder3.build()); - Assert.assertTrue(lastSecondBlock.hasBlockHeader()); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue( - lastSecondBlock.getBlockHeader().getRawData().getNumber() + 1 == currentBlockNum); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - } - - @Test(enabled = true, description = "GetBlockByNum from solidity") - public void testGetBlockByNumFromSolidity() { - Block currentBlock = blockingStubSolidity - .getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - if (currentBlockNum == 1) { - logger.info("Now has very little block, Please test this case by manual"); - Assert.assertTrue(currentBlockNum == 1); - } - - //The number is large than the currently number, there is no exception when query this number. - Long outOfCurrentBlockNum = currentBlockNum + 10000L; - NumberMessage.Builder builder1 = NumberMessage.newBuilder(); - builder1.setNum(outOfCurrentBlockNum); - Block outOfCurrentBlock = blockingStubSolidity.getBlockByNum(builder1.build()); - Assert.assertFalse(outOfCurrentBlock.hasBlockHeader()); - - //Query the first block. - NumberMessage.Builder builder2 = NumberMessage.newBuilder(); - builder2.setNum(1); - Block firstBlock = blockingStubSolidity.getBlockByNum(builder2.build()); - Assert.assertTrue(firstBlock.hasBlockHeader()); - Assert.assertFalse(firstBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getNumber() == 1); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("firstblock test from solidity succesfully"); - - //Query the second latest block. - NumberMessage.Builder builder3 = NumberMessage.newBuilder(); - builder3.setNum(currentBlockNum - 1); - Block lastSecondBlock = blockingStubSolidity.getBlockByNum(builder3.build()); - Assert.assertTrue(lastSecondBlock.hasBlockHeader()); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue( - lastSecondBlock.getBlockHeader().getRawData().getNumber() + 1 == currentBlockNum); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("Last second test from solidity succesfully"); - } - - @Test(enabled = true, description = "get block by id") - public void testGetBlockById() { - - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - ByteString currentHash = currentBlock.getBlockHeader().getRawData().getParentHash(); - GrpcAPI.BytesMessage request = GrpcAPI.BytesMessage.newBuilder().setValue(currentHash).build(); - Block setIdOfBlock = blockingStubFull.getBlockById(request); - Assert.assertTrue(setIdOfBlock.hasBlockHeader()); - Assert.assertFalse(setIdOfBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(setIdOfBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(setIdOfBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - logger.info(Long.toString(setIdOfBlock.getBlockHeader().getRawData().getNumber())); - logger.info(Long.toString(currentBlock.getBlockHeader().getRawData().getNumber())); - Assert.assertTrue( - setIdOfBlock.getBlockHeader().getRawData().getNumber() + 1 == currentBlock.getBlockHeader() - .getRawData().getNumber()); - Assert.assertFalse(setIdOfBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(setIdOfBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("By ID test succesfully"); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestMutiSign002.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestMutiSign002.java deleted file mode 100644 index cf05e1b9c8a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestMutiSign002.java +++ /dev/null @@ -1,467 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.ExchangeList; -import org.tron.api.GrpcAPI.PaginatedMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Exchange; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - - private static final long now = System.currentTimeMillis(); - private static String name1 = "exchange001_1_" + Long.toString(now); - private static String name2 = "exchange001_2_" + Long.toString(now); - private static final long totalSupply = 1000000001L; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] exchange001Address = ecKey1.getAddress(); - String exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] secondExchange001Address = ecKey2.getAddress(); - String secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - Long secondTransferAssetToFirstAccountNum = 100000000L; - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey3.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey4.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[3]; - String accountPermissionJson = ""; - - - Account firstAccount; - ByteString assetAccountId1; - ByteString assetAccountId2; - - Optional listExchange; - Optional exchangeIdInfo; - Integer exchangeId = 0; - Integer exchangeRate = 10; - Long firstTokenInitialBalance = 10000L; - Long secondTokenInitialBalance = firstTokenInitialBalance * exchangeRate; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "MutiSign for create token") - public void test1CreateUsedAsset() { - ecKey1 = new ECKey(Utils.getRandom()); - exchange001Address = ecKey1.getAddress(); - exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - secondExchange001Address = ecKey2.getAddress(); - secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(exchange001Key); - PublicMethed.printAddress(secondExchange001Key); - - Assert.assertTrue(PublicMethed.sendcoin(exchange001Address, 10240000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(secondExchange001Address, 10240000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(exchange001Address), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long start = System.currentTimeMillis() + 5000L; - Long end = System.currentTimeMillis() + 5000000L; - Assert.assertTrue(PublicMethed.createAssetIssue(exchange001Address, name1, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, exchange001Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.createAssetIssue(secondExchange001Address, name2, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, secondExchange001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "MutiSign for create exchange") - public void test2CreateExchange() { - ecKey3 = new ECKey(Utils.getRandom()); - manager1Address = ecKey3.getAddress(); - manager1Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ecKey4 = new ECKey(Utils.getRandom()); - manager2Address = ecKey4.getAddress(); - manager2Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = exchange001Key; - ownerKeyString[1] = manager1Key; - ownerKeyString[2] = manager2Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":3,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(exchange001Key) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate( - accountPermissionJson, exchange001Address, exchange001Key, - blockingStubFull, ownerKeyString); - - listExchange = PublicMethed.getExchangeList(blockingStubFull); - final Integer beforeCreateExchangeNum = listExchange.get().getExchangesCount(); - exchangeId = listExchange.get().getExchangesCount(); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - assetAccountId1 = getAssetIdFromThisAccount.getAssetIssuedID(); - - getAssetIdFromThisAccount = PublicMethed - .queryAccount(secondExchange001Address, blockingStubFull); - assetAccountId2 = getAssetIdFromThisAccount.getAssetIssuedID(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long token1BeforeBalance = 0L; - for (String name : firstAccount.getAssetMap().keySet()) { - token1BeforeBalance = firstAccount.getAssetMap().get(name); - } - Assert.assertTrue(PublicMethed.transferAsset(exchange001Address, assetAccountId2.toByteArray(), - secondTransferAssetToFirstAccountNum, secondExchange001Address, - secondExchange001Key, blockingStubFull)); - Long token2BeforeBalance = secondTransferAssetToFirstAccountNum; - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //logger.info("name1 is " + name1); - //logger.info("name2 is " + name2); - //logger.info("first balance is " + Long.toString(token1BeforeBalance)); - //logger.info("second balance is " + token2BeforeBalance.toString()); - //CreateExchange - Assert.assertTrue( - PublicMethedForMutiSign.exchangeCreate( - assetAccountId1.toByteArray(), firstTokenInitialBalance, - assetAccountId2.toByteArray(), secondTokenInitialBalance, exchange001Address, - exchange001Key, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - listExchange = PublicMethed.getExchangeList(blockingStubFull); - exchangeId = listExchange.get().getExchangesCount(); - - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - long needCoin = updateAccountPermissionFee + multiSignFee; - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1024_000_000L); - - } - - @Test(enabled = true, description = "List exchange after create exchange by MutiSign") - public void test3ListExchange() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - listExchange = PublicMethed.getExchangeList(blockingStubFull); - for (Integer i = 0; i < listExchange.get().getExchangesCount(); i++) { - Assert.assertFalse(ByteArray.toHexString(listExchange.get().getExchanges(i) - .getCreatorAddress().toByteArray()).isEmpty()); - Assert.assertTrue(listExchange.get().getExchanges(i).getExchangeId() > 0); - Assert.assertFalse(ByteArray.toStr(listExchange.get().getExchanges(i).getFirstTokenId() - .toByteArray()).isEmpty()); - Assert.assertTrue(listExchange.get().getExchanges(i).getFirstTokenBalance() > 0); - } - } - - @Test(enabled = true, description = "Mutisign for inject exchange") - public void test4InjectExchange() { - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer injectBalance = 100; - Assert.assertTrue( - PublicMethedForMutiSign.injectExchange( - exchangeId, assetAccountId1.toByteArray(), injectBalance, - exchange001Address, exchange001Key, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(beforeToken1Balance - afterToken1Balance == injectBalance); - Assert.assertTrue(beforeToken2Balance - afterToken2Balance == injectBalance - * exchangeRate); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == injectBalance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == injectBalance * exchangeRate); - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - long needCoin = multiSignFee; - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "MutiSign for withdraw exchange") - public void test5WithdrawExchange() { - - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer withdrawNum = 200; - Assert.assertTrue( - PublicMethedForMutiSign.exchangeWithdraw( - exchangeId, assetAccountId1.toByteArray(), withdrawNum, - exchange001Address, exchange001Key, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(afterToken1Balance - beforeToken1Balance == withdrawNum); - Assert.assertTrue(afterToken2Balance - beforeToken2Balance == withdrawNum - * exchangeRate); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == -withdrawNum); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == -withdrawNum * exchangeRate); - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - long needCoin = multiSignFee; - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "MutiSign for transaction exchange") - public void test6TransactionExchange() { - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("beforeExchangeToken1Balance" + beforeExchangeToken1Balance); - logger.info("beforeExchangeToken2Balance" + beforeExchangeToken2Balance); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer transactionNum = 50; - Assert.assertTrue( - PublicMethedForMutiSign - .exchangeTransaction(exchangeId, assetAccountId1.toByteArray(), transactionNum, 1, - exchange001Address, exchange001Key, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("afterExchangeToken1Balance" + afterExchangeToken1Balance); - logger.info("afterExchangeToken2Balance" + afterExchangeToken2Balance); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == beforeToken1Balance - afterToken1Balance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == beforeToken2Balance - afterToken2Balance); - - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - long needCoin = multiSignFee; - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - - @Test(enabled = true, description = "GetExchangeListPaginated after " - + "MutiSign exchange kind of transaction") - - public void test7GetExchangeListPaginated() { - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(0); - pageMessageBuilder.setLimit(100); - ExchangeList exchangeList = blockingStubFull - .getPaginatedExchangeList(pageMessageBuilder.build()); - Assert.assertTrue(exchangeList.getExchangesCount() >= 1); - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity); - - //Solidity support getExchangeId - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubSolidity); - logger.info("createtime is" + exchangeIdInfo.get().getCreateTime()); - Assert.assertTrue(exchangeIdInfo.get().getCreateTime() > 0); - - //Solidity support listexchange - listExchange = PublicMethed.getExchangeList(blockingStubSolidity); - Assert.assertTrue(listExchange.get().getExchangesCount() > 0); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, exchange001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestNode001.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestNode001.java deleted file mode 100644 index 40e60e06c2c..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestNode001.java +++ /dev/null @@ -1,112 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestNode001 { - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - } - - - @Test(enabled = true, description = "List all nodes") - public void testGetAllNode() { - GrpcAPI.NodeList nodeList = blockingStubFull - .listNodes(GrpcAPI.EmptyMessage.newBuilder().build()); - GrpcAPI.NodeList nodeList1 = blockingStubFull1 - .listNodes(GrpcAPI.EmptyMessage.newBuilder().build()); - Integer times = 0; - while (nodeList.getNodesCount() == 0 && times++ < 5) { - nodeList = blockingStubFull - .listNodes(GrpcAPI.EmptyMessage.newBuilder().build()); - nodeList1 = blockingStubFull1 - .listNodes(GrpcAPI.EmptyMessage.newBuilder().build()); - if (nodeList.getNodesCount() != 0 || nodeList1.getNodesCount() != 0) { - break; - } - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - //Assert.assertTrue(nodeList.getNodesCount() != 0 || nodeList1.getNodesCount() != 0); - - for (Integer j = 0; j < nodeList.getNodesCount(); j++) { - //Assert.assertTrue(nodeList.getNodes(j).hasAddress()); - //Assert.assertFalse(nodeList.getNodes(j).getAddress().getHost().isEmpty()); - //Assert.assertTrue(nodeList.getNodes(j).getAddress().getPort() < 65535); - //logger.info(ByteArray.toStr(nodeList.getNodes(j).getAddress().getHost().toByteArray())); - } - logger.info("get listnode succesuflly"); - - //Improve coverage. - GrpcAPI.NodeList newNodeList = blockingStubFull - .listNodes(GrpcAPI.EmptyMessage.newBuilder().build()); - nodeList.equals(nodeList); - nodeList.equals(newNodeList); - nodeList.getNodesList(); - nodeList.hashCode(); - nodeList.isInitialized(); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer002.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer002.java deleted file mode 100644 index e8e363b943b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer002.java +++ /dev/null @@ -1,215 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestTransfer002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false) - public void testGetTotalTransaction() { - NumberMessage beforeGetTotalTransaction = blockingStubFull - .totalTransaction(GrpcAPI.EmptyMessage.newBuilder().build()); - logger.info(Long.toString(beforeGetTotalTransaction.getNum())); - Long beforeTotalTransaction = beforeGetTotalTransaction.getNum(); - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - NumberMessage afterGetTotalTransaction = blockingStubFull - .totalTransaction(GrpcAPI.EmptyMessage.newBuilder().build()); - logger.info(Long.toString(afterGetTotalTransaction.getNum())); - Long afterTotalTransaction = afterGetTotalTransaction.getNum(); - Assert.assertTrue(afterTotalTransaction - beforeTotalTransaction > 0); - - //Improve coverage. - afterGetTotalTransaction.equals(beforeGetTotalTransaction); - afterGetTotalTransaction.equals(afterGetTotalTransaction); - afterGetTotalTransaction.hashCode(); - afterGetTotalTransaction.isInitialized(); - afterGetTotalTransaction.getSerializedSize(); - afterGetTotalTransaction.getDefaultInstanceForType(); - afterGetTotalTransaction.getParserForType(); - afterGetTotalTransaction.getUnknownFields(); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey) { - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer005.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer005.java deleted file mode 100644 index 5bd3871931f..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer005.java +++ /dev/null @@ -1,233 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountPaginated; - -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - - -@Slf4j -public class WalletTestTransfer005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private static final byte[] INVAILD_ADDRESS = - Base58.decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - - - } - - @Test(enabled = false) - public void testgetTransactionsFromThis() { - //Create a transfer. - //Assert.assertTrue(PublicMethed.sendcoin(toAddress,1000000,fromAddress, - // testKey002,blockingStubFull)); - - ByteString addressBs = ByteString.copyFrom(fromAddress); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionList transactionList = blockingStubExtension - .getTransactionsFromThis(accountPaginated.build()); - Optional gettransactionsfromthis = Optional - .ofNullable(transactionList); - - if (gettransactionsfromthis.get().getTransactionCount() == 0) { - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, - blockingStubSolidity)); - } - - Assert.assertTrue(gettransactionsfromthis.isPresent()); - Integer beforecount = gettransactionsfromthis.get().getTransactionCount(); - logger.info(Integer.toString(beforecount)); - for (Integer j = 0; j < beforecount; j++) { - Assert.assertFalse(gettransactionsfromthis.get().getTransaction(j) - .getRawData().getContractList().isEmpty()); - } - } - - @Test(enabled = false) - public void testgetTransactionsFromThisByInvaildAddress() { - //Invaild address. - ByteString addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionList transactionList = blockingStubExtension - .getTransactionsFromThis(accountPaginated.build()); - Optional gettransactionsfromthisByInvaildAddress = Optional - .ofNullable(transactionList); - - Assert.assertTrue(gettransactionsfromthisByInvaildAddress.get().getTransactionCount() == 0); - - //Limit is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(-1); - transactionList = blockingStubExtension - .getTransactionsFromThis(accountPaginated.build()); - gettransactionsfromthisByInvaildAddress = Optional - .ofNullable(transactionList); - - Assert.assertTrue(gettransactionsfromthisByInvaildAddress.get().getTransactionCount() == 0); - - //offset is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(-1); - accountPaginated.setLimit(100); - transactionList = blockingStubExtension - .getTransactionsFromThis(accountPaginated.build()); - gettransactionsfromthisByInvaildAddress = Optional - .ofNullable(transactionList); - - Assert.assertTrue(gettransactionsfromthisByInvaildAddress.get().getTransactionCount() == 0); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer006.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer006.java deleted file mode 100644 index 95f29545d37..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestTransfer006.java +++ /dev/null @@ -1,234 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountPaginated; - -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - - -@Slf4j -public class WalletTestTransfer006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private static final byte[] INVAILD_ADDRESS = - Base58.decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - - - } - - @Test(enabled = false) - public void testgetTransactionsToThis() { - //Create a transfer. - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - - ByteString addressBs = ByteString.copyFrom(toAddress); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionList transactionList = blockingStubExtension - .getTransactionsToThis(accountPaginated.build()); - - Optional gettransactionstothis = Optional - .ofNullable(transactionList); - - if (gettransactionstothis.get().getTransactionCount() == 0) { - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, - blockingStubSolidity)); - //logger.info("This account didn't transfation any coin to other"); - } - - Assert.assertTrue(gettransactionstothis.isPresent()); - Integer beforecount = gettransactionstothis.get().getTransactionCount(); - logger.info(Integer.toString(beforecount)); - for (Integer j = 0; j < beforecount; j++) { - Assert.assertFalse(gettransactionstothis.get().getTransaction(j) - .getRawData().getContractList().isEmpty()); - } - } - - @Test(enabled = false) - public void testgetTransactionsToThisByInvaildAddress() { - //Invaild address. - ByteString addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionList transactionList = blockingStubExtension - .getTransactionsToThis(accountPaginated.build()); - Optional gettransactionstothisByInvaildAddress = Optional - .ofNullable(transactionList); - - Assert.assertTrue(gettransactionstothisByInvaildAddress.get().getTransactionCount() == 0); - - //Limit is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(-1); - transactionList = blockingStubExtension - .getTransactionsToThis(accountPaginated.build()); - gettransactionstothisByInvaildAddress = Optional - .ofNullable(transactionList); - - Assert.assertTrue(gettransactionstothisByInvaildAddress.get().getTransactionCount() == 0); - - //offset is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(-1); - accountPaginated.setLimit(100); - transactionList = blockingStubExtension - .getTransactionsToThis(accountPaginated.build()); - gettransactionstothisByInvaildAddress = Optional - .ofNullable(transactionList); - - Assert.assertTrue(gettransactionstothisByInvaildAddress.get().getTransactionCount() == 0); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestWitness003.java b/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestWitness003.java deleted file mode 100644 index b4b4714372e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/manual/WalletTestWitness003.java +++ /dev/null @@ -1,330 +0,0 @@ -package stest.tron.wallet.dailybuild.manual; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.WitnessList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class WalletTestWitness003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final String testUpdateWitnessKey = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] updateAddress = PublicMethed.getFinalAddress(testUpdateWitnessKey); - private static final byte[] INVAILD_ADDRESS = Base58 - .decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - - private static final Long costForCreateWitness = 9999000000L; - String createWitnessUrl = "http://www.createwitnessurl.com"; - String updateWitnessUrl = "http://www.updatewitnessurl.com"; - String nullUrl = ""; - String spaceUrl = " ##################~!@#$%^&*()_+}{|:'/.,<>?|]=-"; - byte[] createUrl = createWitnessUrl.getBytes(); - byte[] updateUrl = updateWitnessUrl.getBytes(); - byte[] wrongUrl = nullUrl.getBytes(); - byte[] updateSpaceUrl = spaceUrl.getBytes(); - private static final String tooLongUrl = "qagwqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqas" - + "wqaswqasw1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazx" - + "swedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedc" - + "vqazxswedcvqazxswedcvqazxswedcvqazxswedcv"; - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - logger.info(lowBalTest); - logger.info(ByteArray.toHexString(PublicMethed.getFinalAddress(lowBalTest))); - logger.info(Base58.encode58Check(PublicMethed.getFinalAddress(lowBalTest))); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Invaild account to apply create witness") - public void testInvaildToApplyBecomeWitness() { - Assert.assertFalse(createWitnessNotBroadcast(INVAILD_ADDRESS, createUrl, testKey002)); - } - - @Test(enabled = true, description = "Create witness") - public void testCreateWitness() { - //If you are already is witness, apply failed - //createWitness(fromAddress, createUrl, testKey002); - //Assert.assertFalse(createWitness(fromAddress, createUrl, testKey002)); - - //No balance,try to create witness. - Assert.assertFalse(createWitnessNotBroadcast(lowBalAddress, createUrl, lowBalTest)); - - //Send enough coin to the apply account to make that account - // has ability to apply become witness. - GrpcAPI.WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - GrpcAPI.WitnessList witnessList = result.get(); - if (result.get().getWitnessesCount() < 6) { - Assert.assertTrue(PublicMethed - .sendcoin(lowBalAddress, costForCreateWitness, fromAddress, testKey002, - blockingStubFull)); - //null url, update failed - Assert.assertFalse(createWitnessNotBroadcast(lowBalAddress, wrongUrl, testUpdateWitnessKey)); - //too long url, update failed - Assert.assertFalse(createWitnessNotBroadcast(lowBalAddress, - tooLongUrl.getBytes(), testUpdateWitnessKey)); - Assert.assertTrue(createWitnessNotBroadcast(lowBalAddress, createUrl, lowBalTest)); - - } - } - - @Test(enabled = true, description = "Update witness") - public void testUpdateWitness() { - GrpcAPI.WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - GrpcAPI.WitnessList witnessList = result.get(); - if (result.get().getWitnessesCount() < 6) { - //null url, update failed - Assert.assertFalse(updateWitness(updateAddress, wrongUrl, testUpdateWitnessKey)); - //too long url, update failed - Assert.assertFalse(updateWitness(updateAddress, tooLongUrl.getBytes(), testUpdateWitnessKey)); - //Content space and special char, update success - Assert.assertTrue(updateWitness(updateAddress, updateSpaceUrl, testUpdateWitnessKey)); - //update success - Assert.assertTrue(updateWitness(updateAddress, updateUrl, testUpdateWitnessKey)); - } else { - logger.info("Update witness case had been test.This time skip it."); - } - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createWitnessNotBroadcast(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - return true; - } - - /** - * constructor. - */ - - public Boolean updateWitness(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessUpdateContract.Builder builder = Contract.WitnessUpdateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUpdateUrl(ByteString.copyFrom(url)); - Contract.WitnessUpdateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = PublicMethed.broadcastTransaction(transaction, blockingStubFull); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - logger.info("response.getRestult() == false"); - return false; - } else { - return true; - } - - } - - /** - * constructor. - */ - - public Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey) { - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Protocol.Transaction signTransaction(ECKey ecKey, Protocol.Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign01.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign01.java deleted file mode 100644 index e649e22b0d9..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign01.java +++ /dev/null @@ -1,823 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign01 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Owner permission_name is owner") - public void testOwnerName01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - ownerPermissionKeys.add(witnessKey001); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner permission_name is owner1") - public void testOwnerName02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + "\"permission_name\":\"owner1\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Owner permission_name is string \"123\"") - public void testOwnerName03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"123\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Owner permission_name is string \"\"") - public void testOwnerName04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner permission_name is null") - public void testOwnerName05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - // null - String accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":" + null - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Owner without permission_name") - public void testOwnerName06() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner permission_name is numbers") - public void testOwnerName07() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":123,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Owner permission_name length is 32") - public void testOwnerName08() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"0.1\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Owner permission_name length is 32") - public void testOwnerName09() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1000000, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0," - + "\"permission_name\":\"abcdefghijklmnopqrstuvwxyzabcdef\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - - @Test(enabled = true, description = "Owner permission_name length is 33") - public void testOwnerName10() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0," - + "\"permission_name\":\"abcdefghijklmnopqrstuvwxyzabcdefg\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's name is too long", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign02.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign02.java deleted file mode 100644 index d906bb1a7a3..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign02.java +++ /dev/null @@ -1,724 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign02 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Owner threshold in exception condition") - public void testOwnerThreshold01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - ownerPermissionKeys.add(ownerKey); - - // threshold = Integer.MIN_VALUE - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":-2147483648," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":0," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":-1," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = long.min - logger.info("** update owner and active permission to two address"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\":-9223372036854775808,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\":-9223372036855775828,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = long.min - 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\":-9223372036854775809,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = "12a" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\":\"12a\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\":\"\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\":,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\":" + null + ",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = 1.1 - accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 1.1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = Long.MAX_VALUE < sum(weight) - accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 9223372036854775807,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775807}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : long overflow", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Owner threshold is 1") - public void testOwnerThreshold02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner threshold is more than sum of keys' weight") - public void testOwnerThreshold03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // theshold = Long.MAX_VALUE > sum(weight) - String accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 9223372036854775807,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":214748364}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":214748364}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight should not" - + " be less than threshold in permission Owner", - response.getMessage().toStringUtf8()); - - // theshold = Integer.MAX_VALUE > sum(weight) - accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 2147483647,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":214748364}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":214748364}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight " - + "should not be less than threshold in permission Owner", - response.getMessage().toStringUtf8()); - - // theshold = Long.MAX_VALUE + 1 > sum(weight) - accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 9223372036854775808,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Owner threshold is Long.MAX_VALUE and equal sum(weight)") - public void testOwnerThreshold04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 9223372036854775807,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775806}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner threshold is Integer.MAX_VALUE") - public void testOwnerThreshold05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\"," - + "\"threshold\": 2147483647,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey02); - ownerPermissionKeys.add(witnessKey001); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(3, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign03.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign03.java deleted file mode 100644 index 33a0519db12..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign03.java +++ /dev/null @@ -1,563 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign03 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, testKey002, blockingStubFull); - } - - @Test(enabled = true, description = "Owner doesn't have parent_id") - public void testOwnerParent01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner parent_id in exception condition") - public void testOwnerParent02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // parent_id = "123" - String accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":\"123\",\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 123 - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":123,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = "abc" - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":\"abc\",\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("Expected NumberFormatException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = "" - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":\"\",\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = null - - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":" + null + ",\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = 1 - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":1,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 2 - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":2,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 3 - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":3,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = -1 - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":3,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":2147483647,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MAX_VALUE +1 - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":2147483648,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MIN_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":-2147483648,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MIN_VALUE -1 - accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":-2147483649,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Owner parent_id is 0") - public void testOwnerParent03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"parent_id\":0,\"type\":0," - + "\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign04.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign04.java deleted file mode 100644 index 5d5936f982b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign04.java +++ /dev/null @@ -1,630 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign04 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, testKey002, blockingStubFull); - } - - @Test(enabled = true, description = "Owner weight in exception condition") - public void testOwnerWeight01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - - // weight = Integer.MIN_VALUE - String accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":-2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = 0 - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":0}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":0}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = -1 - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":-1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = long.min - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":-9223372036854775808}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = long.min - 1000020 - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":-9223372036855775828}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = "12a" - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":\"12a\"}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = "" - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":\"\"}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = null - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":" + null + "}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // sum(weight) > Long.MAX_VALUE - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775807}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : long overflow", - response.getMessage().toStringUtf8()); - - // weight = 1.1 - accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1.1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Owner weight is 1") - public void testOwnerWeight02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner weight is Integer.MAX_VALUE") - public void testOwnerWeight03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":2147483648,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey02); - ownerPermissionKeys.add(witnessKey001); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(3, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner weight is Long.MAX_VALUE") - public void testOwnerWeight04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775807}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign05.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign05.java deleted file mode 100644 index f225cabff20..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign05.java +++ /dev/null @@ -1,826 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign05 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String contractTronDiceAddr = "TMYcx6eoRXnePKT1jVn25ZNeMNJ6828HWk"; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, testKey002, blockingStubFull); - } - - @Test(enabled = true, description = "Owner key-address is witness account") - public void testOwnerKeyAddress01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(witnessKey001); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - - @Test(enabled = true, description = "Owner key-address is contract address") - public void testOwnerKeyAddress02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + contractTronDiceAddr + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":2}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner key-address is inactive address") - public void testOwnerKeyAddress03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey01); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner key-address is owner address") - public void testOwnerKeyAddress04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Owner key-address in exception condition") - public void testOwnerKeyAddress05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // address = owner_address more than once - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : address should be distinct " - + "in permission Owner", - response.getMessage().toStringUtf8()); - - // address = not exist - String fakeAddress = "THph9K2M2nLvkianrMGswRhz5hjSA9fuH1"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // address = long address - fakeAddress = "TR3FAbhiSeP7kSh39RjGYpwCqfMDHPMhX4d121"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // address = short address - fakeAddress = "THph9K2M2nLvkianrMGswRhz5hj"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // address = - fakeAddress = ""; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":5}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException!"); - ret = true; - } - - Assert.assertTrue(ret); - - // address = null - - fakeAddress = null; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + fakeAddress - + "\",\"weight\":5}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException!"); - ret = true; - } - - Assert.assertTrue(ret); - - // address = "1.1" - fakeAddress = "1.1"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + fakeAddress - + "\",\"weight\":5}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (IllegalArgumentException e) { - logger.info("IllegalArgumentException!"); - ret = true; - } - - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Owner key-address count is 5") - public void testOwnerKeyAddress06() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(5, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - ownerPermissionKeys.add(testKey002); - ownerPermissionKeys.add(witnessKey001); - ownerPermissionKeys.add(tmpKey01); - ownerPermissionKeys.add(tmpKey02); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner key-address count in exception condition") - public void testOwnerKeyAddress07() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // address count = 6 - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + contractTronDiceAddr + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : number of keys in permission should" - + " not be greater than 5", - response.getMessage().toStringUtf8()); - - // address count = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5," - + "\"keys\":[]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's count should be greater than 0", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Owner key-address count is 1") - public void testOwnerKeyAddress08() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":5}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(witnessKey001); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign06.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign06.java deleted file mode 100644 index e980d277010..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign06.java +++ /dev/null @@ -1,693 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign06 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, testKey002, blockingStubFull); - } - - @Test(enabled = true, description = "Owner type in exception condition") - public void testOwnerType01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - // type = 1 - String accountPermissionJson = - "{\"owner_permission\":{\"type\":1,\"permission_name\":\"owner\",\"threshold\":1," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - - // type = 2 - accountPermissionJson = - "{\"owner_permission\":{\"type\":2,\"permission_name\":\"owner\",\"threshold\":1," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - - // type = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":-1,\"permission_name\":\"owner\",\"threshold\":1," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":-9223372036855775828,\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - - // type = "12a" - accountPermissionJson = - "{\"owner_permission\":{\"type\":\"12a\",\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException: For input string: \"12a\""); - ret = true; - } - Assert.assertTrue(ret); - - // type = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":\"\",\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = - accountPermissionJson = - "{\"owner_permission\":{\"type\":,\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":" + null + ",\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - // type = Integer.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":2147483647,\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - - // type = Long.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":9223372036854775807,\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":-9223372036854775809,\"permission_name\":\"owner\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - - // type = Long.MAX_VALUE + 10 - accountPermissionJson = "{\"owner_permission\":{\"type\":9223372036854775817," - + "\"permission_name\":\"owner\",\"threshold\": 1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission type is error", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Owner type is 0") - public void testOwnerType02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - - @Test(enabled = true, description = "Owner type is Long.Min") - public void testOwnerType03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":-9223372036854775808,\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Owner type is Long.MAX_VALUE + 1") - public void testOwnerType04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":9223372036854775808,\"permission_name\":\"Owner\"," - + "\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - - @Test(enabled = true, description = "Owner type is 0.1") - public void testOwnerType05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0.1," - + "\"permission_name\":\"owner\",\"threshold\": 1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign07.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign07.java deleted file mode 100644 index 7d3dcd6b86f..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign07.java +++ /dev/null @@ -1,726 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign07 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Owner permission_name is owner") - public void testActiveName01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"owner\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - } - - @Test(enabled = true, description = "Owner permission_name is active") - public void testActiveName02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - } - - @Test(enabled = true, description = "Owner permission_name is activea") - public void testActiveName03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"activea\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Owner permission_name is \"123\"") - public void testActiveName04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"123\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Owner permission_name is \"\"") - public void testActiveName05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Owner permission_name in exception condition") - public void testActiveName06() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" + null - + ",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - GrpcAPI.Return response = PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // name = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":,\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("Expected com.alibaba.fastjson.JSONException!"); - ret = true; - } - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Owner permission_name is 1.1") - public void testActiveName07() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":1.1,\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active permission_name length is 32") - public void testActiveName08() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1000000, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2," - + "\"permission_name\":\"abcdefghijklmnopqrstuvwxyzabcdef\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - - @Test(enabled = true, description = "Active permission_name length is 33") - public void testActiveName09() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0," - + "\"permission_name\":\"owner001\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2," - + "\"permission_name\":\"abcdefghijklmnopqrstuvwxyzabcdefg\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's name is too long", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign08.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign08.java deleted file mode 100644 index 0c5b748e62f..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign08.java +++ /dev/null @@ -1,730 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign08 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Active threshold is exception condition") - public void testActiveTheshold01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // threshold = Integer.Max_Value - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":-2147483648," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":0," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":-1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = long.min - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":-9223372036854775808," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // threshold = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":-9223372036855775828," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = long.min - 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":-9223372036854775809," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = "12a" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":\"-12a\"," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException : -12a !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":\"\"," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":" + null + "," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = 1.9 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1.9," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":21}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // threshold = Long.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":9223372036854775807," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775807}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : long overflow", - response.getMessage().toStringUtf8()); - - // theshold = 1.1 < sum(weight) - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1.1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Active threshold is 1") - public void testActiveTheshold02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active threshold is more than sum of weight") - public void testActiveTheshold03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // threshold = Integer.MAX_VALUE *2 + 5 > sum(weight) - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":4294967299," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight should not" - + " be less than threshold in permission Active", - response.getMessage().toStringUtf8()); - - // threshold = Integer.MAX_VALUE > sum(weight) - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":2147483647," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight " - + "should not be less than threshold in permission Active", - response.getMessage().toStringUtf8()); - - // theshold = Long.MAX_VALUE + 1 > sum(weight) - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":9223372036854775808," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Active threshold is Long.MAX_VALUE") - public void testActiveTheshold04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":9223372036854775807," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active threshold is Integer.MAX_VALUE") - public void testActiveTheshold05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey01); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":2147483647," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2147483646}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2147483647}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign09.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign09.java deleted file mode 100644 index 6b1ea799a15..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign09.java +++ /dev/null @@ -1,536 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign09 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Active doesn't have parent_id") - public void testActiveParent01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":4," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Active parent_id is exception condition") - public void testActiveParent02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // parent_id = "123" - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":\"123\",\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 123 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":123,\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = "abc" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":\"abc\",\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("Expected NumberFormatException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":\"\",\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":" + null - + ",\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":1,\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 2 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":2,\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 3 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":3,\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":-1,\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":2147483647,\"type\":2," - + "\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MAX_VALUE +1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":2147483648,\"type\":2," - + "\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MIN_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":-2147483648,\"type\":2," - + "\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MIN_VALUE -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":-2147483649,\"type\":2," - + "\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Active parent_id is 0") - public void testActiveParent03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}]}," - + "\"active_permissions\":[" - + "{\"parent_id\":0,\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign10.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign10.java deleted file mode 100644 index c968d458b25..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign10.java +++ /dev/null @@ -1,659 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign10 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Active weight is exception condition") - public void testActiveWeight01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // weight = Integer.MIN_VALUE - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-2147483648}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":0}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":-1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = long.min - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-9223372036854775808}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-9223372036855775828}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = "12a" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":\"12a\"}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":\"\"}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-9223372036855775828}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":" - + null + "}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = Long.MIN -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":-9223372036854775809}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = 1.1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1.1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Active weight is 1") - public void testActiveWeight02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(3, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(3, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active weight is Integer.MAX_VALUE") - public void testActiveWeight03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":21474836471}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":21474836471}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey02); - ownerPermissionKeys.add(witnessKey001); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(3, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active sum of weight is more than Long.MAX_VALUE") - public void testActiveWeight04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2147483647}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775807}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : long overflow", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Active weight is Long.MAX_VALUE") - public void testActiveWeight05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775807}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign11.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign11.java deleted file mode 100644 index cebd76e5509..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign11.java +++ /dev/null @@ -1,1176 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign11 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String contractTronDiceAddr = "TMYcx6eoRXnePKT1jVn25ZNeMNJ6828HWk"; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Active address is witness") - public void testActiveAddress01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":4," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(witnessKey001); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active address is contract address") - public void testActiveAddress02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + contractTronDiceAddr + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + contractTronDiceAddr + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(3, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active address is inactive address") - public void testActiveAddress03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":5," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":3}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(tmpKey01); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active address is owner address") - public void testActiveAddress04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active address is exception condition") - public void testActiveAddress05() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // address = same address more than once - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : address should be distinct" - + " in permission Active", - response.getMessage().toStringUtf8()); - - // address = not exist - String fakeAddress = "THph9K2M2nLvkianrMGswRhz5hjSA9fuH1"; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // address = long address - fakeAddress = "TR3FAbhiSeP7kSh39RjGYpwCqfMDHPMhX4d121"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // address = short address - fakeAddress = "THph9K2M2nLvkianrMGswRhz5hj"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // address = - fakeAddress = ""; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException!"); - ret = true; - } - - Assert.assertTrue(ret); - - // address = null - fakeAddress = null; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException!"); - ret = true; - } - - Assert.assertTrue(ret); - - // address = null - fakeAddress = "1.1"; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - } catch (IllegalArgumentException e) { - logger.info("IllegalArgumentException!"); - ret = true; - } - Assert.assertTrue(ret); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - - } - - @Test(enabled = true, description = "Active address count is 5") - public void testActiveAddress06() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey01); - activePermissionKeys.add(tmpKey02); - activePermissionKeys.add(testKey002); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"" - + ",\"threshold\":10," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(5, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - ownerPermissionKeys.add(tmpKey01); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - - } - - @Test(enabled = true, description = "Active address count is more than 5") - public void testActiveAddress07() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + contractTronDiceAddr + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : number of keys in permission should" - + " not be greater than 5", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Active address count is 0") - public void testActiveAddress08() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's count should be greater than 0", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Active address count is 1") - public void testActiveAddress09() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey01); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - ownerPermissionKeys.add(witnessKey001); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active permission count is 8") - public void testActiveAddress10() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey01); - activePermissionKeys.add(tmpKey02); - activePermissionKeys.add(testKey002); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[" - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active1\",\"threshold\":5," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active2\",\"threshold\":7," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active3\",\"threshold\":9," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active4\",\"threshold\":10," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active5\",\"threshold\":11," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active6\",\"threshold\":10," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active7\",\"threshold\":11," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(40, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - ownerPermissionKeys.add(tmpKey01); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 9, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Active permission count is 9") - public void testActiveAddress11() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[" - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active1\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active2\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active3\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active4\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active5\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active6\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active7\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active8\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission is too many", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Active permission count is 8, " - + "sum of weight is less than threshold") - public void testActiveAddress12() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[" - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active1\",\"threshold\":9223372036854775807," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active2\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active3\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active4\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active5\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active6\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}," - + "{\"type\":2,\"permission_name\":\"active7\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":3}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight should" - + " not be less than threshold in permission Active", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign12.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign12.java deleted file mode 100644 index e1730c35dfb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign12.java +++ /dev/null @@ -1,507 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign12 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Active type is exception condition") - public void testActiveType01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // type = Integer.MIN_VALUE - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":-2147483648,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":0,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":-1,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":-9223372036854775808," - + "\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":-9223372036855775828," - + "\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":-9223372036854775809," - + "\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = "12a" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":\"12a\",\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":\"\",\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":" + null + ",\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":1,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = Long.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":9223372036854775807," - + "\"permission_name\":\"active0\"," - + "\"threshold\":9223372036854775807," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = Long.MAX_VALUE + 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":9223372036854775808," - + "\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - // type = 1.1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":1.1,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":9223372036854775806}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission type is error", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Active type is 2.9") - public void testActiveType02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - long needCoin = updateAccountPermissionFee; - - PublicMethed - .sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(tmpKey02); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2.9,\"permission_name\":\"active0\"," - + "\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":21}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign13.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign13.java deleted file mode 100644 index 291e9a8d2c3..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign13.java +++ /dev/null @@ -1,853 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign13 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Witness permission_name is witness") - public void testWitnessName01() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed - .sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness permission_name is witness12") - public void testWitnessName02() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000L, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness permission_name is \"123\"") - public void testWitnessName03() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"123\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness permission_name is \"\"") - public void testWitnessName04() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness permission_name is null") - public void testWitnessName05() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":" + null - + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - GrpcAPI.Return response = PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness doesn't have permission_name") - public void testWitnessName06() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness permission_name is 123") - public void testWitnessName07() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"permission_name\":123,\"type\":1," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness permission_name is 0.1") - public void testWitnessName08() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"permission_name\":\"0.1\",\"type\":1," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness permission_name length is 32") - public void testWitnessName09() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":" - + "{\"permission_name\":\"abcdefghijklmnopqrstuvwxyzabcdef\",\"type\":1," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - - @Test(enabled = true, description = "Witness permission_name length is 33") - public void testWitnessName10() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":" - + "{\"permission_name\":\"abcdefghijklmnopqrstuvwxyzabcdefg\",\"type\":1," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's name is too long", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign14.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign14.java deleted file mode 100644 index 4c20e07185d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign14.java +++ /dev/null @@ -1,698 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign14 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Witness threshold is exception condition") - public void testWitnessThreshold01() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // theshold = Integer.MIN_VALUE - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":-2147483648,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // theshold = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":0,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // theshold = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":-1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // theshold = long.min - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":-9223372036854775808,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's" - + " threshold should be greater than 0", - response.getMessage().toStringUtf8()); - - // theshold = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":-9223372036855775828,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = long.min - 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":-9223372036854775809,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = "12a" - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":\"12a\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":\"\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":" + null + ",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = Long.MAX_VALUE < sum(weight) - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":9223372036854775807,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775806}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight should not be" - + " less than threshold in permission Witness", - response.getMessage().toStringUtf8()); - - // theshold = Long.MAX_VALUE + 1 > sum(weight) - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":9223372036854775808,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775806}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // theshold = 1.1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1.1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775806}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - Assert.assertTrue(PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - - } - - @Test(enabled = true, description = "Witness threshold is 1") - public void testWitnessThreshold02() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness threshold is more than sum of weight") - public void testWitnessThreshold03() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // threshold > sum(weight) - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":4294967299,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":214748364}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight should not be" - + " less than threshold in permission Witness", - response.getMessage().toStringUtf8()); - - // threshold = Integer.MAX_VALUE > sum(weight) - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":2147483647,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":214748364}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : sum of all key's weight " - + "should not be less than threshold in permission Witness", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness threshold is Long.MAX_VALUE") - public void testWitnessThreshold04() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":9223372036854775807,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775807}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign15.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign15.java deleted file mode 100644 index 133a9ad7ea9..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign15.java +++ /dev/null @@ -1,604 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign15 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, testKey002, blockingStubFull); - } - - @Test(enabled = true, description = "Witness doesn't have parent_id") - public void testWitnessParent01() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness parent_id is exception condition") - public void testWitnessParent02() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // parent_id = "123" - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":\"123\",\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 123 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":123,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = "abc" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":\"abc\",\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("Expected NumberFormatException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":\"\",\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":" + null + ",\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // parent_id = 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":1,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 2 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":2,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = 3 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":3,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":-1,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":2147483647,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MAX_VALUE +1 - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":2147483648,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MIN_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":-2147483648,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - - // parent_id = Integer.MIN_VALUE -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":-2147483649,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : permission's parent should be owner", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness parent_id is 0") - public void testWitnessParent03() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"parent_id\":0,\"type\":1," - + "\"permission_name\":\"witness\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign16.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign16.java deleted file mode 100644 index 95507fa4d4e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign16.java +++ /dev/null @@ -1,625 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign16 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Witness weight is exception condition") - public void testWitnessWeight01() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // weight = Integer.MIN_VALUE - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":0}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = long.min - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-9223372036854775808}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's weight" - + " should be greater than 0", - response.getMessage().toStringUtf8()); - - // weight = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":-9223372036855775828}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = "12a" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":\"12a\"}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":\"\"}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":" + null + "}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // Long.MAX_VALUE + 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775808}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - // weight = 1.1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1.1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - Assert.assertTrue(PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - - } - - @Test(enabled = true, description = "Witness weight is 1") - public void testWitnessWeight02() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness weight is Integer.MAX_VALUE") - public void testWitnessWeight03() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":2147483647}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness weight is Long.MAX_VALUE") - public void testWitnessWeight04() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":9223372036854775807,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":9223372036854775807}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign17.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign17.java deleted file mode 100644 index 78d6bdc4628..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign17.java +++ /dev/null @@ -1,739 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign17 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private final String contractTronDiceAddr = "TMYcx6eoRXnePKT1jVn25ZNeMNJ6828HWk"; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Witness address is witness") - public void testWitnessAddress01() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness address is contract") - public void testWitnessAddress02() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + contractTronDiceAddr + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness address is inactive address") - public void testWitnessAddress03() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness address is owner_address") - public void testWitnessAddress04() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness address is exception condition") - public void testWitnessAddress05() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // address = owner_address more than once - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : Witness permission's key count should be 1", - response.getMessage().toStringUtf8()); - - // address = not exist - String fakeAddress = "THph9K2M2nLvkianrMGswRhz5hjSA9fuH1"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // address = long address - fakeAddress = "TR3FAbhiSeP7kSh39RjGYpwCqfMDHPMhX4d121"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // address = short address - fakeAddress = "THph9K2M2nLvkianrMGswRhz5hj"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed - .accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - // address = - fakeAddress = ""; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException!"); - ret = true; - } - - Assert.assertTrue(ret); - - // address = null - fakeAddress = null; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException!"); - ret = true; - } - - Assert.assertTrue(ret); - - // address = "1.1" - fakeAddress = "1.1"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + fakeAddress + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (IllegalArgumentException e) { - logger.info("IllegalArgumentException!"); - ret = true; - } - - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness address account is 5") - public void testWitnessAddress06() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : Witness permission's key count should be 1", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Witness address account is 0") - public void testWitnessAddress07() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness12\"," - + "\"threshold\":1,\"keys\":[]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : key's count should be greater than 0", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign18.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign18.java deleted file mode 100644 index 5b8d97cea6b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign18.java +++ /dev/null @@ -1,616 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign18 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Witness type is 1") - public void testWitnessType01() { - // type = 1 - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness type is exception condition") - public void testWitnessType02() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // type = 2 - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":2,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = 0 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":0,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = -1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":-1,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":-9223372036854775808,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - 1000020 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":-9223372036855775828,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = "12a" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":\"12a\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException: For input string: \"12a\""); - ret = true; - } - Assert.assertTrue(ret); - - // type = "" - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":\"\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = null - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":" + null + ",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // type = Integer.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":2147483647,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = Long.MAX_VALUE - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":9223372036854775807,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.MAX_VALUE + 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":9223372036854775808,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = long.min - 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":-9223372036854775809,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - - // type = Long.MAX_VALUE + 1 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":9223372036854775808,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission type is error", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore, balanceAfter); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Witness type is 1.5") - public void testWitnessType03() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1.5,\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign19.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign19.java deleted file mode 100644 index 74541d71c6a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign19.java +++ /dev/null @@ -1,658 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign19 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - public static final String DEFAULT_OPERATION = - "7fff1fc0033e0000000000000000000000000000000000000000000000000000"; - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Active operation is ContractType.TransferContract_VALUE") - public void testActiveOperations01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - List activePermissionKeys2 = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - activePermissionKeys2.add(witnessKey001); - - Integer[] ints = {ContractType.TransferContract_VALUE}; - String operationsTransfer = PublicMethedForMutiSign.getOperations(ints); - Integer[] ints2 = {ContractType.TransferAssetContract_VALUE}; - String operationsTransferAsset = PublicMethedForMutiSign.getOperations(ints2); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operationsTransfer + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operationsTransferAsset + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "]}]}"; - - Assert.assertTrue( - PublicMethedForMutiSign.accountPermissionUpdateWithPermissionId(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, 0, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign - .getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Assert.assertFalse(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 3, ownerKey, - blockingStubFull, - activePermissionKeys2.toArray(new String[activePermissionKeys2.size()]))); - - Assert.assertFalse(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys2.toArray(new String[activePermissionKeys2.size()]))); - - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - - } - - @Test(enabled = true, description = "Active operation is" - + " 0000000000000000000000000000000000000000000000000000000000000000") - public void testActiveOperations02() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(testKey002); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"0000000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue( - PublicMethedForMutiSign.accountPermissionUpdateWithPermissionId(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, 0, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(1, PublicMethedForMutiSign - .getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - Assert.assertFalse(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Active operation include invalid contract") - public void testActiveOperations03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - // operation include invalid 99 contract - Integer[] ints = {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 31, - 32, 33, 41, 42, 43, 44, 45, 99}; - String operations = PublicMethedForMutiSign.getOperations(ints); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : 99 isn't a validate ContractType", - response.getMessage().toStringUtf8()); - - // operation's length is less then 64, - // 63: 7fff1fc0033e000000000000000000000000000000000000000000000000000 - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : 21 isn't a validate ContractType", - response.getMessage().toStringUtf8()); - - // operation's length is less then 64, - // 62: 7fff1fc0033e00000000000000000000000000000000000000000000000000 - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e00000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : operations size must 32", - response.getMessage().toStringUtf8()); - - // operation's length is more then 64, - // 65: 7fff1fc0033e00000000000000000000000000000000000000000000000000000 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":" - + "\"7fff1fc0033e00000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : operations size must 32", - response.getMessage().toStringUtf8()); - - // operation's length is more then 64, - // 66: 7fff1fc0033e00000000000000000000000000000000000000000000000000000 - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":" - + "\"7fff1fc0033e000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : operations size must 32", - response.getMessage().toStringUtf8()); - - // oprations = "12aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - // same result 12eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee - - operations = "12aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : 21 isn't a validate ContractType", - response.getMessage().toStringUtf8()); - - // operation = "" - - operations = ""; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : operations size must 32", - response.getMessage().toStringUtf8()); - - // Operation = - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - // Operation = null - operations = null; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (org.spongycastle.util.encoders.DecoderException e) { - logger.info("org.spongycastle.util.encoders.DecoderException !"); - ret = true; - } - Assert.assertTrue(ret); - - // no Operation - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : operations size must 32", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Owner sets operation") - public void testActiveOperations04() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1," - + "\"operations\":\"" + DEFAULT_OPERATION + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + DEFAULT_OPERATION + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : Owner permission needn't operations", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Witness sets operation") - public void testActiveOperations05() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":3}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"owner\",\"threshold\":1," - + "\"operations\":\"" + DEFAULT_OPERATION + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + DEFAULT_OPERATION + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : Witness permission needn't operations", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign20.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign20.java deleted file mode 100644 index 99531901a59..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign20.java +++ /dev/null @@ -1,542 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign20 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private final String contractTronDiceAddr = "TMYcx6eoRXnePKT1jVn25ZNeMNJ6828HWk"; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Owner address is witness") - public void testOwnerAddress01() { - // address = witness - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"owner\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Owner address is witness with exception condition") - public void testOwnerAddress02() { - // address = witness, without witness permission - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - PublicMethed.sendcoin(ownerAddress, 1_000000, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : witness permission is missed", - response.getMessage().toStringUtf8()); - - // address = witness, without active permission - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission is missed", - response.getMessage().toStringUtf8()); - - // address = witness, without owner permission - accountPermissionJson = - "{\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission is missed", - response.getMessage().toStringUtf8()); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - @Test(enabled = true, description = "Owner address is normal address with exception condition") - public void testOwnerAddress03() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - - // address = normal address, with witness permission - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"witness\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : account isn't witness can't set" - + " witness permission", - response.getMessage().toStringUtf8()); - - // address = normal address, without owner permission - accountPermissionJson = - "{\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : owner permission is missed", - response.getMessage().toStringUtf8()); - - // address = normal address, without active permission - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission is missed", - response.getMessage().toStringUtf8()); - - // address = contract address - byte[] ownerAddress02 = contractTronDiceAddr.getBytes(); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress02, ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : invalidate ownerAddress", - response.getMessage().toStringUtf8()); - - // address = not active address - ECKey ecKeyTmp = new ECKey(Utils.getRandom()); - final byte[] ownerAddressTmp = ecKeyTmp.getAddress(); - final String ownerKeyTmp = ByteArray.toHexString(ecKeyTmp.getPrivKeyBytes()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddressTmp, ownerKeyTmp, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : ownerAddress account does not exist", - response.getMessage().toStringUtf8()); - - // address = not exist - String fakeAddress = "THph9K2M2nLvkianrMGswRhz5hjSA9fuH1"; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : invalidate ownerAddress", - response.getMessage().toStringUtf8()); - - // address = long address - fakeAddress = "TR3FAbhiSeP7kSh39RjGYpwCqfMDHPMhX4d121"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : invalidate ownerAddress", - response.getMessage().toStringUtf8()); - - // address = short address - - fakeAddress = "THph9K2M2nLvkianrMGswRhz5hj"; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : invalidate ownerAddress", - response.getMessage().toStringUtf8()); - - // address = - fakeAddress = ""; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : invalidate ownerAddress", - response.getMessage().toStringUtf8()); - - // address = null - fakeAddress = null; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - - // address = "1ab(*c" - fakeAddress = "1ab(*c"; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - response = PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, fakeAddress.getBytes(), ownerKey, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : invalidate ownerAddress", - response.getMessage().toStringUtf8()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign21.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign21.java deleted file mode 100644 index 83acb60361e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign21.java +++ /dev/null @@ -1,227 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign21 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Permission Count is in exception condition") - public void testPermissionCount01() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - - // count = 1 - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}}"; - - GrpcAPI.Return response = PublicMethed.accountPermissionUpdateForResponse(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull); - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : active permission is missed", - response.getMessage().toStringUtf8()); - - // count = 0 - accountPermissionJson = "[]"; - - boolean ret = false; - try { - PublicMethed.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull); - } catch (com.alibaba.fastjson.JSONException e) { - logger.info("com.alibaba.fastjson.JSONException !"); - ret = true; - } - Assert.assertTrue(ret); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Permission Count is 4") - public void testPermissionCount02() { - String ownerKey = witnessKey001; - byte[] ownerAddress = new WalletClient(ownerKey).getAddress(); - long needCoin = updateAccountPermissionFee * 2; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"owner\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"owner\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey01) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getWitnessPermission())); - - PublicMethedForMutiSign - .recoverWitnessPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign22.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign22.java deleted file mode 100644 index a97c8ba8303..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign22.java +++ /dev/null @@ -1,813 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.tron.api.GrpcAPI.Return.response_code.SIGERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign22 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Sign permission transaction by owner permission") - public void test01SignByOwnerKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - List ownerPermissionKeys = new ArrayList<>(); - PublicMethed.printAddress(ownerKey); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - ownerPermissionKeys.add(ownerKey); - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - ownerPermissionKeys.add(testKey002); - - Assert.assertTrue( - PublicMethedForMutiSign.accountPermissionUpdateWithPermissionId(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, 0, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - - @Test(enabled = true, description = "Sign normal transaction by owner permission") - public void test02SignByOwnerKeyForNormal() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - PublicMethed.printAddress(ownerKey); - - logger.info("** update owner permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - ownerPermissionKeys.add(ownerKey); - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - ownerPermissionKeys.add(testKey002); - - logger.info("** trigger a normal permission"); - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 0, ownerKey, - blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1_000000); - } - - - @Test(enabled = true, description = "Sign normal transaction by active permission") - public void test03SignByActiveKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - - List activePermissionKeys = new ArrayList<>(); - List ownerPermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(testKey002); - activePermissionKeys.add(normalKey001); - - logger.info("** update active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(normalKey001) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** update owner permission to two address"); - logger.info("** trigger a normal permission"); - Assert.assertFalse(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 0, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Assert.assertTrue(PublicMethedForMutiSign - .sendcoinWithPermissionId(fromAddress, 1_000000, ownerAddress, 2, ownerKey, - blockingStubFull, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - } - - - @Test(enabled = true, description = "Sign permission transaction by active permission") - public void test04SignByActiveKeyForPermission() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - Integer[] ints = {ContractType.AccountPermissionUpdateContract_VALUE}; - final String operations = PublicMethedForMutiSign.getOperations(ints); - - PublicMethed.printAddress(ownerKey); - - List activePermissionKeys = new ArrayList<>(); - List ownerPermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(testKey002); - activePermissionKeys.add(normalKey001); - - logger.info("** update active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(normalKey001) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue( - PublicMethedForMutiSign.accountPermissionUpdateWithPermissionId(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, 2, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - - @Test(enabled = true, description = "Sign permission transaction " - + "by default operation active permission") - public void test05SignByActiveKeyWithDefaultOperation() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - - List activePermissionKeys = new ArrayList<>(); - List ownerPermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(testKey002); - activePermissionKeys.add(normalKey001); - - logger.info("** update active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(normalKey001) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - Assert.assertFalse(PublicMethedForMutiSign.accountPermissionUpdateWithPermissionId( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, 2, - activePermissionKeys.toArray(new String[activePermissionKeys.size()]))); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - - @Test(enabled = true, description = "Sign permission transaction" - + " by address which is out of permission list") - public void test06SignByOtherKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - PublicMethed.printAddress(ownerKey); - - logger.info("** update active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - ownerPermissionKeys.add(normalKey001); - GrpcAPI.Return response = PublicMethedForMutiSign.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(SIGERROR, response.getCode()); - Assert.assertThat(response.getMessage().toStringUtf8(), - containsString("it is not contained of permission")); - - Assert.assertEquals(1, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Sign permission transaction " - + "by empty permission list") - public void test07SignByEmptyObjectKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - String[] ownerPermissionKeys = new String[0]; - PublicMethed.printAddress(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - GrpcAPI.Return response = PublicMethedForMutiSign.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, ownerPermissionKeys); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(SIGERROR, response.getCode()); - Assert.assertEquals("validate signature error miss sig or contract", - response.getMessage().toStringUtf8()); - - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Sign permission transaction by empty address") - public void test08SignByEmptyKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - String[] ownerPermissionKeys = new String[1]; - PublicMethed.printAddress(ownerKey); - ownerPermissionKeys[0] = ""; - - logger.info("** update active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - boolean ret = false; - try { - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, ownerPermissionKeys); - } catch (NumberFormatException e) { - logger.info("NumberFormatException !"); - ret = true; - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - - Assert.assertTrue(ret); - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - - } - - @Test(enabled = true, description = "Sign permission transaction by invalid address") - public void test07SignByStringKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - String emptyKey = "abc1222"; - - logger.info("** update active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + emptyKey + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - ownerPermissionKeys.add(emptyKey); - - boolean ret = false; - try { - GrpcAPI.Return response = PublicMethedForMutiSign.accountPermissionUpdateForResponse( - accountPermissionJson, ownerKey.getBytes(), ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - } catch (NullPointerException e) { - logger.info("NullPointerException !"); - ret = true; - } - Assert.assertTrue(ret); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Set same permission") - public void test08RepeatUpdateSamePermission() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - PublicMethedForMutiSign - .recoverAccountPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - PublicMethedForMutiSign - .recoverAccountPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - Assert.assertEquals(1, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Sign permission transaction " - + "by active address and default permissionId") - public void test09SignListMoreThanPermissionKeys() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - PublicMethed.printAddress(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - ownerPermissionKeys.add(testKey002); - ownerPermissionKeys.add(ownerKey); - - GrpcAPI.Return response = PublicMethedForMutiSign.accountPermissionUpdateForResponse( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(SIGERROR, response.getCode()); - Assert.assertEquals("validate signature error Signature count " - + "is 2 more than key counts of permission : 1", response.getMessage().toStringUtf8()); - - Assert.assertEquals(1, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign23.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign23.java deleted file mode 100644 index ff069ec8c23..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign23.java +++ /dev/null @@ -1,1171 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.ENOUGH_PERMISSION; -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.NOT_ENOUGH_PERMISSION; -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.PERMISSION_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign23 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private static final String AVAILABLE_OPERATION = - "7fff1fc0037e0000000000000000000000000000000000000000000000000000"; - private static final String DEFAULT_OPERATION = - "7fff1fc0033e0000000000000000000000000000000000000000000000000000"; - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Add sign for multi sign normal transaction") - public void test01MultiSignNormalTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(1, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - Transaction transaction1 = PublicMethedForMutiSign.addTransactionSignWithPermissionId( - transaction, tmpKey02, 2, blockingStubFull); - - Transaction transaction2 = PublicMethedForMutiSign.addTransactionSignWithPermissionId( - transaction1, witnessKey001, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction2, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethedForMutiSign - .recoverAccountPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - } - - - @Test(enabled = true, description = "Add sign for multi sign permission transaction") - public void test02MultiSignPermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - Integer[] ints = {ContractType.AccountPermissionUpdateContract_VALUE}; - String operations = PublicMethedForMutiSign.getOperations(ints); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + operations + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 2, blockingStubFull); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, ownerKey, 2, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction2, blockingStubFull)); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Add sign for single sign normal transaction") - public void test03SingleSignNormalTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - Integer[] ints = {ContractType.TransferContract_VALUE}; - String operations = PublicMethedForMutiSign.getOperations(ints); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operations + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 2, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - } - - @Test(enabled = true, description = "Add sign for not complete multi sign normal transaction") - public void test05MultiSignNotCompletePermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 2, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Add sign for normal transaction " - + "with address not in permission list") - public void test06SignFailedTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, testKey002, 2, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Add sign for timeout normal transaction") - public void test07TimeoutTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - try { - Thread.sleep(70000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 2, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign.getTransactionSignWeight( - transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Add sign for empty transaction") - public void test08EmptyTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - - logger.info("** created an empty transaction"); - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - TransactionExtention transactionExtention = - blockingStubFull.accountPermissionUpdate(contract); - Transaction transaction = transactionExtention.getTransaction(); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, ownerKey, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Add sign for error transaction") - public void test09ErrorTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a fake transaction"); - Transaction transaction = PublicMethedForMutiSign - .createFakeTransaction(ownerAddress, 1_000_000L, ownerAddress); - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(2, txWeight.getCurrentWeight()); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Add sign transaction with mix order") - public void test10MultiSignNormalTransactionWithMixOrder() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + DEFAULT_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(3, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = PublicMethedForMutiSign.getTransactionSignWeight( - transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString( - transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast1 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(1, txWeight.getCurrentWeight()); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, ownerKey, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("Before broadcast2 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(2, txWeight.getCurrentWeight()); - - Transaction transaction3 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction2, witnessKey001, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction3.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction3, blockingStubFull); - logger.info("Before broadcast2 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction3, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - } - - @Test(enabled = true, description = "Add sign transaction with same address") - public void test11MultiSignNormalTransactionBySameAccount() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + DEFAULT_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(3, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast1 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(1, txWeight.getCurrentWeight()); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, ownerKey, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("Before broadcast2 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(2, txWeight.getCurrentWeight()); - - Transaction transaction3 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction2, ownerKey, 2, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction3.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction3, blockingStubFull); - logger.info("Before broadcast2 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertThat(txWeight.getResult().getMessage(), - containsString("has signed twice!")); - - Assert.assertFalse(PublicMethedForMutiSign.broadcastTransaction( - transaction3, blockingStubFull)); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Add sign transaction with null address") - public void test12MultiSignNormalTransactionByNullKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + DEFAULT_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(3, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = null; - boolean ret = false; - try { - transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, null, 2, blockingStubFull); - } catch (NullPointerException e) { - logger.info("java.lang.NullPointerException"); - ret = true; - } - Assert.assertTrue(ret); - - ret = false; - try { - transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, "", 2, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException: Zero length BigInteger"); - ret = true; - } catch (NullPointerException e) { - logger.info("NullPointerException"); - ret = true; - } - Assert.assertTrue(ret); - - ret = false; - try { - transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, "abcd1234", 2, blockingStubFull); - } catch (Exception e) { - logger.info("Exception!!"); - ret = true; - } - Assert.assertFalse(ret); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertThat(txWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - - @Test(enabled = true, description = "Add sign transaction with String address") - public void test13MultiSignNormalTransactionByStringKey() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - ownerPermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + DEFAULT_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - - Assert.assertEquals(3, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = null; - boolean ret = false; - try { - transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, "abcdefg", 2, blockingStubFull); - } catch (NullPointerException e) { - logger.info("java.lang.NullPointerException"); - ret = true; - } - Assert.assertTrue(ret); - - ret = false; - try { - transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, "", 2, blockingStubFull); - } catch (NumberFormatException e) { - logger.info("NumberFormatException: Zero length BigInteger"); - ret = true; - } catch (NullPointerException e) { - logger.info("NullPointerException"); - ret = true; - } - Assert.assertTrue(ret); - - ret = false; - try { - transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, "abcd1234", 2, blockingStubFull); - } catch (Exception e) { - logger.info("Exception!!"); - ret = true; - } - Assert.assertFalse(ret); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertThat(txWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign24.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign24.java deleted file mode 100644 index 1b12d95518b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign24.java +++ /dev/null @@ -1,816 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.ENOUGH_PERMISSION; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign24 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private static final String AVAILABLE_OPERATION - = "7fff1fc0037e0000000000000000000000000000000000000000000000000000"; - private static final String DEFAULT_OPERATION - = "7fff1fc0033e0000000000000000000000000000000000000000000000000000"; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "Broadcast multi sign normal transaction") - public void test01BroadcastMultiSignNormalTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee * 2; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + "\"permission_name\":\"owner1\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 0, blockingStubFull); - - Transaction transaction2 = PublicMethedForMutiSign.addTransactionSignWithPermissionId( - transaction1, testKey002, 0, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction2, blockingStubFull)); - - PublicMethedForMutiSign - .recoverAccountPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - PublicMethed - .unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull); - - } - - @Test(enabled = true, description = "Broadcast multi sign permission transaction") - public void test02BroadcastMultiSignPermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee * 2 + multiSignFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - Integer[] ints = {ContractType.AccountPermissionUpdateContract_VALUE}; - String operations = PublicMethedForMutiSign.getOperations(ints); - - logger.info("** update owner and active permission to two address"); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + operations + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, testKey002, 0, blockingStubFull); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, ownerKey, 0, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction2, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Broadcast single sign normal transaction") - public void test03BroadcastSingleSignNormalTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - Integer[] ints = {ContractType.TransferContract_VALUE}; - String operations = PublicMethedForMutiSign.getOperations(ints); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operations + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, testKey002, 0, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1000000); - - } - - @Test(enabled = true, description = "Broadcast not sign permission transaction") - public void test04BroadcastNotSignPermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert.assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Broadcast not complete multi sign normal transaction") - public void test05BroadcastMultiSignNotCompletePermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, testKey002, 0, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Broadcast failed transaction") - public void test06BroadcastSignFailedTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, tmpKey02, 0, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = true, description = "Broadcast timeout normal transaction") - public void test07BroadcastTimeoutTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, ownerKey, 0, blockingStubFull); - - try { - Thread.sleep(70000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - TransactionSignWeight txWeight = PublicMethedForMutiSign.getTransactionSignWeight( - transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = true, description = "Broadcast empty transaction") - public void test08BroadcastEmptyTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - PublicMethed.printAddress(ownerKey); - - logger.info("** created an empty transaction"); - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.accountPermissionUpdate(contract); - Transaction transaction = transactionExtention.getTransaction(); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, ownerKey, blockingStubFull); - - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("TransactionSignWeight info : " + txWeight); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore, balanceAfter); - } - - @Test(enabled = true, description = "Broadcast error transaction") - public void test09BroadcastErrorTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long needCoin = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, needCoin + 1_000_000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a fake transaction"); - Transaction transaction = PublicMethedForMutiSign - .createFakeTransaction(ownerAddress, 1_000_000L, ownerAddress); - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, testKey002, 0, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign25.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign25.java deleted file mode 100644 index 6275cf64c5a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign25.java +++ /dev/null @@ -1,958 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.ENOUGH_PERMISSION; -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.NOT_ENOUGH_PERMISSION; -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.OTHER_ERROR; -import static org.tron.api.GrpcAPI.TransactionSignWeight.Result.response_code.PERMISSION_ERROR; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign25 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] ownerAddress = ecKey1.getAddress(); - private String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] normalAddr001 = ecKey2.getAddress(); - private String normalKey001 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey tmpEcKey01 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr01 = tmpEcKey01.getAddress(); - private String tmpKey01 = ByteArray.toHexString(tmpEcKey01.getPrivKeyBytes()); - - private ECKey tmpEcKey02 = new ECKey(Utils.getRandom()); - private byte[] tmpAddr02 = tmpEcKey02.getAddress(); - private String tmpKey02 = ByteArray.toHexString(tmpEcKey02.getPrivKeyBytes()); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private static final String AVAILABLE_OPERATION - = "7fff1fc0037e0000000000000000000000000000000000000000000000000000"; - private static final String DEFAULT_OPERATION - = "7fff1fc0033e0000000000000000000000000000000000000000000000000000"; - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.sendcoin(ownerAddress, 1_000_000, fromAddress, testKey002, blockingStubFull); - } - - @Test(enabled = true, description = "Get sign for multi sign normal transaction") - public void test01GetSignMultiSignNormalTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 2 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed.printAddress(ownerKey); - PublicMethed.printAddress(tmpKey02); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - - String accountPermissionJson = "{\"owner_permission\":{\"type\":0," - + "\"permission_name\":\"owner1\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.clear(); - ownerPermissionKeys.add(tmpKey02); - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(witnessKey001); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, tmpKey02, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before Sign2 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(1, txWeight.getCurrentWeight()); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, testKey002, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(2, txWeight.getCurrentWeight()); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction2, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("After broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(2, txWeight.getCurrentWeight()); - - PublicMethedForMutiSign - .recoverAccountPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("After recover permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertEquals("Signature count is 2 more than key counts of permission : 1", - txWeight.getResult().getMessage()); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, 2 * updateAccountPermissionFee + 2 * multiSignFee + 1); - } - - @Test(enabled = true, description = "Get sign for multi sign permission transaction") - public void test02GetSignMultiSignPermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - long amount = 4 * updateAccountPermissionFee + 100000000; - - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - - Integer[] ints = {ContractType.AccountPermissionUpdateContract_VALUE}; - String operations = PublicMethedForMutiSign.getOperations(ints); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + operations + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before sign permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testKey002, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before sign2 permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("Before broadcast permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(5, txWeight.getCurrentWeight()); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction2, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("After broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - PublicMethedForMutiSign - .recoverAccountPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - logger.info("transaction hex string is " + ByteArray.toHexString(transaction2.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("After recover permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertEquals("Signature count is 2 more than key counts of permission : 1", - txWeight.getResult().getMessage()); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, 3 * updateAccountPermissionFee + multiSignFee); - } - - @Test(enabled = true, description = "Get sign for single sign normal transaction") - public void test03GetSignSingleSignNormalTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 2 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - Integer[] ints = {ContractType.TransferContract_VALUE}; - String operations = PublicMethedForMutiSign.getOperations(ints); - - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + operations + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testKey002, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - Assert.assertTrue(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("After broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - PublicMethedForMutiSign - .recoverAccountPermission(ownerKey, ownerPermissionKeys, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("After recover permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertThat(txWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, 2 * updateAccountPermissionFee + 1000_000); - } - - @Test(enabled = true, description = "Get sign for not sign transaction") - public void test04GetSignNotSignPermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 2 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - System.out - .printf(PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission())); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Assert.assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction, blockingStubFull)); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("After broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - } - - @Test(enabled = true, description = "Get sign for not complete multi sign normal transaction") - public void test05GetSignMultiSignNotCompletePermissionTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 4 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":3," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - logger.info("** trigger a permission transaction"); - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - - Transaction transaction = PublicMethedForMutiSign.accountPermissionUpdateWithoutSign( - accountPermissionJson, ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()])); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testKey002, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("After broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - } - - @Test(enabled = true, description = "Get sign for failed transaction") - public void test06GetSignFailedTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 4 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":5,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, tmpKey02, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertThat(txWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Assert.assertFalse(PublicMethedForMutiSign.broadcastTransaction( - transaction1, blockingStubFull)); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("After broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(PERMISSION_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertThat(txWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - } - - @Test(enabled = true, description = "Get sign for timeout normal transaction") - public void test07GetSignTimeoutTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 4 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed.printAddress(ownerKey); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - ownerPermissionKeys.add(ownerKey); - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":1}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, PublicMethedForMutiSign.getActivePermissionKeyCount( - PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a normal transaction"); - Transaction transaction = PublicMethedForMutiSign - .sendcoin2(fromAddress, 1000_000, ownerAddress, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction, blockingStubFull); - logger.info("Before Sign TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(NOT_ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testKey002, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - try { - Thread.sleep(70000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast2 TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("After broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - } - - @Test(enabled = true, description = "Get sign for empty transaction") - public void test08GetSignEmptyTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 4 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed.printAddress(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - logger.info("** created an empty transaction"); - - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.accountPermissionUpdate(contract); - Transaction transaction = transactionExtention.getTransaction(); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, ownerKey, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - TransactionSignWeight txWeight = - PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(OTHER_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertEquals("class java.lang.IndexOutOfBoundsException : Index: 0", - txWeight.getResult().getMessage()); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - txWeight = PublicMethedForMutiSign.getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("After recover permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(OTHER_ERROR, txWeight.getResult().getCode()); - Assert.assertEquals(0, txWeight.getCurrentWeight()); - Assert.assertEquals("class java.lang.IndexOutOfBoundsException : Index: 0", - txWeight.getResult().getMessage()); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance, balance1); - } - - @Test(enabled = true, description = "Get sign for error transaction") - public void test09GetSignErrorTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] ownerAddress = ecKey1.getAddress(); - final String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - long amount = 4 * updateAccountPermissionFee + 100000000; - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, amount, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - List ownerPermissionKeys = new ArrayList<>(); - List activePermissionKeys = new ArrayList<>(); - - PublicMethed.printAddress(ownerKey); - - ownerPermissionKeys.add(ownerKey); - activePermissionKeys.add(ownerKey); - Account test001AddressAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - final long balance = test001AddressAccount.getBalance(); - String accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner1\"," - + "\"threshold\":1,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":2}," - + "{\"address\":\"" + PublicMethed.getAddressString(testKey002) + "\",\"weight\":3}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"" + AVAILABLE_OPERATION + "\",\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(tmpKey02) + "\",\"weight\":2}" - + "]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, - ownerAddress, ownerKey, blockingStubFull, - ownerPermissionKeys.toArray(new String[ownerPermissionKeys.size()]))); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertEquals(2, - PublicMethedForMutiSign.getActivePermissionKeyCount(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList())); - - Assert.assertEquals(2, PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission().getKeysCount()); - - PublicMethedForMutiSign.printPermissionList(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getActivePermissionList()); - - PublicMethedForMutiSign.printPermission(PublicMethed.queryAccount(ownerAddress, - blockingStubFull).getOwnerPermission()); - - ownerPermissionKeys.add(testKey002); - activePermissionKeys.add(tmpKey02); - - logger.info("** trigger a fake transaction"); - Transaction transaction = PublicMethedForMutiSign - .createFakeTransaction(ownerAddress, 1_000_000L, ownerAddress); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testKey002, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - TransactionSignWeight txWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("Before broadcast permission TransactionSignWeight info :\n" + txWeight); - Assert.assertEquals(ENOUGH_PERMISSION, txWeight.getResult().getCode()); - Assert.assertEquals(3, txWeight.getCurrentWeight()); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Account test001AddressAccount1 = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, 1 * updateAccountPermissionFee); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign26.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign26.java deleted file mode 100644 index 2ad96574271..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign26.java +++ /dev/null @@ -1,981 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign26 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final String testWitnesses = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessesKey = PublicMethed.getFinalAddress(testWitnesses); - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidityInFullnode = null; - - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = "Sendcoin,use acticve address to sign," - + "not meet the requirements.Delete the address,broadcastTransaction.") - public void testMultiUpdatepermissions_BeforeSign() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - logger.info("transactionSignWeight:" + transactionSignWeight); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList3 = test001AddressAccount3.getActivePermissionList(); - Permission ownerPermission3 = test001AddressAccount3.getOwnerPermission(); - Permission witnessPermission3 = test001AddressAccount3.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList3); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission3)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission3)); - - final Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2 - balance3, updateAccountPermissionFee); - logger.info("returnResult:"); - Assert - .assertThat(returnResult.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult.getMessage().toStringUtf8(), - containsString("Permission denied")); - - - } - - @Test(enabled = true, description = "Sendcoin,use acticve address to sign," - + "meet the all requirements.Delete the address,broadcastTransaction.") - public void testMultiUpdatepermissions_BeforeSign_1() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - final Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - final Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - Assert - .assertThat(returnResult.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - } - - - @Test(enabled = true, description = "Sendcoin,use owner address to sign," - + "Delete the address,broadcastTransaction.") - public void testMultiUpdatepermissions_BeforeSign_2() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[2]; - permissionKeyString[0] = dev001Key; - permissionKeyString[1] = sendAccountKey2; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":1,\"keys\":[{" - + "\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 0, dev001Key, - blockingStubFull); - final Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address" - + "\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"" - + "active0\",\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = dev001Key; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString1)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - final Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertThat(returnResult.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2 - balance3, 0); - } - - @Test(enabled = true, description = "AccountPermissionUpdate transaction," - + "use owner address to sign,Delete the address,broadcastTransaction.") - public void testMultiUpdatepermissions_BeforeSign_3() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[2]; - permissionKeyString[0] = dev001Key; - permissionKeyString[1] = sendAccountKey2; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":1,\"keys\":[{" - + "\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - String accountPermissionJson3 = - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":1,\"keys\":[{" - + "\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}]}]} "; - - Transaction transaction = PublicMethedForMutiSign - .accountPermissionUpdateWithoutSign(accountPermissionJson3, test001Address, dev001Key, - blockingStubFull, - permissionKeyString); - final Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, sendAccountKey2, 0, blockingStubFull); - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address" - + "\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"" - + "active0\",\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = dev001Key; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString1)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertThat(returnResult.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2 - balance3, 0); - } - - @Test(enabled = true, description = - "Sendcoin,meet the all requirements.Delete the active address," - + "use the address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_AfterSign_1() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - final Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":1,\"keys\":[{" - + "\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = dev001Key; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString1)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertThat(returnResult.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2 - balance3, 0); - } - - @Test(enabled = true, description = - "Sendcoin,not meet the requirements.Delete the active address," - + "use the address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_AfterSign_2() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[2]; - permissionKeyString[0] = dev001Key; - permissionKeyString[1] = sendAccountKey2; - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - final Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":1,\"keys\":[{" - + "\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = dev001Key; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString1)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - final Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertThat(returnResult.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2 - balance3, 0); - } - - @Test(enabled = true, description = "Sendcoin,Delete the owner address," - + "use the address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_AfterSign() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - logger.info("1-----------------------"); - - final Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 0, dev001Key, - blockingStubFull); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2 - balance3, 0); - - } - - @Test(enabled = true, description = "AccountPermissionUpdate transaction," - + "Delete the owner address,use the address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_AfterSign_4() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 3 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - String accountPermissionJson3 = - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":1,\"keys\":[{" - + "\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}]}]} "; - - final Transaction transaction = PublicMethedForMutiSign - .accountPermissionUpdateWithoutSign(accountPermissionJson3, test001Address, dev001Key, - blockingStubFull, - permissionKeyString); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, dev001Key, 0, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2 - balance3, 0); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign27.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign27.java deleted file mode 100644 index f3025b34c0e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign27.java +++ /dev/null @@ -1,917 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign27 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final String testWitnesses = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessesKey = PublicMethed.getFinalAddress(testWitnesses); - private ManagedChannel channelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = "Sendcoin,use active address sign ,meet all requirements." - + "Then use not in permissionlist address sign,broadcastTransaction.") - public void testMultiUpdatepermissions_1() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = "Sendcoin,use active address sign,not meet the requirements." - + "Then use not in permissionlist address sign,broadcastTransaction.") - public void testMultiUpdatepermissions_2() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = "Sendcoin,use active address sign, meet all requirements." - + "Then use permissionID not same in activelist address to sign," - + "not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_3() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - - @Test(enabled = true, description = "Sendcoin,use active address sign, not meet the requirements." - + "Then use permissionID not same in activelist address to sign," - + "not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_4() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = "Sendcoin,use active address sign, not meet the requirements." - + "Then use permissionID not same in activelist address to sign," - + "meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_5() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - - @Test(enabled = true, description = "Sendcoin,use active address sign, meet all requirements." - + "Then use permissionID not same in activelist address to sign," - + "meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_6() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 3, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey2, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = "Sendcoin,use owner address sign, meet all requirements." - + "Then use not in permissionlist address to sign," - + "not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_7() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - - @Test(enabled = true, description = "Sendcoin,use owner address sign, meet all requirements." - + "Then use in active address to sign,not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_8() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey2, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = "Sendcoin,use owner address sign, meet all requirements." - + "Then use in active address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_9() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - final String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - final long balance = test001AddressAccount.getBalance(); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey2, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign28.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign28.java deleted file mode 100644 index da8232b5029..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign28.java +++ /dev/null @@ -1,1236 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign28 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = - "Sendcoin,use not in permissionlist address sign,not meet the requirements." - + "Then use in active address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_10() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - - } - - @Test(enabled = true, description = - "Sendcoin,use not in permissionlist address sign,not meet the requirements." - + "Then use in active address to sign,not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_11() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - - long balance2 = test001AddressAccount2.getBalance(); - logger.info("balance2:" + balance2); - - Assert.assertEquals(balance1, balance2); - - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign,not meet the requirements." - + "Then use permissionId not same in active address to sign," - + " meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_12() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements." - + "Then use permissionId not same in active address to sign," - + " meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_13() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + multiSignFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - final long balance1 = test001AddressAccount1.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert.assertTrue(returnResult1.getResult()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, multiSignFee + 1); - - - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements." - + "Then use permissionId not same in active address to sign," - + " not meet requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_14() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("ENOUGH_PERMISSION")); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, not meet the requirements." - + "Then use permissionId not same in active address to sign," - + " not meet requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_15() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use not in permissionlist address sign, meet all requirements." - + "Then use owner address to sign,meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_16() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use not in permissionlist address sign, meet all requirements." - + "Then use owner address to sign,not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_17() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements." - + "Then use owner address to sign,not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_18() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements." - + "Then use owner address to sign,meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_19() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, dev001Key, 0, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, not meet the requirements." - + "Then use owner address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_20() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - long balance = test001AddressAccount.getBalance(); - - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - final long balance1 = test001AddressAccount1.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey2, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, not meet the requirements." - + "Then use owner address to sign, not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_21() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, dev001Key, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign29.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign29.java deleted file mode 100644 index 53b1c791021..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign29.java +++ /dev/null @@ -1,858 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign29 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = "Sendcoin,use active address sign, meet all requirements." - + "Then use permissionID same in active address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_22() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 2000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert.assertTrue(returnResult1.getResult()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, multiSignFee + 1); - - - } - - @Test(enabled = true, description = "Sendcoin,use active address sign, not meet the requirements." - + "Then use permissionID same in active address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_23() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 2000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0100000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("validate signature error Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = "Sendcoin,use owner address sign," - + "Then use owner address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_24() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 2000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert.assertTrue(returnResult1.getResult()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, multiSignFee + 1); - - } - - - @Test(enabled = true, description = - "Sendcoin,use active address sign, not meet the requirements." - + "Then use owner address to sign, not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_25() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0100000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("validate signature error Permission denied")); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements." - + "Then use owner address to sign, not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_26() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - - @Test(enabled = true, description = - "Sendcoin,use active address sign, not meet the requirements." - + "Then use owner address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_27() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0100000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, dev001Key, 0, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements." - + "Then use owner address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_28() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, dev001Key, 0, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use owner address sign, meet all requirements." - + "Then use active address to sign, not meet the requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_29() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance, balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use owner address sign, meet all requirements." - + "Then use active address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_30() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey3, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("but it is not contained of permission")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign30.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign30.java deleted file mode 100644 index e0b8c926e5b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign30.java +++ /dev/null @@ -1,376 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign30 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = - "Sendcoin,use active address sign(weight< threshold)," - + "Then use the address to sign(weight>=threshold),broadcastTransaction.") - public void testMultiUpdatepermissions_31() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":2,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}" - + ",{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("NOT_ENOUGH_PERMISSION")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey4, blockingStubFull); - - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("has signed twice")); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("has signed twice")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign(weight< threshold)." - + "Then use the address to sign(weight>=threshold),broadcastTransaction.") - public void testMultiUpdatepermissions_32() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":2,\"operations\":\"" - + "0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}" - + ",{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 2, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey4, blockingStubFull); - - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("validate signature error Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - @Test(enabled = true, description = - "Sendcoin,use owner address sign(weight< threshold)," - + "Then use the address to sign(weight>=threshold),broadcastTransaction.") - public void testMultiUpdatepermissions_33() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[2]; - permissionKeyString[0] = dev001Key; - permissionKeyString[1] = sendAccountKey4; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":2,\"keys\":[{\"address" - + "\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"" - + ",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 0, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey4, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("NOT_ENOUGH_PERMISSION")); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey4, blockingStubFull); - - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("has signed twice")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("has signed twice")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign31.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign31.java deleted file mode 100644 index 8877bf29b6b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign31.java +++ /dev/null @@ -1,860 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign31 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final String testWitnesses = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private ManagedChannel channelSolidity = null; - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements.Then use the same" - + " permissionID active address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_34() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - long balance = test001AddressAccount.getBalance(); - logger.info("balance:" + balance); - PublicMethedForMutiSign.printPermissionList(permissionsList); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - logger.info("balance1:" + balance1); - - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert.assertTrue(returnResult1.getResult()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - logger.info("balance2:" + balance2); - - Assert.assertEquals(balance1 - balance2, 1L); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("DUP_TRANSACTION_ERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance3, balance2); - - - } - - - @Test(enabled = true, description = - "Sendcoin,use active address sign,not meet the requirements.Then use the same" - + " permissionID active address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_35() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0100000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - logger.info("balance2:" + balance2); - Assert.assertEquals(balance1, balance2); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("validate signature error Permission denied")); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - - logger.info("transaction1:" + transactionSignWeight1); - - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("DUP_TRANSACTION_ERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - logger.info("balance3:" + balance3); - Assert.assertEquals(balance3, balance2); - - - } - - @Test(enabled = true, description = - "Sendcoin,use owner address sign,Then use owner address to sign,broadcastTransaction.") - public void testMultiUpdatepermissions_36() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(returnResult1.getResult()); - - logger.info("returnResult1:" + returnResult1); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, 1); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("DUP_TRANSACTION_ERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2, balance3); - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign,not meet requirements,Then use the other permissionID " - + "in active address to sign, meet all requirements.broadcastTransaction.") - public void testMultiUpdatepermissions_37() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 3, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("but it is not contained of permission")); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("but it is not contained of permission")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - //Assert.assertTrue(returnResult1.getResult()); - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey3, 3, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("DUP_TRANSACTION_ERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2, balance3); - - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements,Then use the other permissionID " - + "in active address to sign,not meet the requirements.broadcastTransaction.") - public void testMultiUpdatepermissions_38() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 2; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1, test001Address, 3, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, 1); - - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("DUP_TRANSACTION_ERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance3, balance2); - - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, meet all requirements,Then use the other permissionID " - + "in active address to sign, meet all requirements.broadcastTransaction.") - public void testMultiUpdatepermissions_39() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 2; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 3, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, 1L); - - logger.info("returnResult1:" + returnResult1); - Assert.assertTrue(returnResult1.getResult()); - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey2, 2, blockingStubFull); - - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("SIGERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance3, balance2); - - } - - @Test(enabled = true, description = - "Sendcoin,use active address sign, not meet the requirements,Then use the other permissionID " - + "in active address to sign,not meet the requirements.broadcastTransaction.") - public void testMultiUpdatepermissions_40() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 2; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - final long balance = test001AddressAccount.getBalance(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 3, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey3, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("Permission denied")); - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey2, 2, blockingStubFull); - - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("SIGERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance2, balance3); - - } - - @Test(enabled = true, description = - "Sendcoin,use owner address sign, meet all requirements,Then use active address to sign" - + ",not meet the requirements.broadcastTransaction.") - public void testMultiUpdatepermissions_41() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 2; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - Assert.assertTrue(returnResult1.getResult()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info("returnResult1:" + returnResult1); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, 1); - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey3, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - logger.info("transaction1:" + transactionSignWeight1); - - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult1:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("SIGERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance3, balance2); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign32.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign32.java deleted file mode 100644 index 8217a7cc024..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign32.java +++ /dev/null @@ -1,342 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign32 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final String testWitnesses = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey = new ECKey(Utils.getRandom()); - private byte[] test001Address = ecKey.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = "Dup owner address ") - public void testMultiSignAddDupAssressOwner() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\",\"keys\":" - + "[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}]} "; - - Return areturn = PublicMethedForMutiSign - .accountPermissionUpdateForResponse(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, - permissionKeyString); - Assert - .assertThat(areturn.getCode().toString(), containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(areturn.getMessage().toStringUtf8(), - containsString( - "contract validate error : address should be distinct in permission Owner")); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - } - - @Test(enabled = true, description = "Dup active address in same permissionID activelist ") - public void testMultiSignAddDupAssressActive_1() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - String accountPermissionJson2 = - - "{\"owner_permission\":{\"type\":0,\"permission_name" - + "\":\"owner\",\"threshold\":1,\"keys\":" - + "[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}]}]} "; - - Return areturn = PublicMethedForMutiSign - .accountPermissionUpdateForResponse(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, - permissionKeyString); - Assert - .assertThat(areturn.getCode().toString(), containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(areturn.getMessage().toStringUtf8(), - containsString( - "contract validate error : address should be distinct in permission Active")); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1, balance2); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - } - - @Test(enabled = true, description = "Dup active address in different permissionID activelist ") - public void testMultiSignAddDupAssressActive_2() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\"," - + "\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - long balance1 = test001AddressAccount1.getBalance(); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold" - + "\":1,\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0200000000000000000000000000000000000000000000000000000000000000\",\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}]} "; - - boolean b = PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString); - Assert.assertTrue(b); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign33.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign33.java deleted file mode 100644 index 23ff62d35d1..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign33.java +++ /dev/null @@ -1,260 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign33 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private ManagedChannel channelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test(enabled = true, description = "Owner address fall back into only myself") - public void testMultiSignOwnerAddress() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + multiSignFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - logger.info("balance:" + balance); - - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[5]; - permissionKeyString[0] = dev001Key; - permissionKeyString[1] = sendAccountKey2; - permissionKeyString[2] = sendAccountKey3; - permissionKeyString[3] = sendAccountKey4; - permissionKeyString[4] = sendAccountKey5; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":5,\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey5) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - logger.info("balance1:" + balance1); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - long balance2 = test001AddressAccount2.getBalance(); - logger.info("balance2:" + balance2); - - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee + multiSignFee); - - - } - - @Test(enabled = true, description = "Active address fall back into only myself") - public void testMultiSignActiveAddress() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"" - + "owner\",\"threshold\":1,\"keys\":[{\"address\":\"" - + "" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name" - + "\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"" - + ",\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\"," - + "\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - long balance2 = test001AddressAccount2.getBalance(); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign34.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign34.java deleted file mode 100644 index c937e574fe7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign34.java +++ /dev/null @@ -1,227 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign34 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final String testWitnesses = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - private final byte[] witnessesKey = PublicMethed.getFinalAddress(testWitnesses); - private ManagedChannel channelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - - @Test(enabled = true, description = "SR witness,sendcoin, use witnessPermission address sign.") - public void testMultiUpdatepermissions_42() { - Assert.assertTrue(PublicMethed - .sendcoin(witnessesKey, 1000000000, fromAddress, testKey002, - blockingStubFull)); - Account test001AddressAccount = PublicMethed.queryAccount(witnessesKey, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, witnessesKey, 1, testWitnesses, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testWitnesses, blockingStubFull); - final TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(witnessesKey, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance, balance1); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("permission isn't exit")); - - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("permission isn't exit")); - - } - - @Test(enabled = true, description = "SR witness,sendcoin, use active address sign.") - public void testMultiUpdatepermissions_43() { - Assert.assertTrue(PublicMethed - .sendcoin(witnessesKey, 1000000000, fromAddress, testKey002, - blockingStubFull)); - Account test001AddressAccount = PublicMethed.queryAccount(witnessesKey, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, witnessesKey, 2, testWitnesses, - blockingStubFull); - final Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testWitnesses, blockingStubFull); - final TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transaction:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("permission isn't exit")); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Account test001AddressAccount1 = PublicMethed.queryAccount(witnessesKey, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance, balance1); - Assert - .assertThat(returnResult1.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult1.getMessage().toStringUtf8(), - containsString("permission isn't exit")); - - } - - - @Test(enabled = true, description = "SR witness,sendcoin, use owner address sign.") - public void testMultiUpdatepermissions_44() { - Assert.assertTrue(PublicMethed - .sendcoin(witnessesKey, 1000000000, fromAddress, testKey002, - blockingStubFull)); - Account test001AddressAccount = PublicMethed.queryAccount(witnessesKey, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, witnessesKey, 0, testWitnesses, - blockingStubFull); - final Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, testWitnesses, blockingStubFull); - Return returnResult1 = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - logger.info("returnResult1:" + returnResult1); - Assert.assertTrue(returnResult1.getResult()); - Account test001AddressAccount1 = PublicMethed.queryAccount(witnessesKey, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, 1); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign35.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign35.java deleted file mode 100644 index 7ba2fb1aa68..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign35.java +++ /dev/null @@ -1,290 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign35 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private ManagedChannel channelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test(enabled = true, description = "Test perimissionID is " - + "7fff1fc0037e0000000000000000000000000000000000000000000000000000") - public void testMultiUpdatepermissions_45() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[5]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey5) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":\"" - + "7fff1fc0037e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - String[] permissionKeyString1 = new String[5]; - permissionKeyString1[0] = sendAccountKey4; - Transaction transaction = PublicMethedForMutiSign - .accountPermissionUpdateWithoutSign(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, - permissionKeyString); - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, sendAccountKey4, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - - Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - logger.info("returnResult:" + returnResult); - Assert.assertTrue(returnResult.getResult()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - final long balance2 = test001AddressAccount2.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - Assert.assertEquals(balance1 - balance2, updateAccountPermissionFee); - - - } - - @Test(enabled = true, description = "Test perimissionID is " - + "7fff1fc0033e0000000000000000000000000000000000000000000000000000") - public void testMultiUpdatepermissions_46() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - final long balance = test001AddressAccount.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[5]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey5) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":\"" - + "7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - final long balance1 = test001AddressAccount1.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - String[] permissionKeyString1 = new String[5]; - permissionKeyString1[0] = sendAccountKey4; - Transaction transaction = PublicMethedForMutiSign - .accountPermissionUpdateWithoutSign(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, - permissionKeyString); - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, sendAccountKey4, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight.getResult().getMessage(), - containsString("Permission denied")); - Return returnResult = PublicMethedForMutiSign - .broadcastTransaction1(transaction1, blockingStubFull); - logger.info("returnResult:" + returnResult); - - Assert - .assertThat(returnResult.getCode().toString(), containsString("SIGERROR")); - Assert - .assertThat(returnResult.getMessage().toStringUtf8(), - containsString("Permission denied")); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - final long balance2 = test001AddressAccount2.getBalance(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - Assert.assertEquals(balance1, balance2); - - - } - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign36.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign36.java deleted file mode 100644 index 928330b161d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign36.java +++ /dev/null @@ -1,909 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import com.google.protobuf.Any; -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.TransactionApprovedList; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign36 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final String testWitnesses = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessesKey = PublicMethed.getFinalAddress(testWitnesses); - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - @Test(enabled = true, description = "MultiSign permission transaction") - public void getTransactionApprovedList_01() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[2]; - permissionKeyString[0] = dev001Key; - permissionKeyString[1] = sendAccountKey2; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":2,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Transaction transaction = PublicMethedForMutiSign - .accountPermissionUpdateWithoutSign(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, - permissionKeyString); - - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, dev001Key, 0, blockingStubFull); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey2, blockingStubFull); - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction2, blockingStubFull); - logger.info("test001Address:" + Base58.encode58Check(test001Address)); - logger.info( - "transactionApprovedList:" + Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(Base58.encode58Check(test001Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(Base58.encode58Check(test002Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(1).toByteArray())); - Assert.assertEquals(2, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(0, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - Account test001AddressAccount1 = PublicMethed - .queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - - } - - - @Test(enabled = true, description = "After sign success,delete the address") - public void getTransactionApprovedList_02() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = 2 * updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, sendAccountKey2, 2, blockingStubFull); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson2, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction1, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - logger.info("transactionSignWeight:" + transactionApprovedList); - logger.info("test001Address:" + Base58.encode58Check(test001Address)); - logger.info( - "transactionApprovedList:" + Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(Base58.encode58Check(test002Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(1, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(2, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - Account test001AddressAccount2 = PublicMethed.queryAccount(sendAccountKey2, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - @Test(enabled = true, description = "MultiSign ordinary transaction") - public void getTransactionApprovedList_03() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":2,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(test005Address, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - Transaction transaction2 = PublicMethed - .addTransactionSign(transaction1, sendAccountKey3, blockingStubFull); - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction2, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - logger.info("test001Address:" + Base58.encode58Check(test001Address)); - logger.info( - "transactionApprovedList:" + Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(Base58.encode58Check(test002Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(Base58.encode58Check(test003Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(1).toByteArray())); - Assert.assertEquals(2, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(2, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - @Test(enabled = true, description = "One time sign ordinary transaction") - public void getTransactionApprovedList_04() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(test005Address, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction1, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - logger.info("test001Address:" + Base58.encode58Check(test001Address)); - logger.info( - "transactionApprovedList:" + Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(Base58.encode58Check(test002Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(2, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - Assert.assertEquals(1, transactionApprovedList.getApprovedListCount()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - @Test(enabled = true, description = "No sign transaction") - public void getTransactionApprovedList_05() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(test005Address, 1L, test001Address, 2, dev001Key, - blockingStubFull); - - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - logger.info("test001Address:" + Base58.encode58Check(test001Address)); - - Assert.assertEquals(0, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(2, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - @Test(enabled = true, description = "Multi-signature unfinished transaction") - public void getTransactionApprovedList_06() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":2,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(test005Address, 1L, test001Address, 2, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction1, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - logger.info("test001Address:" + Base58.encode58Check(test001Address)); - - Assert.assertEquals(1, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(Base58.encode58Check(test002Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(2, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - - @Test(enabled = true, description = "Signature not success transaction") - public void getTransactionApprovedList_07() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":2,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(test005Address, 1L, test001Address, 0, dev001Key, - blockingStubFull); - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, sendAccountKey2, blockingStubFull); - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction1, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - - Assert.assertEquals(1, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(Base58.encode58Check(test002Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(0, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - - @Test(enabled = true, description = "The timeout transaction") - public void getTransactionApprovedList_08() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":2,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(test005Address, 1L, test001Address, 0, dev001Key, - blockingStubFull); - - try { - Thread.sleep(100000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Transaction transaction1 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction, sendAccountKey2, 0, blockingStubFull); - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction1, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - logger.info("Base58.encode58Check(test001Address):" + Base58.encode58Check(test002Address)); - logger.info("Base58.encode58Check(test001Address)1:" + Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(1, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(Base58.encode58Check(test002Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - @Test(enabled = true, description = "The error transaction") - public void getTransactionApprovedList_09() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":2,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Transaction transaction = createFakeTransaction(test001Address, 1L, test001Address); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction1, blockingStubFull); - - logger.info("transactionSignWeight:" + transactionApprovedList); - - Assert.assertEquals(1, transactionApprovedList.getApprovedListCount()); - Assert.assertEquals(Base58.encode58Check(test001Address), Base58 - .encode58Check(transactionApprovedList.getApprovedList(0).toByteArray())); - Assert.assertEquals(0, - transactionApprovedList.getTransaction().getTransaction().getRawData().getContract(0) - .getPermissionId()); - - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - - - } - - @Test(enabled = true, description = "The null transaction") - public void getTransactionApprovedList_10() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee; - - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Contract.AccountPermissionUpdateContract.Builder builder = - Contract.AccountPermissionUpdateContract.newBuilder(); - - Contract.AccountPermissionUpdateContract contract = builder.build(); - TransactionExtention transactionExtention = blockingStubFull.accountPermissionUpdate(contract); - Transaction transaction = transactionExtention.getTransaction(); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - final Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction.toByteArray())); - - TransactionApprovedList transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction, blockingStubFull); - logger.info("Before broadcast transactionApprovedList info :\n" + transactionApprovedList); - Assert.assertEquals("class java.lang.IndexOutOfBoundsException : Index: 0", - transactionApprovedList.getResult().getMessage()); - - Assert - .assertFalse(PublicMethedForMutiSign.broadcastTransaction(transaction1, blockingStubFull)); - - logger.info("transaction hex string is " + ByteArray.toHexString(transaction1.toByteArray())); - transactionApprovedList = PublicMethed - .getTransactionApprovedList(transaction1, blockingStubFull); - - Assert.assertEquals("class java.lang.IndexOutOfBoundsException : Index: 0", - transactionApprovedList.getResult().getMessage()); - } - - /** - * constructor. - */ - public Protocol.Transaction createFakeTransaction(byte[] toAddrss, Long amount, - byte[] fromAddress) { - - Contract.TransferContract contract = Contract.TransferContract.newBuilder() - .setOwnerAddress(ByteString.copyFrom(fromAddress)) - .setToAddress(ByteString.copyFrom(toAddrss)) - .setAmount(amount) - .build(); - Protocol.Transaction transaction = createTransaction(contract, ContractType.TransferContract); - - return transaction; - } - - private Transaction setReference(Transaction transaction, long blockNum, - byte[] blockHash) { - byte[] refBlockNum = ByteArray.fromLong(blockNum); - Transaction.raw rawData = transaction.getRawData().toBuilder() - .setRefBlockHash(ByteString.copyFrom(blockHash)) - .setRefBlockBytes(ByteString.copyFrom(refBlockNum)) - .build(); - return transaction.toBuilder().setRawData(rawData).build(); - } - - - /** - * constructor. - */ - - public Transaction setExpiration(Transaction transaction, long expiration) { - Transaction.raw rawData = transaction.getRawData().toBuilder().setExpiration(expiration) - .build(); - return transaction.toBuilder().setRawData(rawData).build(); - } - - - /** - * constructor. - */ - - public Transaction createTransaction(com.google.protobuf.Message message, - ContractType contractType) { - Transaction.raw.Builder transactionBuilder = Transaction.raw.newBuilder().addContract( - Transaction.Contract.newBuilder().setType(contractType).setParameter( - Any.pack(message)).build()); - - Transaction transaction = Transaction.newBuilder().setRawData(transactionBuilder.build()) - .build(); - - long time = System.currentTimeMillis(); - AtomicLong count = new AtomicLong(); - long gtime = count.incrementAndGet() + time; - String ref = "" + gtime; - - transaction = setReference(transaction, gtime, ByteArray.fromString(ref)); - - transaction = setExpiration(transaction, gtime); - - return transaction; - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign37.java b/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign37.java deleted file mode 100644 index 62b9a128777..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/multisign/MultiSign37.java +++ /dev/null @@ -1,409 +0,0 @@ -package stest.tron.wallet.dailybuild.multisign; - -import static org.hamcrest.core.StringContains.containsString; - -import com.google.protobuf.Any; -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TransactionSignWeight; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MultiSign37 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final String testWitnesses = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessesKey = PublicMethed.getFinalAddress(testWitnesses); - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = - "Sendcoin,use owner address sign, not meet all requirements.Then use " - + " active address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_47() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - final Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - long balance = test001AddressAccount.getBalance(); - logger.info("balance:" + balance); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":2,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - final Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - long balance1 = test001AddressAccount1.getBalance(); - logger.info("balance1:" + balance1); - - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("NOT_ENOUGH_PERMISSION")); - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey3, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Signature count is 2 more than key counts of permission : 1")); - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("SIGERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert - .assertThat(returnResult2.getMessage().toStringUtf8(), - containsString( - "Signature count is 2 more than key counts of permission : 1")); - Assert.assertEquals(balance1, balance3); - } - - - @Test(enabled = true, description = - "Sendcoin,use owner address sign, not meet all requirements.Then use " - + " active address to sign, not meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_48() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + 1000000; - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - final Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - long balance = test001AddressAccount.getBalance(); - logger.info("balance:" + balance); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":2,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - final Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - long balance1 = test001AddressAccount1.getBalance(); - logger.info("balance1:" + balance1); - - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("NOT_ENOUGH_PERMISSION")); - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey3, 2, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("PERMISSION_ERROR")); - Assert - .assertThat(transactionSignWeight1.getResult().getMessage(), - containsString("Permission denied")); - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Assert - .assertThat(returnResult2.getCode().toString(), containsString("SIGERROR")); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert - .assertThat(returnResult2.getMessage().toStringUtf8(), - containsString( - "Permission denied")); - Assert.assertEquals(balance1, balance3); - } - - @Test(enabled = true, description = - "Sendcoin,use owner address sign, not meet all requirements.Then use " - + " owner address to sign, meet all requirements,broadcastTransaction.") - public void testMultiUpdatepermissions_49() { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] test001Address = ecKey.getAddress(); - long amount = updateAccountPermissionFee + multiSignFee + 1000000; - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, amount, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - final Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - long balance = test001AddressAccount.getBalance(); - logger.info("balance:" + balance); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":2,\"keys\":[{\"address\":" - + "\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":" - + "\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString)); - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - final Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - long balance1 = test001AddressAccount1.getBalance(); - logger.info("balance1:" + balance1); - - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - Assert.assertEquals(balance - balance1, updateAccountPermissionFee); - - Transaction transaction = PublicMethedForMutiSign - .sendcoinWithPermissionIdNotSign(fromAddress, 1L, test001Address, 0, dev001Key, - blockingStubFull); - - Transaction transaction1 = PublicMethed - .addTransactionSign(transaction, dev001Key, blockingStubFull); - TransactionSignWeight transactionSignWeight = PublicMethedForMutiSign - .getTransactionSignWeight(transaction1, blockingStubFull); - logger.info("transactionSignWeight:" + transactionSignWeight); - Assert - .assertThat(transactionSignWeight.getResult().getCode().toString(), - containsString("NOT_ENOUGH_PERMISSION")); - Transaction transaction2 = PublicMethedForMutiSign - .addTransactionSignWithPermissionId(transaction1, sendAccountKey2, 0, blockingStubFull); - TransactionSignWeight transactionSignWeight1 = PublicMethedForMutiSign - .getTransactionSignWeight(transaction2, blockingStubFull); - logger.info("transaction1:" + transactionSignWeight1); - Assert - .assertThat(transactionSignWeight1.getResult().getCode().toString(), - containsString("ENOUGH_PERMISSION")); - Return returnResult2 = PublicMethedForMutiSign - .broadcastTransaction1(transaction2, blockingStubFull); - logger.info("returnResult2:" + returnResult2); - Account test001AddressAccount3 = PublicMethed.queryAccount(test001Address, blockingStubFull); - long balance3 = test001AddressAccount3.getBalance(); - Assert.assertEquals(balance1 - balance3, multiSignFee + 1); - Assert.assertTrue(returnResult2.getResult()); - } - - /** - * constructor. - */ - - private Transaction setReference(Transaction transaction, long blockNum, - byte[] blockHash) { - byte[] refBlockNum = ByteArray.fromLong(blockNum); - Transaction.raw rawData = transaction.getRawData().toBuilder() - .setRefBlockHash(ByteString.copyFrom(blockHash)) - .setRefBlockBytes(ByteString.copyFrom(refBlockNum)) - .build(); - return transaction.toBuilder().setRawData(rawData).build(); - } - - - /** - * constructor. - */ - - public Transaction setExpiration(Transaction transaction, long expiration) { - Transaction.raw rawData = transaction.getRawData().toBuilder().setExpiration(expiration) - .build(); - return transaction.toBuilder().setRawData(rawData).build(); - } - - - /** - * constructor. - */ - - public Transaction createTransaction(com.google.protobuf.Message message, - ContractType contractType) { - Transaction.raw.Builder transactionBuilder = Transaction.raw.newBuilder().addContract( - Transaction.Contract.newBuilder().setType(contractType).setParameter( - Any.pack(message)).build()); - - Transaction transaction = Transaction.newBuilder().setRawData(transactionBuilder.build()) - .build(); - - long time = System.currentTimeMillis(); - AtomicLong count = new AtomicLong(); - long gtime = count.incrementAndGet() + time; - String ref = "" + gtime; - - transaction = setReference(transaction, gtime, ByteArray.fromString(ref)); - - transaction = setExpiration(transaction, gtime); - - return transaction; - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign006.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign006.java deleted file mode 100644 index 7e31a392520..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign006.java +++ /dev/null @@ -1,357 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey001 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress01 = PublicMethed.getFinalAddress(testKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private static final long now = System.currentTimeMillis(); - private static String name = "MutiSign001_" + Long.toString(now); - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] participateAddress = ecKey4.getAddress(); - String participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false) - public void testMutiSign1CreateAssetissue() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 3; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin + 2048000000L, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = ownerKey; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - - Long start = System.currentTimeMillis() + 5000; - Long end = System.currentTimeMillis() + 1000000000; - logger.info("try create asset issue"); - - txid = PublicMethedForMutiSign - .createAssetIssueForTransactionId1(ownerAddress, name, totalSupply, 1, - 1, start, end, 1, description, url, 2000L, 2000L, - 1L, 1L, ownerKey, blockingStubFull, 2, permissionKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee + 1024_000000L); - - logger.info(" create asset end"); - } - - /** - * constructor. - */ - - @Test(enabled = false) - public void testMutiSign2TransferAssetissue() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.printAddress(manager1Key); - Account getAssetIdFromOwnerAccount; - getAssetIdFromOwnerAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - assetAccountId1 = getAssetIdFromOwnerAccount.getAssetIssuedID(); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - String txid = PublicMethedForMutiSign.transferAssetForTransactionId1(manager1Address, - assetAccountId1.toByteArray(), 10, ownerAddress, ownerKey, blockingStubFull, - 2, permissionKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - /** - * constructor. - */ - - @Test(enabled = false) - public void testMutiSign3ParticipateAssetissue() { - ecKey4 = new ECKey(Utils.getRandom()); - participateAddress = ecKey4.getAddress(); - participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 2; - - Assert.assertTrue( - PublicMethed.sendcoin(participateAddress, needCoin + 2048000000L, fromAddress, testKey002, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - ownerKeyString[0] = participateKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(participateKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, participateAddress, - participateKey, blockingStubFull, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - - txid = PublicMethedForMutiSign.participateAssetIssueForTransactionId(ownerAddress, - assetAccountId1.toByteArray(), 10, participateAddress, participateKey, 2, - blockingStubFull, permissionKeyString); - - Assert.assertNotNull(txid); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee + 10); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - /** - * constructor. - */ - - @Test(enabled = false) - public void testMutiSign4updateAssetissue() { - url = "MutiSign001_update_url" + Long.toString(now); - ownerKeyString[0] = ownerKey; - description = "MutiSign001_update_description" + Long.toString(now); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - String txid = PublicMethedForMutiSign - .updateAssetForTransactionId(ownerAddress, description.getBytes(), url.getBytes(), 100L, - 100L, ownerKey, 2, blockingStubFull, permissionKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - - /** - * constructor. - */ - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign007.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign007.java deleted file mode 100644 index 5d2f1abc6cb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign007.java +++ /dev/null @@ -1,226 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[3]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] newAddress = ecKey4.getAddress(); - String newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false) - public void testMutiSignForAccount() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - ecKey4 = new ECKey(Utils.getRandom()); - newAddress = ecKey4.getAddress(); - newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 10; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - ownerKeyString[2] = manager2Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":3,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - final String updateName = Long.toString(System.currentTimeMillis()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - byte[] accountName = "11z2112310".getBytes(); - Assert.assertTrue(PublicMethedForMutiSign.createAccount1( - ownerAddress, newAddress, ownerKey, blockingStubFull, 2, permissionKeyString)); - Assert.assertTrue( - PublicMethedForMutiSign.setAccountId1(accountName, - ownerAddress, ownerKey, 2, blockingStubFull, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.sendcoinWithPermissionId( - newAddress, 100L, ownerAddress, 2, ownerKey, blockingStubFull, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceWithPermissionId( - ownerAddress, 1000000L, 0, 2, ownerKey, blockingStubFull, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceGetEnergyWithPermissionId( - ownerAddress, 1000000L, 0, 1, ownerKey, blockingStubFull, 2, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceForReceiverWithPermissionId( - ownerAddress, 1000000L, 0, 0, ByteString.copyFrom(newAddress), - ownerKey, blockingStubFull, 2, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.unFreezeBalanceWithPermissionId( - ownerAddress, ownerKey, 0, null, 2, blockingStubFull, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.unFreezeBalanceWithPermissionId( - ownerAddress, ownerKey, 0, newAddress, 2, blockingStubFull, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.updateAccountWithPermissionId( - ownerAddress, updateName.getBytes(), ownerKey, blockingStubFull, 2, permissionKeyString)); - - String voteStr = Base58.encode58Check(witnessAddress); - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - Assert.assertTrue(PublicMethedForMutiSign.voteWitnessWithPermissionId( - smallVoteMap, ownerAddress, ownerKey, blockingStubFull, 2, permissionKeyString)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, multiSignFee * 10 + 1000000 + 100); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - - } - - /** - * constructor. - */ - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public static byte[] randomBytes(int length) { - // generate the random number - byte[] result = new byte[length]; - new Random().nextBytes(result); - result[0] = Wallet.getAddressPreFixByte(); - return result; - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign008.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign008.java deleted file mode 100644 index fbb8bd9c709..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign008.java +++ /dev/null @@ -1,204 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign008 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - ArrayList txidList = new ArrayList(); - - Optional infoById = null; - Long beforeTime; - Long afterTime; - Long beforeBlockNum; - Long afterBlockNum; - Block currentBlock; - Long currentBlockNum; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = false, threadPoolSize = 1, invocationCount = 1) - public void testMutiSignForSmartContract() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needcoin = updateAccountPermissionFee + multiSignFee * 4; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needcoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 1, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - randNum = rand.nextInt(4000); - - Long maxFeeLimit = 1000000000L; - String contractName = "StorageAndCpu" + Integer.toString(randNum); - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestStorageAndCpu_storageAndCpu"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestStorageAndCpu_storageAndCpu"); - byte[] contractAddress = PublicMethedForMutiSign.deployContract1(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, ownerKey, ownerAddress, blockingStubFull, 2, permissionKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString() != null); - String txid; - String initParmes = "\"" + "930" + "\""; - txid = PublicMethedForMutiSign.triggerContract1(contractAddress, - "testUseCpu(uint256)", initParmes, false, - 0, maxFeeLimit, ownerAddress, ownerKey, blockingStubFull, 2, permissionKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.getTransactionById(txid, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue( - PublicMethedForMutiSign.updateSettingWithPermissionId(contractAddress, 50, ownerKey, - ownerAddress, 2, blockingStubFull, permissionKeyString)); - Assert.assertTrue( - PublicMethedForMutiSign.updateEnergyLimitWithPermissionId(contractAddress, 50, ownerKey, - ownerAddress, 2, blockingStubFull, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, ownerAddress, blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign009.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign009.java deleted file mode 100644 index 12fc3279d43..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign009.java +++ /dev/null @@ -1,181 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - - -@Slf4j -public class WalletTestMutiSign009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[1]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false) - public void testMutiSignForProposal() { - long needcoin = updateAccountPermissionFee + multiSignFee * 3; - Assert.assertTrue(PublicMethed.sendcoin(witness001Address, needcoin + 10000000L, - fromAddress, testKey002, blockingStubFull)); - - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(witness001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = witnessKey001; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"owner\",\"threshold\":1,\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate( - accountPermissionJson, witness001Address, witnessKey001, - blockingStubFull, ownerKeyString); - - //Create a proposal - - PublicMethed.waitProduceNextBlock(blockingStubFull); - HashMap proposalMap = new HashMap(); - proposalMap.put(0L, 81000L); - Assert.assertTrue( - PublicMethedForMutiSign.createProposalWithPermissionId(witness001Address, witnessKey001, - proposalMap, 2, blockingStubFull, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Get proposal list - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer proposalId = listProposals.get().getProposalsCount(); - logger.info(Integer.toString(proposalId)); - - Assert.assertTrue(PublicMethedForMutiSign.approveProposalWithPermission( - witness001Address, witnessKey001, proposalId, - true, 2, blockingStubFull, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Delete proposal list after approve - Assert.assertTrue(PublicMethedForMutiSign.deleteProposalWithPermissionId( - witness001Address, witnessKey001, proposalId, 2, blockingStubFull, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(witness001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertTrue(balanceBefore - balanceAfter >= needcoin); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign010.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign010.java deleted file mode 100644 index 3d581e1ae4b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign010.java +++ /dev/null @@ -1,427 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.ExchangeList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Exchange; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign010 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - - private static final long now = System.currentTimeMillis(); - private static String name1 = "exchange001_1_" + Long.toString(now); - private static String name2 = "exchange001_2_" + Long.toString(now); - private static final long totalSupply = 1000000001L; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] exchange001Address = ecKey1.getAddress(); - String exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] secondExchange001Address = ecKey2.getAddress(); - String secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - Long secondTransferAssetToFirstAccountNum = 100000000L; - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey3.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey4.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[3]; - String accountPermissionJson = ""; - - - Account firstAccount; - ByteString assetAccountId1; - ByteString assetAccountId2; - - Optional listExchange; - Optional exchangeIdInfo; - Integer exchangeId = 0; - Integer exchangeRate = 10; - Long firstTokenInitialBalance = 10000L; - Long secondTokenInitialBalance = firstTokenInitialBalance * exchangeRate; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "MutiSign for create token") - public void test1CreateUsedAsset() { - ecKey1 = new ECKey(Utils.getRandom()); - exchange001Address = ecKey1.getAddress(); - exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - secondExchange001Address = ecKey2.getAddress(); - secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(exchange001Key); - PublicMethed.printAddress(secondExchange001Key); - - Assert.assertTrue(PublicMethed.sendcoin(exchange001Address, 10240000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(secondExchange001Address, 10240000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(exchange001Address), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long start = System.currentTimeMillis() + 5000L; - Long end = System.currentTimeMillis() + 5000000L; - Assert.assertTrue(PublicMethed.createAssetIssue(exchange001Address, name1, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, exchange001Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.createAssetIssue(secondExchange001Address, name2, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, secondExchange001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = false, description = "MutiSign for create exchange") - public void test2CreateExchange() { - ecKey3 = new ECKey(Utils.getRandom()); - manager1Address = ecKey3.getAddress(); - manager1Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ecKey4 = new ECKey(Utils.getRandom()); - manager2Address = ecKey4.getAddress(); - manager2Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - final long needCoin = updateAccountPermissionFee + multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = exchange001Key; - ownerKeyString[1] = manager1Key; - ownerKeyString[2] = manager2Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":3,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(exchange001Key) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate( - accountPermissionJson, exchange001Address, exchange001Key, - blockingStubFull, ownerKeyString); - - listExchange = PublicMethed.getExchangeList(blockingStubFull); - final Integer beforeCreateExchangeNum = listExchange.get().getExchangesCount(); - exchangeId = listExchange.get().getExchangesCount(); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - assetAccountId1 = getAssetIdFromThisAccount.getAssetIssuedID(); - - getAssetIdFromThisAccount = PublicMethed - .queryAccount(secondExchange001Address, blockingStubFull); - assetAccountId2 = getAssetIdFromThisAccount.getAssetIssuedID(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long token1BeforeBalance = 0L; - for (String name : firstAccount.getAssetMap().keySet()) { - token1BeforeBalance = firstAccount.getAssetMap().get(name); - } - Assert.assertTrue(PublicMethed.transferAsset(exchange001Address, assetAccountId2.toByteArray(), - secondTransferAssetToFirstAccountNum, secondExchange001Address, - secondExchange001Key, blockingStubFull)); - Long token2BeforeBalance = secondTransferAssetToFirstAccountNum; - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //logger.info("name1 is " + name1); - //logger.info("name2 is " + name2); - //logger.info("first balance is " + Long.toString(token1BeforeBalance)); - //logger.info("second balance is " + token2BeforeBalance.toString()); - //CreateExchange - Assert.assertTrue( - PublicMethedForMutiSign.exchangeCreate1( - assetAccountId1.toByteArray(), firstTokenInitialBalance, - assetAccountId2.toByteArray(), secondTokenInitialBalance, exchange001Address, - exchange001Key, blockingStubFull, 2, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - listExchange = PublicMethed.getExchangeList(blockingStubFull); - exchangeId = listExchange.get().getExchangesCount(); - - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1024_000_000L); - - } - - - @Test(enabled = false, description = "Mutisign for inject exchange") - public void test4InjectExchange() { - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - final long needCoin = multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer injectBalance = 100; - Assert.assertTrue( - PublicMethedForMutiSign.injectExchange1( - exchangeId, assetAccountId1.toByteArray(), injectBalance, - exchange001Address, exchange001Key, blockingStubFull, 2, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(beforeToken1Balance - afterToken1Balance == injectBalance); - Assert.assertTrue(beforeToken2Balance - afterToken2Balance == injectBalance - * exchangeRate); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == injectBalance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == injectBalance * exchangeRate); - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = false, description = "MutiSign for withdraw exchange") - public void test5WithdrawExchange() { - final long needCoin = multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer withdrawNum = 200; - Assert.assertTrue( - PublicMethedForMutiSign.exchangeWithdraw1( - exchangeId, assetAccountId1.toByteArray(), withdrawNum, - exchange001Address, exchange001Key, blockingStubFull, 2, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(afterToken1Balance - beforeToken1Balance == withdrawNum); - Assert.assertTrue(afterToken2Balance - beforeToken2Balance == withdrawNum - * exchangeRate); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == -withdrawNum); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == -withdrawNum * exchangeRate); - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = false, description = "MutiSign for transaction exchange") - public void test6TransactionExchange() { - final long needCoin = multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("beforeExchangeToken1Balance" + beforeExchangeToken1Balance); - logger.info("beforeExchangeToken2Balance" + beforeExchangeToken2Balance); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer transactionNum = 50; - Assert.assertTrue( - PublicMethedForMutiSign - .exchangeTransaction1(exchangeId, assetAccountId1.toByteArray(), transactionNum, 1, - exchange001Address, exchange001Key, blockingStubFull, 2, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("afterExchangeToken1Balance" + afterExchangeToken1Balance); - logger.info("afterExchangeToken2Balance" + afterExchangeToken2Balance); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == beforeToken1Balance - afterToken1Balance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == beforeToken2Balance - afterToken2Balance); - - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign011.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign011.java deleted file mode 100644 index 78c04377d22..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign011.java +++ /dev/null @@ -1,201 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey001 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress01 = PublicMethed.getFinalAddress(testKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private static final long now = System.currentTimeMillis(); - private static String name = "MutiSign001_" + Long.toString(now); - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] participateAddress = ecKey4.getAddress(); - String participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false) - public void testMutiSign1UpdatePermission() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needCoin = updateAccountPermissionFee * 2 + multiSignFee * 3; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = ownerKey; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId1(accountPermissionJson1, ownerAddress, ownerKey, - blockingStubFull, 2, permissionKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - - } - - - /** - * constructor. - */ - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign012.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign012.java deleted file mode 100644 index c050f9c6e8f..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign012.java +++ /dev/null @@ -1,357 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign012 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey001 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress01 = PublicMethed.getFinalAddress(testKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private static final long now = System.currentTimeMillis(); - private static String name = "MutiSign001_" + Long.toString(now); - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] participateAddress = ecKey4.getAddress(); - String participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false) - public void testMutiSign1CreateAssetissue() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 3; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin + 2048000000L, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = ownerKey; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - - Long start = System.currentTimeMillis() + 5000; - Long end = System.currentTimeMillis() + 1000000000; - logger.info("try create asset issue"); - - txid = PublicMethedForMutiSign - .createAssetIssueForTransactionId1(ownerAddress, name, totalSupply, 1, - 1, start, end, 1, description, url, 2000L, 2000L, - 1L, 1L, ownerKey, blockingStubFull, 0, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee + 1024_000000L); - - logger.info(" create asset end"); - } - - /** - * constructor. - */ - - @Test(enabled = false) - public void testMutiSign2TransferAssetissue() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.printAddress(manager1Key); - Account getAssetIdFromOwnerAccount; - getAssetIdFromOwnerAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - assetAccountId1 = getAssetIdFromOwnerAccount.getAssetIssuedID(); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - String txid = PublicMethedForMutiSign.transferAssetForTransactionId1(manager1Address, - assetAccountId1.toByteArray(), 10, ownerAddress, ownerKey, blockingStubFull, - 0, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - /** - * constructor. - */ - - @Test(enabled = false) - public void testMutiSign3ParticipateAssetissue() { - ecKey4 = new ECKey(Utils.getRandom()); - participateAddress = ecKey4.getAddress(); - participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 2; - - Assert.assertTrue( - PublicMethed.sendcoin(participateAddress, needCoin + 2048000000L, fromAddress, testKey002, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - ownerKeyString[0] = participateKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(participateKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, participateAddress, - participateKey, blockingStubFull, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - - txid = PublicMethedForMutiSign.participateAssetIssueForTransactionId(ownerAddress, - assetAccountId1.toByteArray(), 10, participateAddress, participateKey, 0, - blockingStubFull, ownerKeyString); - - Assert.assertNotNull(txid); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee + 10); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - /** - * constructor. - */ - - @Test(enabled = false) - public void testMutiSign4updateAssetissue() { - url = "MutiSign001_update_url" + Long.toString(now); - ownerKeyString[0] = ownerKey; - description = "MutiSign001_update_description" + Long.toString(now); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - String txid = PublicMethedForMutiSign - .updateAssetForTransactionId(ownerAddress, description.getBytes(), url.getBytes(), 100L, - 100L, ownerKey, 0, blockingStubFull, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - - /** - * constructor. - */ - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign013.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign013.java deleted file mode 100644 index 10bb0f7fa92..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign013.java +++ /dev/null @@ -1,226 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign013 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[3]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] newAddress = ecKey4.getAddress(); - String newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false) - public void testMutiSignForAccount() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - ecKey4 = new ECKey(Utils.getRandom()); - newAddress = ecKey4.getAddress(); - newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 10; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - ownerKeyString[2] = manager2Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":3,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - final String updateName = Long.toString(System.currentTimeMillis()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - byte[] accountName = "11z2122328".getBytes(); - Assert.assertTrue(PublicMethedForMutiSign.createAccount1( - ownerAddress, newAddress, ownerKey, blockingStubFull, 0, ownerKeyString)); - Assert.assertTrue( - PublicMethedForMutiSign.setAccountId1(accountName, - ownerAddress, ownerKey, 0, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.sendcoinWithPermissionId( - newAddress, 100L, ownerAddress, 0, ownerKey, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceWithPermissionId( - ownerAddress, 1000000L, 0, 0, ownerKey, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceGetEnergyWithPermissionId( - ownerAddress, 1000000L, 0, 1, ownerKey, blockingStubFull, 0, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceForReceiverWithPermissionId( - ownerAddress, 1000000L, 0, 0, ByteString.copyFrom(newAddress), - ownerKey, blockingStubFull, 0, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.unFreezeBalanceWithPermissionId( - ownerAddress, ownerKey, 0, null, 0, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.unFreezeBalanceWithPermissionId( - ownerAddress, ownerKey, 0, newAddress, 0, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.updateAccountWithPermissionId( - ownerAddress, updateName.getBytes(), ownerKey, blockingStubFull, 0, ownerKeyString)); - - String voteStr = Base58.encode58Check(witnessAddress); - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - Assert.assertTrue(PublicMethedForMutiSign.voteWitnessWithPermissionId( - smallVoteMap, ownerAddress, ownerKey, blockingStubFull, 0, ownerKeyString)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, multiSignFee * 10 + 1000000 + 100); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - - } - - /** - * constructor. - */ - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public static byte[] randomBytes(int length) { - // generate the random number - byte[] result = new byte[length]; - new Random().nextBytes(result); - result[0] = Wallet.getAddressPreFixByte(); - return result; - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign014.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign014.java deleted file mode 100644 index 7fe7948c67a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign014.java +++ /dev/null @@ -1,204 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign014 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - ArrayList txidList = new ArrayList(); - - Optional infoById = null; - Long beforeTime; - Long afterTime; - Long beforeBlockNum; - Long afterBlockNum; - Block currentBlock; - Long currentBlockNum; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = false, threadPoolSize = 1, invocationCount = 1) - public void testMutiSignForSmartContract() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needcoin = updateAccountPermissionFee + multiSignFee * 4; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needcoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 1, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - randNum = rand.nextInt(4000); - - Long maxFeeLimit = 1000000000L; - String contractName = "StorageAndCpu" + Integer.toString(randNum); - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestStorageAndCpu_storageAndCpu"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestStorageAndCpu_storageAndCpu"); - byte[] contractAddress = PublicMethedForMutiSign.deployContract1(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, ownerKey, ownerAddress, blockingStubFull, 0, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString() != null); - String txid; - String initParmes = "\"" + "930" + "\""; - txid = PublicMethedForMutiSign.triggerContract1(contractAddress, - "testUseCpu(uint256)", initParmes, false, - 0, maxFeeLimit, ownerAddress, ownerKey, blockingStubFull, 0, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.getTransactionById(txid, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue( - PublicMethedForMutiSign.updateSettingWithPermissionId(contractAddress, 50, ownerKey, - ownerAddress, 0, blockingStubFull, ownerKeyString)); - Assert.assertTrue( - PublicMethedForMutiSign.updateEnergyLimitWithPermissionId(contractAddress, 50, ownerKey, - ownerAddress, 0, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, ownerAddress, blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign015.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign015.java deleted file mode 100644 index 650d99da7cb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign015.java +++ /dev/null @@ -1,182 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - - -@Slf4j -public class WalletTestMutiSign015 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false) - public void testMutiSignForProposal() { - long needcoin = updateAccountPermissionFee + multiSignFee * 5; - Assert.assertTrue(PublicMethed.sendcoin(witness001Address, needcoin + 10000000L, - fromAddress, testKey002, blockingStubFull)); - - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(witness001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = witnessKey001; - ownerKeyString[1] = testKey002; - - accountPermissionJson = "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\"" - + ",\"threshold\":2,\"keys\":[{\"address\":\"" + PublicMethed - .getAddressString(witnessKey001) + "\"," - + "\"weight\":1},{\"address\":\"" + PublicMethed.getAddressString(testKey002) - + "\",\"weight\":1}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"owner\",\"threshold\":1," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0037e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(manager1Key) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}]}]} "; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate( - accountPermissionJson, witness001Address, witnessKey001, - blockingStubFull, ownerKeyString); - - //Create a proposal - - PublicMethed.waitProduceNextBlock(blockingStubFull); - HashMap proposalMap = new HashMap(); - proposalMap.put(0L, 81000L); - Assert.assertTrue( - PublicMethedForMutiSign.createProposalWithPermissionId(witness001Address, witnessKey001, - proposalMap, 0, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Get proposal list - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer proposalId = listProposals.get().getProposalsCount(); - logger.info(Integer.toString(proposalId)); - - Assert.assertTrue(PublicMethedForMutiSign.approveProposalWithPermission( - witness001Address, witnessKey001, proposalId, - true, 0, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Delete proposal list after approve - Assert.assertTrue(PublicMethedForMutiSign.deleteProposalWithPermissionId( - witness001Address, witnessKey001, proposalId, 0, blockingStubFull, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(witness001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign016.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign016.java deleted file mode 100644 index df6245574f8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign016.java +++ /dev/null @@ -1,427 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.ExchangeList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Exchange; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign016 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - - private static final long now = System.currentTimeMillis(); - private static String name1 = "exchange001_1_" + Long.toString(now); - private static String name2 = "exchange001_2_" + Long.toString(now); - private static final long totalSupply = 1000000001L; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] exchange001Address = ecKey1.getAddress(); - String exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] secondExchange001Address = ecKey2.getAddress(); - String secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - Long secondTransferAssetToFirstAccountNum = 100000000L; - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey3.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey4.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[3]; - String accountPermissionJson = ""; - - - Account firstAccount; - ByteString assetAccountId1; - ByteString assetAccountId2; - - Optional listExchange; - Optional exchangeIdInfo; - Integer exchangeId = 0; - Integer exchangeRate = 10; - Long firstTokenInitialBalance = 10000L; - Long secondTokenInitialBalance = firstTokenInitialBalance * exchangeRate; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "MutiSign for create token") - public void test1CreateUsedAsset() { - ecKey1 = new ECKey(Utils.getRandom()); - exchange001Address = ecKey1.getAddress(); - exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - secondExchange001Address = ecKey2.getAddress(); - secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(exchange001Key); - PublicMethed.printAddress(secondExchange001Key); - - Assert.assertTrue(PublicMethed.sendcoin(exchange001Address, 10240000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(secondExchange001Address, 10240000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 100000000000L, 0, 0, - ByteString.copyFrom(exchange001Address), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long start = System.currentTimeMillis() + 5000L; - Long end = System.currentTimeMillis() + 5000000L; - Assert.assertTrue(PublicMethed.createAssetIssue(exchange001Address, name1, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, exchange001Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.createAssetIssue(secondExchange001Address, name2, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, secondExchange001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = false, description = "MutiSign for create exchange") - public void test2CreateExchange() { - ecKey3 = new ECKey(Utils.getRandom()); - manager1Address = ecKey3.getAddress(); - manager1Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ecKey4 = new ECKey(Utils.getRandom()); - manager2Address = ecKey4.getAddress(); - manager2Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - final long needCoin = updateAccountPermissionFee + multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = exchange001Key; - ownerKeyString[1] = manager1Key; - ownerKeyString[2] = manager2Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":3,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(exchange001Key) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate( - accountPermissionJson, exchange001Address, exchange001Key, - blockingStubFull, ownerKeyString); - - listExchange = PublicMethed.getExchangeList(blockingStubFull); - final Integer beforeCreateExchangeNum = listExchange.get().getExchangesCount(); - exchangeId = listExchange.get().getExchangesCount(); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - assetAccountId1 = getAssetIdFromThisAccount.getAssetIssuedID(); - - getAssetIdFromThisAccount = PublicMethed - .queryAccount(secondExchange001Address, blockingStubFull); - assetAccountId2 = getAssetIdFromThisAccount.getAssetIssuedID(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long token1BeforeBalance = 0L; - for (String name : firstAccount.getAssetMap().keySet()) { - token1BeforeBalance = firstAccount.getAssetMap().get(name); - } - Assert.assertTrue(PublicMethed.transferAsset(exchange001Address, assetAccountId2.toByteArray(), - secondTransferAssetToFirstAccountNum, secondExchange001Address, - secondExchange001Key, blockingStubFull)); - Long token2BeforeBalance = secondTransferAssetToFirstAccountNum; - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //logger.info("name1 is " + name1); - //logger.info("name2 is " + name2); - //logger.info("first balance is " + Long.toString(token1BeforeBalance)); - //logger.info("second balance is " + token2BeforeBalance.toString()); - //CreateExchange - Assert.assertTrue( - PublicMethedForMutiSign.exchangeCreate1( - assetAccountId1.toByteArray(), firstTokenInitialBalance, - assetAccountId2.toByteArray(), secondTokenInitialBalance, exchange001Address, - exchange001Key, blockingStubFull, 0, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - listExchange = PublicMethed.getExchangeList(blockingStubFull); - exchangeId = listExchange.get().getExchangesCount(); - - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin + 1024_000_000L); - - } - - - @Test(enabled = false, description = "Mutisign for inject exchange") - public void test4InjectExchange() { - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - final long needCoin = multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer injectBalance = 100; - Assert.assertTrue( - PublicMethedForMutiSign.injectExchange1( - exchangeId, assetAccountId1.toByteArray(), injectBalance, - exchange001Address, exchange001Key, blockingStubFull, 0, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(beforeToken1Balance - afterToken1Balance == injectBalance); - Assert.assertTrue(beforeToken2Balance - afterToken2Balance == injectBalance - * exchangeRate); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == injectBalance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == injectBalance * exchangeRate); - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - @Test(enabled = false, description = "MutiSign for withdraw exchange") - public void test5WithdrawExchange() { - final long needCoin = multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer withdrawNum = 200; - Assert.assertTrue( - PublicMethedForMutiSign.exchangeWithdraw1( - exchangeId, assetAccountId1.toByteArray(), withdrawNum, - exchange001Address, exchange001Key, blockingStubFull, 0, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(afterToken1Balance - beforeToken1Balance == withdrawNum); - Assert.assertTrue(afterToken2Balance - beforeToken2Balance == withdrawNum - * exchangeRate); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == -withdrawNum); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == -withdrawNum * exchangeRate); - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - - } - - @Test(enabled = false, description = "MutiSign for transaction exchange") - public void test6TransactionExchange() { - final long needCoin = multiSignFee; - Long balanceBefore = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("beforeExchangeToken1Balance" + beforeExchangeToken1Balance); - logger.info("beforeExchangeToken2Balance" + beforeExchangeToken2Balance); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer transactionNum = 50; - Assert.assertTrue( - PublicMethedForMutiSign - .exchangeTransaction1(exchangeId, assetAccountId1.toByteArray(), transactionNum, 1, - exchange001Address, exchange001Key, blockingStubFull, 0, ownerKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("afterExchangeToken1Balance" + afterExchangeToken1Balance); - logger.info("afterExchangeToken2Balance" + afterExchangeToken2Balance); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == beforeToken1Balance - afterToken1Balance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == beforeToken2Balance - afterToken2Balance); - - Long balanceAfter = PublicMethed.queryAccount(exchange001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, needCoin); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign017.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign017.java deleted file mode 100644 index 4975bf34cd2..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign017.java +++ /dev/null @@ -1,201 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign017 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey001 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress01 = PublicMethed.getFinalAddress(testKey001); - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private static final long now = System.currentTimeMillis(); - private static String name = "MutiSign001_" + Long.toString(now); - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] participateAddress = ecKey4.getAddress(); - String participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = false) - public void testMutiSign1UpdatePermission() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needCoin = updateAccountPermissionFee * 2 + multiSignFee * 3; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - String[] permissionKeyString1 = new String[1]; - permissionKeyString1[0] = ownerKey; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}" - + "]}]}"; - txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId1(accountPermissionJson1, ownerAddress, ownerKey, - blockingStubFull, 0, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - - } - - - /** - * constructor. - */ - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign018.java b/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign018.java deleted file mode 100644 index 3cb68cb9928..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign018.java +++ /dev/null @@ -1,321 +0,0 @@ -package stest.tron.wallet.dailybuild.operationupdate; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign018 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - private final String operations = Configuration.getByPath("testng.conf") - .getString("defaultParameter.operations"); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - ArrayList txidList = new ArrayList(); - - Optional infoById = null; - Long beforeTime; - Long afterTime; - Long beforeBlockNum; - Long afterBlockNum; - Block currentBlock; - Long currentBlockNum; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = false, threadPoolSize = 1, invocationCount = 1) - public void test1MutiSignForClearContractAbi() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needcoin = updateAccountPermissionFee + multiSignFee * 4; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needcoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 1, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operations + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - Long maxFeeLimit = 1000000000L; - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethedForMutiSign.deployContract1(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, ownerKey, ownerAddress, blockingStubFull, 2, permissionKeyString); - logger.info("address:" + Base58.encode58Check(contractAddress)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString() != null); - Assert.assertTrue(PublicMethedForMutiSign - .clearContractAbi(contractAddress, ownerAddress, ownerKey, - blockingStubFull, 2, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, ownerAddress, blockingStubFull)); - } - - @Test(enabled = false, threadPoolSize = 1, invocationCount = 1) - public void test2MutiSignForClearContractAbiForDefault() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needcoin = updateAccountPermissionFee + multiSignFee * 4; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needcoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 1, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - String operationsDefault = "7fff1fc0034e0100000000000000000000000000000000000000000000000000"; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"" + operationsDefault + "\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - Long maxFeeLimit = 1000000000L; - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethedForMutiSign.deployContract1(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, ownerKey, ownerAddress, blockingStubFull, 2, permissionKeyString); - logger.info("address:" + Base58.encode58Check(contractAddress)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString() != null); - Assert.assertTrue(PublicMethedForMutiSign - .clearContractAbi(contractAddress, ownerAddress, ownerKey, - blockingStubFull, 2, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, ownerAddress, blockingStubFull)); - } - - - @Test(enabled = false, threadPoolSize = 1, invocationCount = 1) - public void test3MutiSignForClearContractAbiForDefault() { - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needcoin = updateAccountPermissionFee + multiSignFee * 4; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needcoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 1, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - String[] activeDefaultKeyString = new String[1]; - - activeDefaultKeyString[0] = ownerKey; - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long maxFeeLimit = 1000000000L; - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethedForMutiSign.deployContract1(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, ownerKey, ownerAddress, blockingStubFull, 2, activeDefaultKeyString); - logger.info("address:" + Base58.encode58Check(contractAddress)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString() != null); - Assert.assertTrue(PublicMethedForMutiSign - .clearContractAbi(contractAddress, ownerAddress, ownerKey, - blockingStubFull, 2, activeDefaultKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, ownerAddress, blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/originenergylimit/ContractOriginEnergyLimit001.java b/src/test/java/stest/tron/wallet/dailybuild/originenergylimit/ContractOriginEnergyLimit001.java deleted file mode 100644 index 5097810bfe7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/originenergylimit/ContractOriginEnergyLimit001.java +++ /dev/null @@ -1,155 +0,0 @@ -package stest.tron.wallet.dailybuild.originenergylimit; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractOriginEnergyLimit001 { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress3 = ecKey1.getAddress(); - String testKeyForGrammarAddress3 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress3); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - - //Origin_energy_limit001,028,029 - @Test(enabled = true, description = "Boundary value and update test") - public void testOrigin_energy_limit001() { - Assert.assertTrue(PublicMethed - .sendcoin(grammarAddress3, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/contractOriginEnergyLimit001.sol"; - String contractName = "findArgsContractTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String contractAddress = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, -1, "0", 0, - null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(contractAddress == null); - - String contractAddress1 = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 0, "0", 0, - null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - - Assert.assertTrue(contractAddress1 == null); - - byte[] contractAddress2 = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 9223372036854775807L, "0", - 0, null, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertFalse(PublicMethed.updateEnergyLimit(contractAddress2, -1L, - testKeyForGrammarAddress3, grammarAddress3, blockingStubFull)); - SmartContract smartContract = PublicMethed.getContract(contractAddress2, blockingStubFull); - Assert.assertTrue(smartContract.getOriginEnergyLimit() == 9223372036854775807L); - - Assert.assertFalse(PublicMethed.updateEnergyLimit(contractAddress2, 0L, - testKeyForGrammarAddress3, grammarAddress3, blockingStubFull)); - SmartContract smartContract1 = PublicMethed.getContract(contractAddress2, blockingStubFull); - Assert.assertTrue(smartContract1.getOriginEnergyLimit() == 9223372036854775807L); - - Assert.assertTrue(PublicMethed.updateEnergyLimit(contractAddress2, - 9223372036854775807L, testKeyForGrammarAddress3, - grammarAddress3, blockingStubFull)); - SmartContract smartContract2 = PublicMethed.getContract(contractAddress2, blockingStubFull); - Assert.assertTrue(smartContract2.getOriginEnergyLimit() == 9223372036854775807L); - - Assert.assertTrue(PublicMethed.updateEnergyLimit(contractAddress2, 'c', - testKeyForGrammarAddress3, grammarAddress3, blockingStubFull)); - SmartContract smartContract3 = PublicMethed.getContract(contractAddress2, blockingStubFull); - Assert.assertEquals(smartContract3.getOriginEnergyLimit(), 99); - - Assert.assertFalse(PublicMethed.updateEnergyLimit(contractAddress2, 1L, - testNetAccountKey, testNetAccountAddress, blockingStubFull)); - SmartContract smartContract4 = PublicMethed.getContract(contractAddress2, blockingStubFull); - Assert.assertEquals(smartContract4.getOriginEnergyLimit(), 99); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/originenergylimit/ContractOriginEnergyLimit004.java b/src/test/java/stest/tron/wallet/dailybuild/originenergylimit/ContractOriginEnergyLimit004.java deleted file mode 100644 index d12e0c4a592..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/originenergylimit/ContractOriginEnergyLimit004.java +++ /dev/null @@ -1,383 +0,0 @@ -package stest.tron.wallet.dailybuild.originenergylimit; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractOriginEnergyLimit004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - private long getAvailableFrozenEnergy(byte[] accountAddress) { - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(accountAddress, - blockingStubFull); - long energyLimit = resourceInfo.getEnergyLimit(); - long energyUsed = resourceInfo.getEnergyUsed(); - return energyLimit - energyUsed; - } - - private long getUserAvailableEnergy(byte[] userAddress) { - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(userAddress, - blockingStubFull); - Account info = PublicMethed.queryAccount(userAddress, blockingStubFull); - long balance = info.getBalance(); - long energyLimit = resourceInfo.getEnergyLimit(); - long userAvaliableFrozenEnergy = getAvailableFrozenEnergy(userAddress); - return balance / 100 + userAvaliableFrozenEnergy; - } - - private long getFeeLimit(String txid) { - Optional trsById = PublicMethed.getTransactionById(txid, blockingStubFull); - return trsById.get().getRawData().getFeeLimit(); - } - - private long getUserMax(byte[] userAddress, long feelimit) { - logger.info("User feeLimit: " + feelimit / 100); - logger.info("User UserAvaliableEnergy: " + getUserAvailableEnergy(userAddress)); - return Math.min(feelimit / 100, getUserAvailableEnergy(userAddress)); - } - - private long getOriginalEnergyLimit(byte[] contractAddress) { - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - return smartContract.getOriginEnergyLimit(); - } - - private long getConsumeUserResourcePercent(byte[] contractAddress) { - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - return smartContract.getConsumeUserResourcePercent(); - } - - private long getDevMax(byte[] devAddress, byte[] userAddress, long feeLimit, - byte[] contractAddress) { - long devMax = Math.min(getAvailableFrozenEnergy(devAddress), - getOriginalEnergyLimit(contractAddress)); - long p = getConsumeUserResourcePercent(contractAddress); - if (p != 0) { - logger.info("p: " + p); - devMax = Math.min(devMax, getUserMax(userAddress, feeLimit) * (100 - p) / p); - logger.info("Dev byUserPercent: " + getUserMax(userAddress, feeLimit) * (100 - p) / p); - } - logger.info("Dev AvaliableFrozenEnergy: " + getAvailableFrozenEnergy(devAddress)); - logger.info("Dev OriginalEnergyLimit: " + getOriginalEnergyLimit(contractAddress)); - return devMax; - } - - @Test(enabled = true, description = "Contract use Origin_energy_limit") - public void testOriginEnergyLimit() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 1000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - // A2B1 - - //dev balance and Energy - long devTargetBalance = 10_000_000; - long devTargetEnergy = 70000; - - // deploy contract parameters - final long deployFeeLimit = maxFeeLimit; - final long consumeUserResourcePercent = 0; - final long originEnergyLimit = 1000; - - //dev balance and Energy - final long devTriggerTargetBalance = 0; - final long devTriggerTargetEnergy = 592; - - // user balance and Energy - final long userTargetBalance = 0; - final long userTargetEnergy = 2000L; - - // trigger contract parameter, maxFeeLimit 10000000 - final long triggerFeeLimit = maxFeeLimit; - final boolean expectRet = true; - - // count dev energy, balance - long devFreezeBalanceSun = PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, - devTargetEnergy, blockingStubFull); - - long devNeedBalance = devTargetBalance + devFreezeBalanceSun; - - logger.info("need balance:" + devNeedBalance); - - // get balance - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, devNeedBalance, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - // get energy - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, devFreezeBalanceSun, - 3, 1, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("before deploy, dev energy limit is " + Long.toString(devEnergyLimitBefore)); - logger.info("before deploy, dev energy usage is " + Long.toString(devEnergyUsageBefore)); - logger.info("before deploy, dev balance is " + Long.toString(devBalanceBefore)); - - String filePath = "src/test/resources/soliditycode/contractOriginEnergyLimit004.sol"; - String contractName = "findArgsContractTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String deployTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - deployFeeLimit, 0L, consumeUserResourcePercent, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after deploy, dev energy limit is " + Long.toString(devEnergyLimitAfter)); - logger.info("after deploy, dev energy usage is " + Long.toString(devEnergyUsageAfter)); - logger.info("after deploy, dev balance is " + Long.toString(devBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(deployTxid, blockingStubFull); - - ByteString contractAddressString = infoById.get().getContractAddress(); - contractAddress = contractAddressString.toByteArray(); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - - Assert.assertTrue(smartContract.getAbi() != null); - - Assert.assertTrue(devEnergyLimitAfter > 0); - Assert.assertTrue(devEnergyUsageAfter > 0); - Assert.assertEquals(devBalanceBefore, devBalanceAfter); - - // count dev energy, balance - devFreezeBalanceSun = PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, - devTriggerTargetEnergy, blockingStubFull); - - devNeedBalance = devTriggerTargetBalance + devFreezeBalanceSun; - logger.info("dev need balance:" + devNeedBalance); - - // count user energy, balance - long userFreezeBalanceSun = PublicMethed.getFreezeBalanceCount(user001Address, user001Key, - userTargetEnergy, blockingStubFull); - - long userNeedBalance = userTargetBalance + userFreezeBalanceSun; - - logger.info("User need balance:" + userNeedBalance); - - // get balance - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, devNeedBalance, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, userNeedBalance, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // get energy - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, devFreezeBalanceSun, - 3, 1, dev001Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, userFreezeBalanceSun, - 3, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - devEnergyLimitBefore = accountResource.getEnergyLimit(); - devEnergyUsageBefore = accountResource.getEnergyUsed(); - devBalanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("before trigger, dev devEnergyLimitBefore is " - + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, dev devEnergyUsageBefore is " - + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, dev devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount( - user001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, user userEnergyLimitBefore is " - + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, user userEnergyUsageBefore is " - + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, user userBalanceBefore is " + Long.toString(userBalanceBefore)); - - logger.info("=================================="); - long userMax = getUserMax(user001Address, triggerFeeLimit); - long devMax = getDevMax(dev001Address, user001Address, triggerFeeLimit, contractAddress); - - logger.info("userMax: " + userMax); - logger.info("devMax: " + devMax); - logger.info("=================================="); - - String param = "\"" + 0 + "\""; - final String triggerTxid = PublicMethed - .triggerContract(contractAddress, "findArgsByIndexTest(uint256)", - param, false, 0, triggerFeeLimit, - user001Address, user001Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - devEnergyLimitAfter = accountResource.getEnergyLimit(); - devEnergyUsageAfter = accountResource.getEnergyUsed(); - devBalanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after trigger, dev devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, dev devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, dev devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, - blockingStubFull).getBalance(); - - logger.info("after trigger, user userEnergyLimitAfter is " - + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, user userEnergyUsageAfter is " - + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, user userBalanceAfter is " + Long.toString(userBalanceAfter)); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - boolean isSuccess = true; - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - logger.info("transaction failed with message: " + infoById.get().getResMessage()); - isSuccess = false; - } - - long fee = infoById.get().getFee(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long energyUsage = infoById.get().getReceipt().getEnergyUsage(); - long originEnergyUsage = infoById.get().getReceipt().getOriginEnergyUsage(); - long energyTotalUsage = infoById.get().getReceipt().getEnergyUsageTotal(); - long netUsage = infoById.get().getReceipt().getNetUsage(); - long netFee = infoById.get().getReceipt().getNetFee(); - - logger.info("fee: " + fee); - logger.info("energyFee: " + energyFee); - logger.info("energyUsage: " + energyUsage); - logger.info("originEnergyUsage: " + originEnergyUsage); - logger.info("energyTotalUsage: " + energyTotalUsage); - logger.info("netUsage: " + netUsage); - logger.info("netFee: " + netFee); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - long devExpectCost = energyTotalUsage * (100 - consumeUserPercent) / 100; - long userExpectCost = energyTotalUsage - devExpectCost; - final long totalCost = devExpectCost + userExpectCost; - - logger.info("devExpectCost: " + devExpectCost); - logger.info("userExpectCost: " + userExpectCost); - - Assert.assertTrue(devEnergyLimitAfter > 0); - Assert.assertEquals(devBalanceBefore, devBalanceAfter); - - // dev original is the dev max expense A2B1 - Assert.assertEquals(getOriginalEnergyLimit(contractAddress), devMax); - - // DEV is enough to pay - Assert.assertEquals(originEnergyUsage, devExpectCost); - // Assert.assertEquals(devEnergyUsageAfter,devExpectCost + devEnergyUsageBefore); - // User Energy is enough to pay"); - Assert.assertEquals(energyUsage, userExpectCost); - Assert.assertEquals(userBalanceBefore, userBalanceAfter); - Assert.assertEquals(userEnergyUsageAfter, userEnergyUsageBefore); - Assert.assertEquals(userBalanceBefore, userBalanceAfter); - Assert.assertEquals(totalCost, energyTotalUsage); - - if (expectRet) { - Assert.assertTrue(isSuccess); - } else { - Assert.assertFalse(isSuccess); - } - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken001.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken001.java deleted file mode 100644 index ecb9d30b4c2..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken001.java +++ /dev/null @@ -1,239 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - } - - @Test(enabled = true, description = "DeployContract with correct tokenValue and tokenId") - public void deployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 3100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 130000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, dev001Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken001.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 5; - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage() - .toStringUtf8()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(tokenValue), - Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100L + tokenValue), contractAssetCount); - - // get and verify the msg.value and msg.id - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getResultInCon()", "#", false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info("The msg value: " + PublicMethed - .getStrings(infoById.get().getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(infoById.get().getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken002.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken002.java deleted file mode 100644 index 1121fade9b8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken002.java +++ /dev/null @@ -1,298 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "TriggerContract with correct tokenValue and tokenId") - public void deployTransferTokenContract() { - - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 3100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 300_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 70000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed.getAssetIssueValue( - dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken002.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 0; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, callValue, 0, 10000, - tokenId, tokenValue, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed.getAssetIssueValue( - dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() - + ", Count: " + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = assetAccountId.toStringUtf8(); - tokenValue = 10; - callValue = 0; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, - blockingStubFull).getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info("the value: " - + PublicMethed.getStrings(infoById.get().getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(infoById.get().getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken003.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken003.java deleted file mode 100644 index c215d96d973..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken003.java +++ /dev/null @@ -1,382 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class ContractTrcToken003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountDev = null; - private static ByteString assetAccountUser = null; - private static final long TotalSupply = 1000L; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - - } - - @Test(enabled = true, description = "DeployContract with exception condition") - public void deployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, blockingStubFull), - 0, 1, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //dev Create a new AssetIssue - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountDev = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The assetAccountDev token name: " + tokenName); - logger.info("The assetAccountDev token ID: " + assetAccountDev.toStringUtf8()); - - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - //user Create a new AssetIssue - Assert.assertTrue(PublicMethed.createAssetIssue(user001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountUser = PublicMethed - .queryAccount(user001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The assetAccountUser token name: " + tokenName); - logger.info("The assetAccountUser token ID: " + assetAccountUser.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountDev, blockingStubFull); - Long userAssetCountBefore = PublicMethed.getAssetIssueValue(dev001Address, assetAccountUser, - blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before dev has AssetId: " + assetAccountDev.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - logger.info("before dev has AssetId: " + assetAccountUser.toStringUtf8() - + ", userAssetCountBefore: " + userAssetCountBefore); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken003.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - // the tokenId is not exist - String fakeTokenId = Long.toString(Long.valueOf(assetAccountDev.toStringUtf8()) + 100); - Long fakeTokenValue = 100L; - - GrpcAPI.Return response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, fakeTokenValue, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : No asset !", - response.getMessage().toStringUtf8()); - - // deployer didn't have any such token - fakeTokenId = assetAccountUser.toStringUtf8(); - fakeTokenValue = 100L; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, fakeTokenValue, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : assetBalance must greater than 0.", - response.getMessage().toStringUtf8()); - - // deployer didn't have any Long.MAX_VALUE - fakeTokenId = Long.toString(Long.MAX_VALUE); - fakeTokenValue = 100L; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, fakeTokenValue, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : No asset !", - response.getMessage().toStringUtf8()); - - // the tokenValue is not enough - fakeTokenId = assetAccountDev.toStringUtf8(); - fakeTokenValue = devAssetCountBefore + 100; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, fakeTokenValue, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : assetBalance is not sufficient.", - response.getMessage().toStringUtf8()); - - // tokenid is -1 - fakeTokenId = Long.toString(-1); - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, 100, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenid is 100_0000L - fakeTokenId = Long.toString(100_0000L); - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, 100, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - // tokenid is Long.MIN_VALUE - fakeTokenId = Long.toString(Long.MIN_VALUE); - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, 100, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenid is 0 - fakeTokenId = Long.toString(0); - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - fakeTokenId, 100, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals( - "contract validate error : invalid arguments with tokenValue = 100, tokenId = 0", - response.getMessage().toStringUtf8()); - - // tokenvalue is less than 0 - fakeTokenValue = -1L; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountDev.toStringUtf8(), fakeTokenValue, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenValue must >= 0", - response.getMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenvalue is long.min - fakeTokenValue = Long.MIN_VALUE; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountDev.toStringUtf8(), fakeTokenValue, null, dev001Key, - dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenValue must >= 0", - response.getMessage().toStringUtf8()); - - String tokenId = Long.toString(-1); - long tokenValue = 0; - long callValue = 10; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = Long.toString(Long.MIN_VALUE); - tokenValue = 0; - callValue = 10; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = Long.toString(1000000); - tokenValue = 0; - callValue = 10; - - response = PublicMethed - .deployContractAndGetResponse(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountDev, blockingStubFull); - Long userAssetCountAfter = PublicMethed.getAssetIssueValue(dev001Address, assetAccountUser, - blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after dev has AssetId: " + assetAccountDev.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - logger.info("after user has AssetId: " + assetAccountDev.toStringUtf8() - + ", userAssetCountAfter: " + userAssetCountAfter); - - Assert.assertEquals(devAssetCountBefore, devAssetCountAfter); - Assert.assertEquals(userAssetCountBefore, userAssetCountAfter); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken005.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken005.java deleted file mode 100644 index 476b91c2dfd..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken005.java +++ /dev/null @@ -1,466 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.api.GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - - @Test(enabled = true, description = "TriggerContract with exception condition") - public void deployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 1_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 70000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken005.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 0; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, callValue, 0, 10000, - tokenId, tokenValue, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long userAssetId = PublicMethed - .getAssetIssueValue(user001Address, ByteString.copyFromUtf8(tokenId), - blockingStubFull); - logger.info("before userAssetId has AssetId " - + tokenId + ", Count is " + userAssetId); - - // not such tokenId - tokenId = Long.toString(Long.valueOf(assetAccountId.toStringUtf8()) + 100000); - tokenValue = 10; - callValue = 5; - - GrpcAPI.Return response = PublicMethed - .triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : No asset !", - response.getMessage().toStringUtf8()); - - // not have this tokenId - tokenId = assetAccountId.toStringUtf8(); - tokenValue = 10; - callValue = 5; - - response = PublicMethed.triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : Owner no asset!", - response.getMessage().toStringUtf8()); - - // tokenId is Long.MAX_VALUE - tokenId = Long.toString(Long.MAX_VALUE); - tokenValue = 10; - callValue = 5; - - response = PublicMethed.triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : No asset !", - response.getMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenValue is not enough - tokenId = assetAccountId.toStringUtf8(); - tokenValue = 100; - callValue = 5; - - response = PublicMethed - .triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : assetBalance is not sufficient.", - response.getMessage().toStringUtf8()); - - PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, - testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenvalue is less than 0 - tokenId = assetAccountId.toStringUtf8(); - tokenValue = -1; - callValue = 5; - - response = PublicMethed - .triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenValue must >= 0", - response.getMessage().toStringUtf8()); - - tokenId = assetAccountId.toStringUtf8(); - tokenValue = Long.MIN_VALUE; - callValue = 5; - - response = PublicMethed.triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenValue must >= 0", - response.getMessage().toStringUtf8()); - - PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenId is 100_0000 - tokenId = Long.toString(100_0000); - tokenValue = 10; - callValue = 5; - - response = PublicMethed - .triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - // tokenId is long.min - tokenId = Long.toString(Long.MIN_VALUE); - tokenValue = 10; - callValue = 5; - - response = PublicMethed.triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - // tokenId is 0 - tokenId = Long.toString(0); - tokenValue = 10; - callValue = 5; - - response = PublicMethed.triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals( - "contract validate error : invalid arguments with tokenValue = 10, tokenId = 0", - response.getMessage().toStringUtf8()); - - PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = Long.toString(Long.MIN_VALUE); - tokenValue = 0; - callValue = 5; - - response = PublicMethed - .triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = Long.toString(-1); - tokenValue = 0; - callValue = 5; - - response = PublicMethed.triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = Long.toString(100_0000L); - tokenValue = 0; - callValue = 5; - - response = PublicMethed.triggerContractAndGetResponse(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - - Assert.assertFalse(response.getResult()); - Assert.assertEquals(CONTRACT_VALIDATE_ERROR, response.getCode()); - Assert.assertEquals("contract validate error : tokenId must > 1000000", - response.getMessage().toStringUtf8()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken011.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken011.java deleted file mode 100644 index 71390063241..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken011.java +++ /dev/null @@ -1,483 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - private byte[] resultContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "TransferToken with correct value, deploy transfer contract") - public void test01DeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 15048_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 14048_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account getAssetIdFromThisAccount = PublicMethed - .queryAccount(dev001Address, blockingStubFull); - assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken011.sol"; - String contractName = "transferTokenContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - } - - - @Test(enabled = true, description = "TransferToken with correct value, deploy receive contract") - public void test02DeployRevContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken011.sol"; - String contractName = "Result"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - final String recieveTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 1000, assetAccountId.toStringUtf8(), - 100, null, dev001Key, dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - // after deploy, check account resource - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Optional infoById = PublicMethed - .getTransactionInfoById(recieveTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy receive failed with message: " + infoById.get().getResMessage()); - } - - resultContractAddress = infoById.get().getContractAddress().toByteArray(); - - SmartContract smartContract = PublicMethed - .getContract(resultContractAddress, blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with correct value, transfer to a contract") - public void test03TriggerContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - String tokenId = assetAccountId.toStringUtf8(); - Long tokenValue = Long.valueOf(1); - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - TransactionInfo transactionInfo = infoById.get(); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(tokenId, msgId.toString()); - Assert.assertEquals(tokenValue, msgTokenValue); - Assert.assertEquals(callValue, msgCallValue); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - Assert.assertEquals(receiveAssetAfter - receiveAssetBefore, - transferAssetBefore + 2L - transferAssetAfter); - - } - - @Test(enabled = true, description = "TransferToken with correct value, get contract tokenBalance") - public void test04TriggerTokenBalanceContract() { - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 1000_000_000L, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("before trigger, dev energy limit is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, dev energy usage is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, dev balance is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, - blockingStubFull).getBalance(); - - logger.info("before trigger, user energy limit is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, user energy usage is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, user balance is " + Long.toString(userBalanceBefore)); - - String param = "\"" + Base58.encode58Check(resultContractAddress) + "\",\"" - + assetAccountId.toStringUtf8() + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getTokenBalnce(address,trcToken)", - param, false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed.getTransactionInfoById(triggerTxid, - blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - logger.info("the receivercontract token: " + ByteArray - .toLong(infoById.get().getContractResult(0).toByteArray())); - Long assetIssueCount = PublicMethed - .getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("the receivercontract token(getaccount): " + assetIssueCount); - Assert.assertTrue(assetIssueCount == ByteArray - .toLong(ByteArray.fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken012.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken012.java deleted file mode 100644 index 134e451204b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken012.java +++ /dev/null @@ -1,383 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken012 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "TransferToken with correct value, deploy transfer contract") - public void test01DeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 15048_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 14048_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken012.sol"; - String contractName = "transferTokenContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - } - - - @Test(description = "TransferToken with correct value, transfer to a normal account") - public void test02TriggerContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - logger.info("before trigger, receiveTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - String tokenId = assetAccountId.toStringUtf8(); - Long tokenValue = Long.valueOf(1); - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(dev001Address) - + "\",\"" + tokenValue + "\"," + tokenId; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - logger.info("after trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - Assert.assertEquals(receiveAssetAfter - receiveAssetBefore, - transferAssetBefore + 2L - transferAssetAfter); - } - - @Test(description = "TransferToken with correct value, get account tokenBalance") - public void test03TriggerTokenBalanceContract() { - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 1000_000_000L, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("before trigger, dev energy limit is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, dev energy usage is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, dev balance is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, - blockingStubFull).getBalance(); - - logger.info("before trigger, user energy limit is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, user energy usage is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, user balance is " + Long.toString(userBalanceBefore)); - - String param = "\"" + Base58.encode58Check(dev001Address) + "\",\"" - + assetAccountId.toStringUtf8() + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getTokenBalnce(address,trcToken)", - param, false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed.getTransactionInfoById(triggerTxid, - blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - logger.info("the receivercontract token: " + ByteArray - .toLong(infoById.get().getContractResult(0).toByteArray())); - Long assetIssueCount = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - - logger.info("the receivercontract token(getaccount): " + assetIssueCount); - Assert.assertTrue(assetIssueCount == ByteArray - .toLong(ByteArray.fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken014.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken014.java deleted file mode 100644 index 2b99381852e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken014.java +++ /dev/null @@ -1,626 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.protos.Protocol.TransactionInfo.code.FAILED; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken014 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static ByteString assetAccountUser = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - private byte[] resultContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "TransferToken with tokenId in exception condition," - + " deploy transfer contract") - public void test01DeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), - testKey002, blockingStubFull)); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //dev Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, - 1, 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount( - dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The assetAccountId token name: " + tokenName); - logger.info("The assetAccountId token ID: " + assetAccountId.toStringUtf8()); - - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - //user Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(user001Address, tokenName, TotalSupply, - 1, 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountUser = PublicMethed.queryAccount( - user001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The assetAccountUser token name: " + tokenName); - logger.info("The assetAccountUser token ID: " + assetAccountUser.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed.getAssetIssueValue( - dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken014.sol"; - String contractName = "transferTokenContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with tokenId in exception condition," - + " deploy receiver contract") - public void test02DeployRevContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken014.sol"; - String contractName = "Result"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String recieveTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 1000, assetAccountId.toStringUtf8(), - 100, null, dev001Key, dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(recieveTokenTxid, blockingStubFull); - - if (recieveTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy receive failed with message: " + infoById.get().getResMessage()); - } - - resultContractAddress = infoById.get().getContractAddress().toByteArray(); - - SmartContract smartContract = PublicMethed - .getContract(resultContractAddress, blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - // after deploy, check account resource - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with tokenId in exception condition," - + " transfer to contract") - public void test03TriggerContract() { - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - Long devAssetBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - logger.info("before trigger, dev001Address has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + devAssetBefore); - - // transfer to smart contract - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // transfer a not exist TokenId, to a contract - String tokenId = assetAccountUser.toStringUtf8(); - Long tokenValue = Long.valueOf(1); - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // transfer a not exist TokenId, to a normal account - tokenId = assetAccountUser.toStringUtf8(); - tokenValue = Long.valueOf(1); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(dev001Address) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenValue is not enough - tokenId = assetAccountId.toStringUtf8(); - tokenValue = transferAssetBefore + 100; - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenValue is not enough, transfer to a normal account - tokenId = assetAccountId.toStringUtf8(); - tokenValue = transferAssetBefore + 100; - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(dev001Address) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // TokenId is long.max, to a contract - String fackTokenId = Long.toString(Long.MAX_VALUE); - Long fakeValue = 1L; - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\"," + fakeValue + ",\"" + fackTokenId + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, 0, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // TokenId is not exist, to a contract - fackTokenId = Long.toString(Long.valueOf(assetAccountId.toStringUtf8()) + 10000); - fakeValue = 1L; - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\"," + fakeValue + ",\"" + fackTokenId + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, 0, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // TokenId is long.max, to a normal account - fackTokenId = Long.toString(Long.MAX_VALUE); - fakeValue = 1L; - - param = "\"" + Base58.encode58Check(dev001Address) - + "\"," + fakeValue + ",\"" + fackTokenId + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, 0, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // TokenId is not exist, to a normal account - fackTokenId = Long.toString(Long.valueOf(assetAccountId.toStringUtf8()) + 10000); - fakeValue = 1L; - - param = "\"" + Base58.encode58Check(dev001Address) - + "\"," + fakeValue + ",\"" + fackTokenId + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, 0, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenValue is long.min, transfer to a contract - tokenId = assetAccountId.toStringUtf8(); - tokenValue = Long.MIN_VALUE; - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("endowment out of long range", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenValue is long.min, transfer to a normal account - param = "\"" + Base58.encode58Check(dev001Address) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("endowment out of long range", - infoById.get().getResMessage().toStringUtf8()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - Long devAssetAfter = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - logger.info("after trigger, dev001Address has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + devAssetAfter); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - Assert.assertEquals(receiveAssetBefore, receiveAssetAfter); - Assert.assertEquals(devAssetBefore, devAssetAfter); - Assert.assertEquals(transferAssetBefore, transferAssetAfter); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken018.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken018.java deleted file mode 100644 index 813dab94b76..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken018.java +++ /dev/null @@ -1,301 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.protos.Protocol.TransactionInfo.code.FAILED; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class ContractTrcToken018 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - private byte[] receiveTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - private byte[] tmpAddress = ecKey3.getAddress(); - private String tmp001Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Transfer token to an inactive account") - public void testDeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, dev001Key, blockingStubFull)); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken023.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Delpoy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(tmpAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, receiveTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - String param = "\"" + Base58.encode58Check(tmpAddress) - + "\"," + assetAccountId.toStringUtf8() + ",\"1\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", param, false, 0, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional trsById = PublicMethed.getTransactionById(triggerTxid, blockingStubFull); - long feeLimit = trsById.get().getRawData().getFeeLimit(); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals( - "transfer trc10 failed: Validate InternalTransfer error, no ToAccount. " - + "And not allowed to create account in smart contract.", - infoById.get().getResMessage().toStringUtf8()); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(tmpAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, receiveTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - Assert.assertEquals(receiveAssetAfter, receiveAssetBefore); - Assert.assertEquals(transferAssetBefore, transferAssetAfter); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken023.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken023.java deleted file mode 100644 index 3956a0d472e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken023.java +++ /dev/null @@ -1,283 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken023 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static final long now = System.currentTimeMillis(); - - private static String tokenName = "testAssetIssue_" + Long.toString(now); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private static ByteString assetAccountId = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - byte[] transferTokenContractAddress; - byte[] btestAddress; - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); - } - - - @Test(enabled = true, description = "Fallback function energy limit to prevent fallback attacks") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - int i = randomInt(6666666, 9999999); - ByteString tokenId1 = ByteString.copyFromUtf8(String.valueOf(i)); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath2 = "src/test/resources/soliditycode/contractTrcToken023.sol"; - String contractName2 = "tokenTest"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath2, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String contractName = "B"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath2, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - btestAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(btestAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Fallback function energy used >2300") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long beforeAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueBAddress:" + beforeAssetIssueBAddress); - - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - - String param = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + assetAccountId - .toStringUtf8() - + "\",\"1\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueBAddress:" + afterAssetIssueBAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertEquals(afterBalanceContractAddress, beforeBalanceContractAddress); - Assert.assertTrue(afterAssetIssueContractAddress == beforeAssetIssueContractAddress); - Assert.assertTrue(afterAssetIssueBAddress == beforeAssetIssueBAddress); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken026.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken026.java deleted file mode 100644 index fd9ac39abff..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken026.java +++ /dev/null @@ -1,808 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken026 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - byte[] btestAddress; - byte[] ctestAddress; - byte[] transferTokenContractAddress; - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); - } - - - @Test(enabled = true, description = "Deploy transferToken contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken026.sol"; - String contractName = "B"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - btestAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - ctestAddress = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "token"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - PublicMethed - .transferAsset(btestAddress, assetAccountId.toByteArray(), 100, dev001Address, - dev001Key, - blockingStubFull); - PublicMethed - .transferAsset(ctestAddress, assetAccountId.toByteArray(), 100, dev001Address, - dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - } - - @Test(enabled = true, description = "Multistage call transferToken use right tokenID") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long beforeAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueCAddress = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueBAddress:" + beforeAssetIssueBAddress); - logger.info("beforeAssetIssueCAddress:" + beforeAssetIssueCAddress); - - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - // 1.user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "testInCall(address,address,address,uint256,trcToken)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueBAddress:" + afterAssetIssueBAddress); - logger.info("afterAssetIssueCAddress:" + afterAssetIssueCAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertEquals(afterBalanceContractAddress, beforeBalanceContractAddress); - Assert.assertTrue(afterAssetIssueContractAddress == beforeAssetIssueContractAddress + 1); - Assert.assertTrue(afterAssetIssueBAddress == beforeAssetIssueBAddress); - Assert.assertTrue(afterAssetIssueCAddress == beforeAssetIssueCAddress - 1); - } - - @Test(enabled = true, description = "Multistage call transferToken use fake tokenID") - public void deploy03TransferTokenContract() { - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueBAddress:" + afterAssetIssueBAddress); - logger.info("afterAssetIssueCAddress:" + afterAssetIssueCAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - //3. user trigger A to transfer token to B - int i = randomInt(6666666, 9999999); - - ByteString tokenId1 = ByteString.copyFromUtf8(String.valueOf(i)); - - String param1 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + tokenId1 - .toStringUtf8() - + "\""; - - final String triggerTxid1 = PublicMethed.triggerContract(transferTokenContractAddress, - "testInCall(address,address,address,uint256,trcToken)", - param1, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - final Long afterAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress1 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress1 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress1 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance1 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - logger.info("afterAssetIssueCount1:" + afterAssetIssueDevAddress1); - logger.info("afterAssetIssueDevAddress1:" + afterAssetIssueContractAddress1); - logger.info("afterAssetIssueBAddress1:" + afterAssetIssueBAddress1); - logger.info("afterAssetIssueCAddress1:" + afterAssetIssueCAddress1); - logger.info("afterAssetIssueUserAddress1:" + afterAssetIssueUserAddress1); - logger.info("afterBalanceContractAddress1:" + afterBalanceContractAddress1); - logger.info("afterUserBalance1:" + afterUserBalance1); - - Optional infoById1 = PublicMethed - .getTransactionInfoById(triggerTxid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == afterAssetIssueUserAddress1); - Assert.assertEquals(afterBalanceContractAddress, afterBalanceContractAddress1); - Assert.assertTrue(afterAssetIssueContractAddress == afterAssetIssueContractAddress1); - Assert.assertTrue(afterAssetIssueBAddress == afterAssetIssueBAddress1); - Assert.assertTrue(afterAssetIssueCAddress == afterAssetIssueCAddress1); - } - - @Test(enabled = true, description = "Multistage call transferToken token value not enough") - public void deploy04TransferTokenContract() { - Account infoafter1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - final Long afterAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress1 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress1 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress1 = - PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance1 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - //4. user trigger A to transfer token to B - String param2 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",10000000,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid2 = PublicMethed.triggerContract(transferTokenContractAddress, - "testInCall(address,address,address,uint256,trcToken)", - param2, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter2 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterAssetIssueDevAddress2 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - Long afterAssetIssueContractAddress2 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress2 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress2 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress2 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress2 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance2 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance2:" + afterBalance2); - logger.info("afterEnergyUsed2:" + afterEnergyUsed2); - logger.info("afterNetUsed2:" + afterNetUsed2); - logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2); - logger.info("afterAssetIssueCount2:" + afterAssetIssueDevAddress2); - logger.info("afterAssetIssueDevAddress2:" + afterAssetIssueContractAddress2); - logger.info("afterAssetIssueBAddress2:" + afterAssetIssueBAddress2); - logger.info("afterAssetIssueCAddress2:" + afterAssetIssueCAddress2); - logger.info("afterAssetIssueUserAddress2:" + afterAssetIssueUserAddress2); - logger.info("afterBalanceContractAddress2:" + afterBalanceContractAddress2); - logger.info("afterUserBalance2:" + afterUserBalance2); - - Optional infoById2 = PublicMethed - .getTransactionInfoById(triggerTxid2, blockingStubFull); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress1 == afterAssetIssueUserAddress2); - Assert.assertEquals(afterBalanceContractAddress1, afterBalanceContractAddress2); - Assert.assertTrue(afterAssetIssueContractAddress1 == afterAssetIssueContractAddress2); - Assert.assertTrue(afterAssetIssueBAddress1 == afterAssetIssueBAddress2); - Assert.assertTrue(afterAssetIssueCAddress1 == afterAssetIssueCAddress2); - } - - @Test(enabled = true, description = "Multistage call transferToken calltoken ID not exist") - public void deploy05TransferTokenContract() { - Account infoafter2 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterAssetIssueDevAddress2 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - final Long afterAssetIssueContractAddress2 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress2 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress2 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress2 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress2 = - PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance2 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - //5. user trigger A to transfer token to B - String param3 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - int i = randomInt(6666666, 9999999); - - ByteString tokenId1 = ByteString.copyFromUtf8(String.valueOf(i)); - final String triggerTxid3 = PublicMethed.triggerContract(transferTokenContractAddress, - "testInCall(address,address,address,uint256,trcToken)", - param3, false, 0, 1000000000L, tokenId1 - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter3 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterAssetIssueDevAddress3 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - Long afterAssetIssueContractAddress3 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress3 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress3 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress3 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress3 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance3 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance3:" + afterBalance3); - logger.info("afterEnergyUsed3:" + afterEnergyUsed3); - logger.info("afterNetUsed3:" + afterNetUsed3); - logger.info("afterFreeNetUsed3:" + afterFreeNetUsed3); - logger.info("afterAssetIssueCount3:" + afterAssetIssueDevAddress3); - logger.info("afterAssetIssueDevAddress3:" + afterAssetIssueContractAddress3); - logger.info("afterAssetIssueBAddress3:" + afterAssetIssueBAddress3); - logger.info("afterAssetIssueCAddress3:" + afterAssetIssueCAddress3); - logger.info("afterAssetIssueUserAddress3:" + afterAssetIssueUserAddress3); - logger.info("afterBalanceContractAddress3:" + afterBalanceContractAddress3); - logger.info("afterUserBalance3:" + afterUserBalance3); - - Optional infoById3 = PublicMethed - .getTransactionInfoById(triggerTxid3, blockingStubFull); - Assert.assertTrue(triggerTxid3 == null); - Assert.assertTrue(afterAssetIssueUserAddress2 == afterAssetIssueUserAddress3); - Assert.assertEquals(afterBalanceContractAddress2, afterBalanceContractAddress3); - Assert.assertTrue(afterAssetIssueContractAddress2 == afterAssetIssueContractAddress3); - Assert.assertTrue(afterAssetIssueBAddress2 == afterAssetIssueBAddress3); - Assert.assertTrue(afterAssetIssueCAddress2 == afterAssetIssueCAddress3); - } - - @Test(enabled = true, description = "Multistage call transferToken calltoken value not enough") - public void deploy06TransferTokenContract() { - Account infoafter3 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterAssetIssueDevAddress3 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - final Long afterAssetIssueContractAddress3 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress3 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress3 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress3 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress3 = - PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance3 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - //6. user trigger A to transfer token to B - String param4 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid4 = PublicMethed.triggerContract(transferTokenContractAddress, - "testInCall(address,address,address,uint256,trcToken)", - param4, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 100000000, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter4 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter4 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance4 = infoafter4.getBalance(); - Long afterEnergyUsed4 = resourceInfoafter4.getEnergyUsed(); - Long afterAssetIssueDevAddress4 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed4 = resourceInfoafter4.getNetUsed(); - Long afterFreeNetUsed4 = resourceInfoafter4.getFreeNetUsed(); - Long afterAssetIssueContractAddress4 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress4 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress4 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress4 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress4 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance4 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance4:" + afterBalance4); - logger.info("afterEnergyUsed4:" + afterEnergyUsed4); - logger.info("afterNetUsed4:" + afterNetUsed4); - logger.info("afterFreeNetUsed4:" + afterFreeNetUsed4); - logger.info("afterAssetIssueCount4:" + afterAssetIssueDevAddress4); - logger.info("afterAssetIssueDevAddress4:" + afterAssetIssueContractAddress4); - logger.info("afterAssetIssueBAddress4:" + afterAssetIssueBAddress4); - logger.info("afterAssetIssueCAddress4:" + afterAssetIssueCAddress4); - logger.info("afterAssetIssueUserAddress4:" + afterAssetIssueUserAddress4); - logger.info("afterBalanceContractAddress4:" + afterBalanceContractAddress4); - logger.info("afterUserBalance4:" + afterUserBalance4); - - Optional infoById4 = PublicMethed - .getTransactionInfoById(triggerTxid4, blockingStubFull); - Assert.assertTrue(triggerTxid4 == null); - - Assert.assertTrue(afterAssetIssueUserAddress3 == afterAssetIssueUserAddress4); - Assert.assertEquals(afterBalanceContractAddress3, afterBalanceContractAddress4); - Assert.assertTrue(afterAssetIssueContractAddress3 == afterAssetIssueContractAddress4); - Assert.assertTrue(afterAssetIssueBAddress3 == afterAssetIssueBAddress4); - Assert.assertTrue(afterAssetIssueCAddress3 == afterAssetIssueCAddress4); - } - - @Test(enabled = true, description = "Multistage call transferToken use right tokenID,tokenvalue") - public void deploy07TransferTokenContract() { - Account infoafter4 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter4 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance4 = infoafter4.getBalance(); - Long afterEnergyUsed4 = resourceInfoafter4.getEnergyUsed(); - final Long afterAssetIssueDevAddress4 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed4 = resourceInfoafter4.getNetUsed(); - Long afterFreeNetUsed4 = resourceInfoafter4.getFreeNetUsed(); - final Long afterAssetIssueContractAddress4 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress4 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress4 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress4 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress4 = - PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance4 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - //2. user trigger A to transfer token to B - String param5 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid5 = PublicMethed.triggerContract(transferTokenContractAddress, - "testInCall(address,address,address,uint256,trcToken)", - param5, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter5 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter5 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance5 = infoafter5.getBalance(); - Long afterEnergyUsed5 = resourceInfoafter5.getEnergyUsed(); - Long afterAssetIssueDevAddress5 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed5 = resourceInfoafter5.getNetUsed(); - Long afterFreeNetUsed5 = resourceInfoafter5.getFreeNetUsed(); - Long afterAssetIssueContractAddress5 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress5 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress5 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress5 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress5 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance5 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance5:" + afterBalance5); - logger.info("afterEnergyUsed5:" + afterEnergyUsed5); - logger.info("afterNetUsed5:" + afterNetUsed5); - logger.info("afterFreeNetUsed5:" + afterFreeNetUsed5); - logger.info("afterAssetIssueCount5:" + afterAssetIssueDevAddress5); - logger.info("afterAssetIssueDevAddress5:" + afterAssetIssueContractAddress5); - logger.info("afterAssetIssueBAddress5:" + afterAssetIssueBAddress5); - logger.info("afterAssetIssueCAddress5:" + afterAssetIssueCAddress5); - logger.info("afterAssetIssueUserAddress5:" + afterAssetIssueUserAddress5); - logger.info("afterBalanceContractAddress5:" + afterBalanceContractAddress5); - logger.info("afterUserBalance5:" + afterUserBalance5); - - Optional infoById5 = PublicMethed - .getTransactionInfoById(triggerTxid5, blockingStubFull); - Assert.assertTrue(infoById5.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress4 == afterAssetIssueUserAddress5); - Assert.assertEquals(afterBalanceContractAddress4, afterBalanceContractAddress5); - Assert.assertTrue(afterAssetIssueContractAddress4 + 2 == afterAssetIssueContractAddress5); - Assert.assertTrue(afterAssetIssueBAddress4 == afterAssetIssueBAddress5); - Assert.assertTrue(afterAssetIssueCAddress4 - 1 == afterAssetIssueCAddress5); - Assert.assertTrue(afterAssetIssueDevAddress4 - 1 == afterAssetIssueDevAddress5); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken027.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken027.java deleted file mode 100644 index 086ac2f39d4..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken027.java +++ /dev/null @@ -1,804 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken027 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - /** - * constructor. - */ - private ManagedChannel channelFull = null; - byte[] btestAddress; - byte[] ctestAddress; - byte[] transferTokenContractAddress; - private static ByteString assetAccountId = null; - int i1 = randomInt(6666666, 9999999); - ByteString tokenId1 = ByteString.copyFromUtf8(String.valueOf(i1)); - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); - } - - - @Test(enabled = true, description = "Deploy transferToken contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String tokenName = "testAI_" + randomInt(10000, 90000); - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken027.sol"; - String contractName = "B"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - btestAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "C"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - ctestAddress = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "token"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - PublicMethed - .transferAsset(btestAddress, assetAccountId.toByteArray(), 100, dev001Address, - dev001Key, - blockingStubFull); - PublicMethed - .transferAsset(ctestAddress, assetAccountId.toByteArray(), 100, dev001Address, - dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - } - - @Test(enabled = true, description = "Multistage delegatecall transferToken use right tokenID") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long beforeAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueCAddress = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueBAddress:" + beforeAssetIssueBAddress); - logger.info("beforeAssetIssueCAddress:" + beforeAssetIssueCAddress); - - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - // 1.user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "testIndelegateCall(address,address,address,uint256,trcToken)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueBAddress:" + afterAssetIssueBAddress); - logger.info("afterAssetIssueCAddress:" + afterAssetIssueCAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertEquals(afterBalanceContractAddress, beforeBalanceContractAddress); - Assert.assertTrue(afterAssetIssueContractAddress == beforeAssetIssueContractAddress + 1); - Assert.assertTrue(afterAssetIssueBAddress == beforeAssetIssueBAddress); - Assert.assertTrue(afterAssetIssueCAddress == beforeAssetIssueCAddress - 1); - - } - - @Test(enabled = true, description = "Multistage delegatecall transferToken use fake tokenID") - public void deploy03TransferTokenContract() { - //3. user trigger A to transfer token to B - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - final Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - String param1 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + tokenId1 - .toStringUtf8() - + "\""; - - final String triggerTxid1 = PublicMethed.triggerContract(transferTokenContractAddress, - "testIndelegateCall(address,address,address,uint256,trcToken)", - param1, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - Long afterAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress1 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress1 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress1 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance1 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - logger.info("afterAssetIssueCount1:" + afterAssetIssueDevAddress1); - logger.info("afterAssetIssueDevAddress1:" + afterAssetIssueContractAddress1); - logger.info("afterAssetIssueBAddress1:" + afterAssetIssueBAddress1); - logger.info("afterAssetIssueCAddress1:" + afterAssetIssueCAddress1); - logger.info("afterAssetIssueUserAddress1:" + afterAssetIssueUserAddress1); - logger.info("afterBalanceContractAddress1:" + afterBalanceContractAddress1); - logger.info("afterUserBalance1:" + afterUserBalance1); - - Optional infoById1 = PublicMethed - .getTransactionInfoById(triggerTxid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == afterAssetIssueUserAddress1); - Assert.assertEquals(afterBalanceContractAddress, afterBalanceContractAddress1); - Assert.assertTrue(afterAssetIssueContractAddress == afterAssetIssueContractAddress1); - Assert.assertTrue(afterAssetIssueBAddress == afterAssetIssueBAddress1); - Assert.assertTrue(afterAssetIssueCAddress == afterAssetIssueCAddress1); - } - - - @Test(enabled = true, description = "Multistage delegatecall transferToken token value" - + " not enough") - public void deploy04TransferTokenContract() { - //4. user trigger A to transfer token to B - Account infoafter1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - final Long afterAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress1 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress1 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress1 = - PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance1 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - String param2 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",10000000,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid2 = PublicMethed.triggerContract(transferTokenContractAddress, - "testIndelegateCall(address,address,address,uint256,trcToken)", - param2, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter2 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterAssetIssueDevAddress2 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - Long afterAssetIssueContractAddress2 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress2 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress2 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress2 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress2 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance2 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance2:" + afterBalance2); - logger.info("afterEnergyUsed2:" + afterEnergyUsed2); - logger.info("afterNetUsed2:" + afterNetUsed2); - logger.info("afterFreeNetUsed2:" + afterFreeNetUsed2); - logger.info("afterAssetIssueCount2:" + afterAssetIssueDevAddress2); - logger.info("afterAssetIssueDevAddress2:" + afterAssetIssueContractAddress2); - logger.info("afterAssetIssueBAddress2:" + afterAssetIssueBAddress2); - logger.info("afterAssetIssueCAddress2:" + afterAssetIssueCAddress2); - logger.info("afterAssetIssueUserAddress2:" + afterAssetIssueUserAddress2); - logger.info("afterBalanceContractAddress2:" + afterBalanceContractAddress2); - logger.info("afterUserBalance2:" + afterUserBalance2); - - Optional infoById2 = PublicMethed - .getTransactionInfoById(triggerTxid2, blockingStubFull); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress1 == afterAssetIssueUserAddress2); - Assert.assertEquals(afterBalanceContractAddress1, afterBalanceContractAddress2); - Assert.assertTrue(afterAssetIssueContractAddress1 == afterAssetIssueContractAddress2); - Assert.assertTrue(afterAssetIssueBAddress1 == afterAssetIssueBAddress2); - Assert.assertTrue(afterAssetIssueCAddress1 == afterAssetIssueCAddress2); - } - - @Test(enabled = true, description = "Multistage delegatecall transferToken calltoken ID" - + " not exist") - public void deploy05TransferTokenContract() { - Account infoafter2 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterAssetIssueDevAddress2 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - final Long afterAssetIssueContractAddress2 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress2 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress2 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress2 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress2 = PublicMethed - .queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance2 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - //5. user trigger A to transfer token to B - String param3 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid3 = PublicMethed.triggerContract(transferTokenContractAddress, - "testIndelegateCall(address,address,address,uint256,trcToken)", - param3, false, 0, 1000000000L, tokenId1 - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter3 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterAssetIssueDevAddress3 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - Long afterAssetIssueContractAddress3 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress3 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress3 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress3 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress3 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance3 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance3:" + afterBalance3); - logger.info("afterEnergyUsed3:" + afterEnergyUsed3); - logger.info("afterNetUsed3:" + afterNetUsed3); - logger.info("afterFreeNetUsed3:" + afterFreeNetUsed3); - logger.info("afterAssetIssueCount3:" + afterAssetIssueDevAddress3); - logger.info("afterAssetIssueDevAddress3:" + afterAssetIssueContractAddress3); - logger.info("afterAssetIssueBAddress3:" + afterAssetIssueBAddress3); - logger.info("afterAssetIssueCAddress3:" + afterAssetIssueCAddress3); - logger.info("afterAssetIssueUserAddress3:" + afterAssetIssueUserAddress3); - logger.info("afterBalanceContractAddress3:" + afterBalanceContractAddress3); - logger.info("afterUserBalance3:" + afterUserBalance3); - - Optional infoById3 = PublicMethed - .getTransactionInfoById(triggerTxid3, blockingStubFull); - Assert.assertTrue(triggerTxid3 == null); - Assert.assertTrue(afterAssetIssueUserAddress2 == afterAssetIssueUserAddress3); - Assert.assertEquals(afterBalanceContractAddress2, afterBalanceContractAddress3); - Assert.assertTrue(afterAssetIssueContractAddress2 == afterAssetIssueContractAddress3); - Assert.assertTrue(afterAssetIssueBAddress2 == afterAssetIssueBAddress3); - Assert.assertTrue(afterAssetIssueCAddress2 == afterAssetIssueCAddress3); - } - - @Test(enabled = true, description = "Multistage delegatecall transferToken calltoken value " - + "not enough") - public void deploy06TransferTokenContract() { - Account infoafter3 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterAssetIssueDevAddress3 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - final Long afterAssetIssueContractAddress3 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress3 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress3 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress3 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress3 = - PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance3 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - //user trigger A to transfer token to B - String param4 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid4 = PublicMethed.triggerContract(transferTokenContractAddress, - "testIndelegateCall(address,address,address,uint256,trcToken)", - param4, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 100000000, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter4 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter4 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance4 = infoafter4.getBalance(); - Long afterEnergyUsed4 = resourceInfoafter4.getEnergyUsed(); - Long afterAssetIssueDevAddress4 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed4 = resourceInfoafter4.getNetUsed(); - Long afterFreeNetUsed4 = resourceInfoafter4.getFreeNetUsed(); - Long afterAssetIssueContractAddress4 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress4 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress4 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress4 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress4 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance4 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance4:" + afterBalance4); - logger.info("afterEnergyUsed4:" + afterEnergyUsed4); - logger.info("afterNetUsed4:" + afterNetUsed4); - logger.info("afterFreeNetUsed4:" + afterFreeNetUsed4); - logger.info("afterAssetIssueCount4:" + afterAssetIssueDevAddress4); - logger.info("afterAssetIssueDevAddress4:" + afterAssetIssueContractAddress4); - logger.info("afterAssetIssueBAddress4:" + afterAssetIssueBAddress4); - logger.info("afterAssetIssueCAddress4:" + afterAssetIssueCAddress4); - logger.info("afterAssetIssueUserAddress4:" + afterAssetIssueUserAddress4); - logger.info("afterBalanceContractAddress4:" + afterBalanceContractAddress4); - logger.info("afterUserBalance4:" + afterUserBalance4); - - Optional infoById4 = PublicMethed - .getTransactionInfoById(triggerTxid4, blockingStubFull); - Assert.assertTrue(triggerTxid4 == null); - Assert.assertTrue(afterAssetIssueUserAddress3 == afterAssetIssueUserAddress4); - Assert.assertEquals(afterBalanceContractAddress3, afterBalanceContractAddress4); - Assert.assertTrue(afterAssetIssueContractAddress3 == afterAssetIssueContractAddress4); - Assert.assertTrue(afterAssetIssueBAddress3 == afterAssetIssueBAddress4); - Assert.assertTrue(afterAssetIssueCAddress3 == afterAssetIssueCAddress4); - } - - @Test(enabled = true, description = "Multistage delegatecall transferToken use right tokenID," - + "tokenvalue") - public void deploy07TransferTokenContract() { - Account infoafter4 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter4 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance4 = infoafter4.getBalance(); - Long afterEnergyUsed4 = resourceInfoafter4.getEnergyUsed(); - final Long afterAssetIssueDevAddress4 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - final Long afterNetUsed4 = resourceInfoafter4.getNetUsed(); - final Long afterFreeNetUsed4 = resourceInfoafter4.getFreeNetUsed(); - final Long afterAssetIssueContractAddress4 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueBAddress4 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueCAddress4 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - final Long afterAssetIssueUserAddress4 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - final Long afterBalanceContractAddress4 = - PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance4 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - // user trigger A to transfer token to B - String param5 = - "\"" + Base58.encode58Check(btestAddress) + "\",\"" + Base58.encode58Check(ctestAddress) - + "\",\"" + Base58.encode58Check(transferTokenContractAddress) - + "\",1,\"" + assetAccountId - .toStringUtf8() - + "\""; - - final String triggerTxid5 = PublicMethed.triggerContract(transferTokenContractAddress, - "testIndelegateCall(address,address,address,uint256,trcToken)", - param5, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter5 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter5 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance5 = infoafter5.getBalance(); - Long afterEnergyUsed5 = resourceInfoafter5.getEnergyUsed(); - Long afterAssetIssueDevAddress5 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed5 = resourceInfoafter5.getNetUsed(); - Long afterFreeNetUsed5 = resourceInfoafter5.getFreeNetUsed(); - Long afterAssetIssueContractAddress5 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress5 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueCAddress5 = PublicMethed - .getAssetIssueValue(ctestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress5 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress5 = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance5 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance5:" + afterBalance5); - logger.info("afterEnergyUsed5:" + afterEnergyUsed5); - logger.info("afterNetUsed5:" + afterNetUsed5); - logger.info("afterFreeNetUsed5:" + afterFreeNetUsed5); - logger.info("afterAssetIssueCount5:" + afterAssetIssueDevAddress5); - logger.info("afterAssetIssueDevAddress5:" + afterAssetIssueContractAddress5); - logger.info("afterAssetIssueBAddress5:" + afterAssetIssueBAddress5); - logger.info("afterAssetIssueCAddress5:" + afterAssetIssueCAddress5); - logger.info("afterAssetIssueUserAddress5:" + afterAssetIssueUserAddress5); - logger.info("afterBalanceContractAddress5:" + afterBalanceContractAddress5); - logger.info("afterUserBalance5:" + afterUserBalance5); - - Optional infoById5 = PublicMethed - .getTransactionInfoById(triggerTxid5, blockingStubFull); - Assert.assertTrue(infoById5.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress4 == afterAssetIssueUserAddress5); - Assert.assertEquals(afterBalanceContractAddress4, afterBalanceContractAddress5); - Assert.assertTrue(afterAssetIssueContractAddress4 + 2 == afterAssetIssueContractAddress5); - Assert.assertTrue(afterAssetIssueBAddress4 == afterAssetIssueBAddress5); - Assert.assertTrue(afterAssetIssueCAddress4 - 1 == afterAssetIssueCAddress5); - Assert.assertTrue(afterAssetIssueDevAddress4 - 1 == afterAssetIssueDevAddress5); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken028.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken028.java deleted file mode 100644 index dd60b41e31a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken028.java +++ /dev/null @@ -1,269 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken028 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static ByteString assetAccountId = null; - int i1 = randomInt(6666666, 9999999); - ByteString tokenId1 = ByteString.copyFromUtf8(String.valueOf(i1)); - private byte[] transferTokenContractAddress; - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); - } - - - @Test(enabled = true, description = "Deploy tokenBalanceWithSameName contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 3, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 3, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String tokenName = "testAI_" + randomInt(10000, 90000); - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken028.sol"; - String contractName = "token"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - - // devAddress transfer token to userAddress - Assert.assertTrue(PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - } - - - @Test(enabled = true, description = "Trigger tokenBalanceWithSameName") - public void deploy02TransferTokenContract() { - // user trigger A to transfer token to B - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - String param = - "\"" + tokenId1 - .toStringUtf8() - + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "tokenBalanceWithSameName(trcToken)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertEquals(afterBalanceContractAddress, beforeBalanceContractAddress); - Assert.assertTrue(afterAssetIssueContractAddress == beforeAssetIssueContractAddress); - - String triggerTxid1 = PublicMethed.triggerContract(transferTokenContractAddress, - "getA()", - "#", false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(triggerTxid1, blockingStubFull); - Long returnnumber1 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(returnnumber1 == 9); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken029.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken029.java deleted file mode 100644 index 54793e73c38..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken029.java +++ /dev/null @@ -1,252 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken029 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static ByteString assetAccountId = null; - byte[] transferTokenContractAddress; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - @Test(enabled = true, description = "Deploy transferTokenwithSameName contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken029.sol"; - String contractName = "token"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - /** - * constructor. - */ - - @Test(enabled = true, description = "Trigger transferTokenwithSameName") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - - // user trigger A to transfer token to B - ByteString assetAccountDev = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - ByteString fakeTokenId = ByteString - .copyFromUtf8(Long.toString(Long.valueOf(assetAccountDev.toStringUtf8()) + 100)); - String param = "\"" + fakeTokenId.toStringUtf8() + "\",\"1\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenWithSameName(trcToken,uint256)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertEquals(afterBalanceContractAddress, beforeBalanceContractAddress); - Assert.assertEquals(afterUserBalance, beforeUserBalance); - Assert.assertTrue(afterAssetIssueContractAddress == beforeAssetIssueContractAddress); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - null, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - null, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken030.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken030.java deleted file mode 100644 index 6871dbc3769..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken030.java +++ /dev/null @@ -1,249 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken030 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - byte[] transferTokenContractAddress; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "Deploy suicide contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken030.sol"; - String contractName = "token"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Trigger suicide contract,toaddress is other") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - final Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - - // user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(user001Address) - + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "kill(address)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - final Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalanceContractAddress == 0); - Assert.assertTrue(beforeAssetIssueUserAddress + beforeAssetIssueContractAddress - == afterAssetIssueUserAddress); - Assert.assertTrue(beforeUserBalance + beforeBalanceContractAddress - == afterUserBalance); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken031.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken031.java deleted file mode 100644 index 6b7e4877180..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken031.java +++ /dev/null @@ -1,243 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken031 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - byte[] transferTokenContractAddress; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - @Test(enabled = true, description = "Deploy suicide contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken031.sol"; - String contractName = "token"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertNotNull(transferTokenContractAddress); - - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Trigger suicide contract,toaddress is myself") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - - // user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(transferTokenContractAddress) - + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "kill(address)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get() - .getResultValue() == 0); - Assert.assertTrue(afterBalanceContractAddress == 0); - Assert.assertTrue(afterAssetIssueContractAddress == 0); - - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken034.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken034.java deleted file mode 100644 index 943ca4a9144..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken034.java +++ /dev/null @@ -1,239 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken034 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - byte[] transferTokenContractAddress; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "Deploy after transfertoken execute require contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken034.sol"; - String contractName = "token"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Trigger after transfertoken execute require contract") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - - // user trigger A to transfer token to B - ByteString assetAccountDev = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - ByteString fakeTokenId = ByteString - .copyFromUtf8(Long.toString(Long.valueOf(assetAccountDev.toStringUtf8()) + 100)); - String param = - "\"" + Base58.encode58Check(user001Address) + "\",1,\"" + fakeTokenId - .toStringUtf8() - + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "failTransferTokenRevert(address,uint256,trcToken)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertEquals(beforeAssetIssueDevAddress, afterAssetIssueDevAddress); - Assert.assertEquals(beforeAssetIssueUserAddress, afterAssetIssueUserAddress); - Assert.assertEquals(beforeAssetIssueContractAddress, afterAssetIssueContractAddress); - - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken035.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken035.java deleted file mode 100644 index f4861b96364..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken035.java +++ /dev/null @@ -1,239 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken035 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - byte[] transferTokenContractAddress; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "Deploy after transfertoken execute assert contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 9999000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - String filePath = "src/test/resources/soliditycode/contractTrcToken035.sol"; - String contractName = "token"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Trigger after transfertoken execute assert contract") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - - // user trigger A to transfer token to B - ByteString assetAccountDev = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - ByteString fakeTokenId = ByteString - .copyFromUtf8(Long.toString(Long.valueOf(assetAccountDev.toStringUtf8()) + 100)); - String param = - "\"" + Base58.encode58Check(user001Address) + "\",1,\"" + fakeTokenId - .toStringUtf8() - + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "failTransferTokenError(address,uint256,trcToken)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertEquals(beforeAssetIssueDevAddress, afterAssetIssueDevAddress); - Assert.assertEquals(beforeAssetIssueUserAddress, afterAssetIssueUserAddress); - Assert.assertEquals(beforeAssetIssueContractAddress, afterAssetIssueContractAddress); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken036.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken036.java deleted file mode 100644 index 21895f3edae..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken036.java +++ /dev/null @@ -1,542 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken036 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - byte[] transferTokenContractAddress; - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - int originEnergyLimit = 50000; - byte[] transferTokenWithPureTestAddress; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = false, description = "Deploy contract") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 9999000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - // String filePath = "src/test/resources/soliditycode/contractTrcToken036.sol"; - // String contractName = "IllegalDecorate"; - // HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - // String code = retMap.get("byteCode").toString(); - // String abi = retMap.get("abI").toString(); - // transferTokenContractAddress = PublicMethed - // .deployContract(contractName, abi, code, "", maxFeeLimit, - // 0L, 0, originEnergyLimit, "0", - // 0, null, dev001Key, dev001Address, - // blockingStubFull); - // PublicMethed.waitProduceNextBlock(blockingStubFull); - // PublicMethed.waitProduceNextBlock(blockingStubFull); - // - // // devAddress transfer token to userAddress - // PublicMethed - // .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - // dev001Address, - // dev001Key, - // blockingStubFull); - // Assert - // .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 100, fromAddress, - // testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = false, description = "Trigger transferTokenWithPure contract") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long user001AddressAddressBalance = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("user001AddressAddressBalance:" + user001AddressAddressBalance); - - // user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(user001Address) + "\",\"1\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenWithPure(address,uint256)", - param, false, 10, 1000000000L, assetAccountId - .toStringUtf8(), - 10, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afteruser001AddressAddressBalance = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterContractAddressBalance:" + afteruser001AddressAddressBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(beforeAssetIssueDevAddress - 10 == afterAssetIssueDevAddress); - Assert.assertTrue(beforeAssetIssueUserAddress + 10 == afterAssetIssueUserAddress); - Assert.assertTrue(user001AddressAddressBalance + 10 == afteruser001AddressAddressBalance); - - String filePath = "src/test/resources/soliditycode/contractTrcToken036.sol"; - String contractName1 = "IllegalDecorate1"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - transferTokenWithPureTestAddress = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenWithPureTestAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenWithPureTestAddress, 100, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = false, description = "Trigger transferTokenWithConstant contract") - public void deploy03TransferTokenContract() { - Account info1; - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance1 = info1.getBalance(); - Long beforeEnergyUsed1 = resourceInfo1.getEnergyUsed(); - Long beforeNetUsed1 = resourceInfo1.getNetUsed(); - Long beforeFreeNetUsed1 = resourceInfo1.getFreeNetUsed(); - Long beforeAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long user001AddressAddressBalance1 = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - logger.info("beforeBalance:" + beforeBalance1); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed1); - logger.info("beforeNetUsed:" + beforeNetUsed1); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed1); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress1); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress1); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress1); - logger.info("user001AddressAddressBalance:" + user001AddressAddressBalance1); - - // user trigger A to transfer token to B - String param1 = - "\"" + Base58.encode58Check(user001Address) + "\",\"1\""; - - final String triggerTxid1 = PublicMethed.triggerContract(transferTokenWithPureTestAddress, - "transferTokenWithConstant(address,uint256)", - param1, false, 10, 1000000000L, assetAccountId - .toStringUtf8(), - 10, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - Long afterAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afteruser001AddressAddressBalance1 = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress1); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress1); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress1); - logger.info("afterContractAddressBalance:" + afteruser001AddressAddressBalance1); - - Optional infoById1 = PublicMethed - .getTransactionInfoById(triggerTxid1, blockingStubFull); - Assert.assertEquals(beforeBalance1, afterBalance1); - Assert.assertEquals(beforeAssetIssueDevAddress1, afterAssetIssueDevAddress1); - Assert.assertEquals(beforeAssetIssueUserAddress1, afterAssetIssueUserAddress1); - Assert.assertEquals(user001AddressAddressBalance1, afteruser001AddressAddressBalance1); - } - - @Test(enabled = false, description = "Trigger transferTokenWithView contract") - public void deploy04TransferTokenContract() { - String filePath2 = "src/test/resources/soliditycode/contractTrcToken036.sol"; - String contractName2 = "IllegalDecorate2"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath2, contractName2); - - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - byte[] transferTokenWithViewAddress = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenWithViewAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenWithViewAddress, 100, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info2; - AccountResourceMessage resourceInfo2 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info2 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance2 = info2.getBalance(); - Long beforeEnergyUsed2 = resourceInfo2.getEnergyUsed(); - Long beforeNetUsed2 = resourceInfo2.getNetUsed(); - Long beforeFreeNetUsed2 = resourceInfo2.getFreeNetUsed(); - Long beforeAssetIssueDevAddress2 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress2 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress2 = PublicMethed - .getAssetIssueValue(transferTokenWithViewAddress, - assetAccountId, - blockingStubFull); - Long user001AddressAddressBalance2 = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - logger.info("beforeAssetIssueContractAddress2:" + beforeAssetIssueContractAddress2); - logger.info("beforeAssetIssueDevAddress2:" + beforeAssetIssueDevAddress2); - logger.info("beforeAssetIssueUserAddress2:" + beforeAssetIssueUserAddress2); - logger.info("user001AddressAddressBalance2:" + user001AddressAddressBalance2); - - // user trigger A to transfer token to B - String param2 = - "\"" + Base58.encode58Check(user001Address) + "\",\"1\""; - - String triggerTxid2 = PublicMethed.triggerContract(transferTokenWithViewAddress, - "transferTokenWithView(address,uint256)", - param2, false, 10, 1000000000L, assetAccountId - .toStringUtf8(), - 10, dev001Address, dev001Key, - blockingStubFull); - - Account infoafter2 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter2 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance2 = infoafter2.getBalance(); - Long afterEnergyUsed2 = resourceInfoafter2.getEnergyUsed(); - Long afterAssetIssueDevAddress2 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed2 = resourceInfoafter2.getNetUsed(); - Long afterFreeNetUsed2 = resourceInfoafter2.getFreeNetUsed(); - Long afterAssetIssueContractAddress2 = PublicMethed - .getAssetIssueValue(transferTokenWithViewAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress2 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afteruser001AddressAddressBalance2 = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - - logger.info("afterAssetIssueDevAddress2:" + afterAssetIssueDevAddress2); - logger.info("afterAssetIssueContractAddress2:" + afterAssetIssueContractAddress2); - logger.info("afterAssetIssueUserAddress2:" + afterAssetIssueUserAddress2); - logger.info("afteruser001AddressAddressBalance2:" + afteruser001AddressAddressBalance2); - - Optional infoById2 = PublicMethed - .getTransactionInfoById(triggerTxid2, blockingStubFull); - - Assert.assertEquals(beforeAssetIssueDevAddress2, afterAssetIssueDevAddress2); - Assert.assertEquals(beforeAssetIssueUserAddress2, afterAssetIssueUserAddress2); - Assert.assertEquals(user001AddressAddressBalance2, afteruser001AddressAddressBalance2); - } - - @Test(enabled = false, description = "Trigger transferTokenWithNoPayable contract") - public void deploy05TransferTokenContract() { - String filePath = "src/test/resources/soliditycode/contractTrcToken036.sol"; - String contractName3 = "IllegalDecorate3"; - HashMap retMap3 = PublicMethed.getBycodeAbi(filePath, contractName3); - - String code3 = retMap3.get("byteCode").toString(); - String abi3 = retMap3.get("abI").toString(); - byte[] transferTokenWithOutPayableTestAddress = PublicMethed - .deployContract(contractName3, abi3, code3, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed - .transferAsset(transferTokenWithOutPayableTestAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenWithOutPayableTestAddress, 100, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info3; - AccountResourceMessage resourceInfo3 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info3 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance3 = info3.getBalance(); - Long beforeEnergyUsed3 = resourceInfo3.getEnergyUsed(); - Long beforeNetUsed3 = resourceInfo3.getNetUsed(); - Long beforeFreeNetUsed3 = resourceInfo3.getFreeNetUsed(); - Long beforeAssetIssueDevAddress3 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueUserAddress3 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress3 = PublicMethed - .getAssetIssueValue( - transferTokenWithOutPayableTestAddress, - assetAccountId, - blockingStubFull); - Long user001AddressAddressBalance3 = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - logger.info("beforeBalance:" + beforeBalance3); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed3); - logger.info("beforeNetUsed:" + beforeNetUsed3); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed3); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueContractAddress3); - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress3); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress3); - logger.info("user001AddressAddressBalance:" + user001AddressAddressBalance3); - - String param3 = - "\"" + Base58.encode58Check(user001Address) + "\",\"1\""; - - String triggerTxid3 = PublicMethed.triggerContract(transferTokenWithOutPayableTestAddress, - "transferTokenWithOutPayable(address,uint256)", - param3, false, 10, 1000000000L, assetAccountId - .toStringUtf8(), - 10, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter3 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter3 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance3 = infoafter3.getBalance(); - Long afterEnergyUsed3 = resourceInfoafter3.getEnergyUsed(); - Long afterAssetIssueDevAddress3 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed3 = resourceInfoafter3.getNetUsed(); - Long afterFreeNetUsed3 = resourceInfoafter3.getFreeNetUsed(); - Long afterAssetIssueContractAddress3 = PublicMethed - .getAssetIssueValue( - transferTokenWithOutPayableTestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress3 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afteruser001AddressAddressBalance3 = PublicMethed - .queryAccount(user001Address, blockingStubFull).getBalance(); - - Optional infoById3 = PublicMethed - .getTransactionInfoById(triggerTxid3, blockingStubFull); - Assert.assertTrue(infoById3.get().getResultValue() == 1); - - Assert.assertEquals(beforeAssetIssueDevAddress3, afterAssetIssueDevAddress3); - Assert.assertEquals(beforeAssetIssueUserAddress3, afterAssetIssueUserAddress3); - Assert.assertEquals(user001AddressAddressBalance3, afteruser001AddressAddressBalance3); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - null, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - null, blockingStubFull); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken037.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken037.java deleted file mode 100644 index 0d5a7c636ea..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken037.java +++ /dev/null @@ -1,250 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken037 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "Multi-level call transferToken tokenBalance") - public void deploy01TransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - - String filePath = "src/test/resources/soliditycode/contractTrcToken037.sol"; - String contractName = "receiveTrc10"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] btestAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - - String contractName1 = "transferTrc10"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - byte[] transferTokenContractAddress = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueBAddress:" + beforeAssetIssueBAddress); - - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - - String param = - "\"" + Base58.encode58Check(btestAddress) + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "receive(address)", - param, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 10, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueBAddress:" + afterAssetIssueBAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertEquals(afterBalanceContractAddress, beforeBalanceContractAddress); - Assert.assertTrue(afterAssetIssueDevAddress == beforeAssetIssueDevAddress - 10); - Assert.assertTrue(afterAssetIssueBAddress == beforeAssetIssueBAddress + 10); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken038.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken038.java deleted file mode 100644 index 3cac1f8d606..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken038.java +++ /dev/null @@ -1,268 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken038 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "Multi-level call transferToken assert tokenBalance ") - public void deployTransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 3, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 3, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertFalse(assetAccountId.toStringUtf8().equals("")); - - - // deploy transferTokenContract - int originEnergyLimit = 50000; - - String filePath = "src/test/resources/soliditycode/contractTrcToken038.sol"; - String contractName2 = "transferTrc10"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - final byte[] transferTokenContractAddress = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName = "receiveTrc10"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] btestAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(btestAddress, 1000000000L, fromAddress, - testKey002, blockingStubFull)); - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - dev001Address, - dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long beforeBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueBAddress:" + beforeAssetIssueBAddress); - - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - - String param = - "\"" + Base58.encode58Check(btestAddress) + "\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "receive(address)", - param, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(transferTokenContractAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueBAddress:" + afterAssetIssueBAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertEquals(afterBalanceContractAddress, beforeBalanceContractAddress); - Assert.assertTrue(afterAssetIssueContractAddress == beforeAssetIssueContractAddress); - Assert.assertTrue(afterAssetIssueBAddress == beforeAssetIssueBAddress); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - null, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - null, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken039.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken039.java deleted file mode 100644 index 0470715bc36..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken039.java +++ /dev/null @@ -1,392 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken039 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - byte[] proxyTestAddress; - byte[] atestAddress; - byte[] btestAddress; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "Deploy Proxy contract") - public void deploy01TransferTokenContract() { - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "dev001Address:" + Base58.encode58Check(dev001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info( - "user001Address:" + Base58.encode58Check(user001Address)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // deploy transferTokenContract - int originEnergyLimit = 50000; - - String filePath = "src/test/resources/soliditycode/contractTrcToken039.sol"; - String contractName = "Proxy"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - proxyTestAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 1000L, 0, originEnergyLimit, assetAccountId.toStringUtf8(), - 1000, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName1 = "A"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - atestAddress = PublicMethed - .deployContract(contractName1, abi1, code1, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName2 = "B"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath, contractName2); - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - btestAddress = PublicMethed - .deployContract(contractName2, abi2, code2, "", maxFeeLimit, - 0L, 0, originEnergyLimit, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Trigger Proxy contract use AddressA") - public void deploy02TransferTokenContract() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long beforeAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(proxyTestAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueAAddress = PublicMethed - .getAssetIssueValue(atestAddress, assetAccountId, - blockingStubFull); - Long beforeBalanceContractAddress = PublicMethed.queryAccount(proxyTestAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueBAddress:" + beforeAssetIssueBAddress); - - logger.info("beforeAssetIssueDevAddress:" + beforeAssetIssueDevAddress); - logger.info("beforeAssetIssueUserAddress:" + beforeAssetIssueUserAddress); - logger.info("beforeBalanceContractAddress:" + beforeBalanceContractAddress); - logger.info("beforeUserBalance:" + beforeUserBalance); - String param = - "\"" + Base58.encode58Check(atestAddress) + "\""; - String param1 = - "\"" + "1" + "\",\"" + Base58.encode58Check(user001Address) + "\",\"" + assetAccountId - .toStringUtf8() - + "\""; - - String triggerTxid = PublicMethed.triggerContract(proxyTestAddress, - "upgradeTo(address)", - param, false, 0, 1000000000L, "0", - 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - final String triggerTxid1 = PublicMethed.triggerContract(proxyTestAddress, - "trans(uint256,address,trcToken)", - param1, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueDevAddress = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(proxyTestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueAAddress = PublicMethed - .getAssetIssueValue(atestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueUserAddress = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long afterBalanceContractAddress = PublicMethed.queryAccount(proxyTestAddress, - blockingStubFull).getBalance(); - Long afterUserBalance = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueDevAddress); - logger.info("afterAssetIssueDevAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueBAddress:" + afterAssetIssueBAddress); - logger.info("afterAssetIssueUserAddress:" + afterAssetIssueUserAddress); - logger.info("afterBalanceContractAddress:" + afterBalanceContractAddress); - logger.info("afterUserBalance:" + afterUserBalance); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid1, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress == beforeAssetIssueUserAddress); - Assert.assertTrue(afterBalanceContractAddress == beforeBalanceContractAddress - 1); - Assert.assertTrue(afterAssetIssueContractAddress == beforeAssetIssueContractAddress + 1); - Assert.assertTrue(afterAssetIssueDevAddress == beforeAssetIssueDevAddress - 1); - Assert.assertTrue(afterUserBalance == beforeUserBalance + 1); - Assert.assertTrue(afterAssetIssueUserAddress == afterAssetIssueUserAddress); - Assert.assertTrue(afterAssetIssueBAddress == beforeAssetIssueBAddress); - } - - @Test(enabled = true, description = "Trigger Proxy contract use AddressB") - public void deploy03TransferTokenContract() { - Account info1; - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - info1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - Long beforeBalance1 = info1.getBalance(); - Long beforeEnergyUsed1 = resourceInfo1.getEnergyUsed(); - Long beforeNetUsed1 = resourceInfo1.getNetUsed(); - Long beforeFreeNetUsed1 = resourceInfo1.getFreeNetUsed(); - Long beforeAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long beforeAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - - Long beforeAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(proxyTestAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueBAddress1 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long beforeBalanceContractAddress1 = PublicMethed.queryAccount(proxyTestAddress, - blockingStubFull).getBalance(); - Long beforeUserBalance1 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - logger.info("beforeBalance1:" + beforeBalance1); - logger.info("beforeEnergyUsed1:" + beforeEnergyUsed1); - logger.info("beforeNetUsed1:" + beforeNetUsed1); - logger.info("beforeFreeNetUsed1:" + beforeFreeNetUsed1); - logger.info("beforeAssetIssueContractAddress1:" + beforeAssetIssueContractAddress1); - logger.info("beforeAssetIssueBAddress1:" + beforeAssetIssueBAddress1); - - logger.info("beforeAssetIssueDevAddress1:" + beforeAssetIssueDevAddress1); - logger.info("beforeAssetIssueUserAddress1:" + beforeAssetIssueUserAddress1); - logger.info("beforeBalanceContractAddress1:" + beforeBalanceContractAddress1); - logger.info("beforeUserBalance1:" + beforeUserBalance1); - String param3 = - "\"" + Base58.encode58Check(btestAddress) + "\""; - String param2 = - "\"" + "1" + "\",\"" + Base58.encode58Check(user001Address) + "\",\"" + assetAccountId - .toStringUtf8() - + "\""; - - String triggerTxid2 = PublicMethed.triggerContract(proxyTestAddress, - "upgradeTo(address)", - param3, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - String triggerTxid3 = PublicMethed.triggerContract(proxyTestAddress, - "trans(uint256,address,trcToken)", - param2, false, 0, 1000000000L, assetAccountId - .toStringUtf8(), - 1, dev001Address, dev001Key, - blockingStubFull); - Account infoafter1 = PublicMethed.queryAccount(dev001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterAssetIssueDevAddress1 = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - Long afterAssetIssueContractAddress1 = PublicMethed - .getAssetIssueValue(proxyTestAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueBAddress1 = PublicMethed - .getAssetIssueValue(btestAddress, assetAccountId, - blockingStubFull); - - Long afterAssetIssueUserAddress1 = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterBalanceContractAddress1 = PublicMethed.queryAccount(proxyTestAddress, - blockingStubFull).getBalance(); - Long afterUserBalance1 = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("afterBalance1:" + afterBalance1); - logger.info("afterEnergyUsed1:" + afterEnergyUsed1); - logger.info("afterNetUsed1:" + afterNetUsed1); - logger.info("afterFreeNetUsed1:" + afterFreeNetUsed1); - logger.info("afterAssetIssueCount1:" + afterAssetIssueDevAddress1); - logger.info("afterAssetIssueDevAddress1:" + afterAssetIssueContractAddress1); - logger.info("afterAssetIssueBAddress1:" + afterAssetIssueBAddress1); - logger.info("afterAssetIssueUserAddress1:" + afterAssetIssueUserAddress1); - logger.info("afterBalanceContractAddress1:" + afterBalanceContractAddress1); - logger.info("afterUserBalance1:" + afterUserBalance1); - - Optional infoById2 = PublicMethed - .getTransactionInfoById(triggerTxid3, blockingStubFull); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - Assert.assertTrue(afterAssetIssueUserAddress1 == beforeAssetIssueUserAddress1); - Assert.assertTrue(afterBalanceContractAddress1 == beforeBalanceContractAddress1 - 1); - Assert.assertTrue(afterAssetIssueContractAddress1 == beforeAssetIssueContractAddress1 + 1); - Assert.assertTrue(afterAssetIssueDevAddress1 == beforeAssetIssueDevAddress1 - 1); - Assert.assertTrue(afterUserBalance1 == beforeUserBalance1 + 1); - Assert.assertTrue(afterAssetIssueUserAddress1 == afterAssetIssueUserAddress1); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken041.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken041.java deleted file mode 100644 index 5fcaad6f0f7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken041.java +++ /dev/null @@ -1,231 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken041 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); - } - - - @Test(enabled = true, description = "Trigger contract msg.tokenId add 1,msg.tokenValue add 1") - public void deployTransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - ByteString assetAccountDev = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - final ByteString fakeTokenId = ByteString - .copyFromUtf8(Long.toString(Long.valueOf(assetAccountDev.toStringUtf8()) + 100)); - - // devAddress transfer token to A - PublicMethed.transferAsset(dev001Address, assetAccountId.toByteArray(), 101, user001Address, - user001Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // deploy transferTokenContract - String filePath = "src/test/resources/soliditycode/contractTrcToken041.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 10000, assetAccountId.toStringUtf8(), - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - user001Address, - user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - info = PublicMethed.queryAccount(user001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueCount); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - - // user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(dev001Address) + "\",\"" + fakeTokenId - .toStringUtf8() - + "\",\"105\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 100000000L, fakeTokenId.toStringUtf8(), - 10000000L, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(user001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueCount); - logger.info("afterAssetIssueContractAddress:" + afterAssetIssueContractAddress); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertEquals(beforeAssetIssueCount, afterAssetIssueCount); - Assert.assertEquals(beforeAssetIssueContractAddress, afterAssetIssueContractAddress); - Assert.assertTrue(afterEnergyUsed == 0L); - - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken043.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken043.java deleted file mode 100644 index ba1aa82dcd0..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken043.java +++ /dev/null @@ -1,614 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.protos.Protocol.TransactionInfo.code.FAILED; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken043 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static ByteString assetAccountUser = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - private byte[] resultContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - private byte[] user002Address = ecKey3.getAddress(); - private String user002Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - - @Test(enabled = true, description = "TransferToken with invalid tokenId, deploy transferContract") - public void test01DeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 5048_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 5048_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.sendcoin(user002Address, 5048_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken043.sol"; - String contractName = "transferTokenContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with invalid tokenId, deploy receive contract") - public void test02DeployRevContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken043.sol"; - String contractName = "Result"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String recieveTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 1000, assetAccountId.toStringUtf8(), - 100, null, dev001Key, dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // after deploy, check account resource - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Optional infoById = PublicMethed - .getTransactionInfoById(recieveTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (recieveTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy receive failed with message: " + infoById.get().getResMessage()); - } - - resultContractAddress = infoById.get().getContractAddress().toByteArray(); - - SmartContract smartContract = PublicMethed - .getContract(resultContractAddress, blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with invalid tokenId, transferToken") - public void test03TriggerContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.transferAsset(user002Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - // tokenId is 100_0000 - String tokenId = Long.toString(100_0000); - Long tokenValue = Long.valueOf(1); - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Triger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenId is -1 - tokenId = Long.toString(-1); - tokenValue = Long.valueOf(1); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - //Assert.assertEquals("validateForSmartContract failure, not valid token id", - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenId is 1 - tokenId = Long.toString(Long.MIN_VALUE); - tokenValue = Long.valueOf(1); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenId is long.min - tokenId = Long.toString(Long.MIN_VALUE); - tokenValue = Long.valueOf(1); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - // tokenId is 0, contract not have trx - tokenId = Long.toString(0); - tokenValue = Long.valueOf(1); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - // tokenId is 0, account does not have trx - param = "\"" + Base58.encode58Check(dev001Address) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user002Address, user002Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user002Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .sendcoin(user002Address, 5000000, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenId is 0, transfer contract has trx, transfer to a contract - tokenId = Long.toString(0); - tokenValue = Long.valueOf(1); - callValue = Long.valueOf(1); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user002Address, user002Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user002Address, user002Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user002Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //tokenId is 0, transfer contract has trx, transfer to normal account - tokenId = Long.toString(0); - tokenValue = Long.valueOf(1); - callValue = Long.valueOf(1); - - param = "\"" + Base58.encode58Check(dev001Address) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user002Address, user002Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user002Address, user002Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user002Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenid bigger than long.max, trigger to a contract - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTestIDOverBigInteger(address)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user002Address, user002Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user002Address, user002Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user002Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // tokenid bigger than long.max, trigger to a normal account - param = "\"" + Base58.encode58Check(dev001Address) + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTestIDOverBigInteger(address)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user002Address, user002Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - Assert.assertEquals(receiveAssetAfter, receiveAssetBefore); - Assert.assertEquals(transferAssetBefore, transferAssetAfter); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user002Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken048.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken048.java deleted file mode 100644 index 7b58d3350bc..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken048.java +++ /dev/null @@ -1,229 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken048 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "TransferToken msg.value msg,tokenvalue is negative number") - public void deployTransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - ByteString assetAccountDev = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - final ByteString fakeassetAccountId = ByteString - .copyFromUtf8(Long.toString(Long.valueOf(assetAccountDev.toStringUtf8()) + 100)); - - // devAddress transfer token to A - PublicMethed.transferAsset(dev001Address, assetAccountId.toByteArray(), 101, user001Address, - user001Key, blockingStubFull); - - // deploy transferTokenContract - String filePath = "./src/test/resources/soliditycode/contractTrcToken048.sol"; - String contractName = "Test"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 10000, "0", - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - user001Address, - user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - info = PublicMethed.queryAccount(user001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueCount); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - - // user trigger A to transfer token to B - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "testMsgTokenValue()", - "#", false, 0, 100000000L, fakeassetAccountId.toStringUtf8(), - -1000, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String triggerTxid1 = PublicMethed.triggerContract(transferTokenContractAddress, - "testMsgValue()", - "#", false, -1000, 100000000L, "0", - 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(user001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueCount); - logger.info("afterAssetIssueContractAddress:" + afterAssetIssueContractAddress); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertEquals(beforeAssetIssueCount, afterAssetIssueCount); - Assert.assertEquals(beforeAssetIssueContractAddress, afterAssetIssueContractAddress); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken049.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken049.java deleted file mode 100644 index 1e6a11be5ed..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken049.java +++ /dev/null @@ -1,261 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken049 { - - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); - } - - /** - * constructor. - */ - - public ByteString createAssetissue(byte[] devAddress, String devKey, String tokenName) { - - ByteString assetAccountId = null; - ByteString addressBS1 = ByteString.copyFrom(devAddress); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - - logger.info("The token name: " + tokenName); - - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(devAddress, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, devKey, blockingStubFull)); - - Account getAssetIdFromThisAccount = PublicMethed.queryAccount(devAddress, blockingStubFull); - assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - } else { - logger.info("This account already create an assetisue"); - Optional queryAssetByAccount1 = Optional.ofNullable(assetIssueList1); - tokenName = ByteArray.toStr(queryAssetByAccount1.get().getAssetIssue(0) - .getName().toByteArray()); - } - return assetAccountId; - } - - @Test(enabled = true, description = "TransferToken to myself") - public void deployTransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String tokenName = "testAI_" + randomInt(10000, 90000); - ByteString tokenId = createAssetissue(user001Address, user001Key, tokenName); - int i = randomInt(6666666, 9999999); - - // devAddress transfer token to A - PublicMethed.transferAsset(dev001Address, tokenId.toByteArray(), 101, user001Address, - user001Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // deploy transferTokenContract - String filePath = "./src/test/resources/soliditycode/contractTrcToken049.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 10000, tokenId.toStringUtf8(), - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - byte[] transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, tokenId.toByteArray(), 100, user001Address, - user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - info = PublicMethed.queryAccount(user001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueCount = - PublicMethed.getAssetIssueValue(user001Address, tokenId, blockingStubFull); - Long beforeAssetIssueContractAddress = - PublicMethed.getAssetIssueValue(transferTokenContractAddress, tokenId, - blockingStubFull); - final Long beforeAssetIssueDev = PublicMethed.getAssetIssueValue(dev001Address, tokenId, - blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueCount); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - - // user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(dev001Address) + "\",\"" + tokenId - .toStringUtf8() - + "\",\"1\""; - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 100000000L, "0", - 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(user001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueCount = - PublicMethed.getAssetIssueValue(user001Address, tokenId, blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = - PublicMethed.getAssetIssueValue(transferTokenContractAddress, tokenId, - blockingStubFull); - final Long afterAssetIssueDev = PublicMethed.getAssetIssueValue(dev001Address, tokenId, - blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueCount); - logger.info("afterAssetIssueContractAddress:" + afterAssetIssueContractAddress); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertEquals(beforeBalance, afterBalance); - Assert.assertEquals(beforeAssetIssueCount, afterAssetIssueCount); - Assert.assertTrue(beforeAssetIssueContractAddress - 1 == afterAssetIssueContractAddress); - - Assert.assertTrue(beforeAssetIssueDev + 1 == afterAssetIssueDev); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken050.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken050.java deleted file mode 100644 index b60c75bd32d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken050.java +++ /dev/null @@ -1,239 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken050 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "TransferToken to contract address ") - public void deployTransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // devAddress transfer token to A - PublicMethed.transferAsset(user001Address, assetAccountId.toByteArray(), 101, dev001Address, - dev001Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // deploy transferTokenContract - - String filePath = "./src/test/resources/soliditycode/contractTrcToken050.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - byte[] transferTokenContractAddress; - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 10000, assetAccountId.toStringUtf8(), - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - user001Address, - user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - info = PublicMethed.queryAccount(user001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long beforeAssetIssueDev = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueCount); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDev:" + beforeAssetIssueDev); - - // user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(transferTokenContractAddress) + "\",\"" + assetAccountId - .toStringUtf8() - + "\",\"1\""; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 100000000L, "0", - 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(user001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - final Long afterAssetIssueDev = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueCount); - logger.info("afterAssetIssueContractAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueDev:" + afterAssetIssueDev); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(beforeAssetIssueCount, afterAssetIssueCount); - Assert.assertTrue(beforeAssetIssueContractAddress == afterAssetIssueContractAddress); - Assert.assertEquals(beforeAssetIssueDev, afterAssetIssueDev); - - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken051.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken051.java deleted file mode 100644 index 2c892c19608..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken051.java +++ /dev/null @@ -1,250 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.protos.Protocol.TransactionInfo.code.FAILED; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken051 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "TransferToken to contract developer tokenID is 0") - public void deployTransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 6048000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // devAddress transfer token to A - PublicMethed.transferAsset(dev001Address, assetAccountId.toByteArray(), 101, user001Address, - user001Key, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // deploy transferTokenContract - String filePath = "./src/test/resources/soliditycode/contractTrcToken051.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] transferTokenContractAddress; - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 10000, assetAccountId.toStringUtf8(), - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - user001Address, - user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - info = PublicMethed.queryAccount(user001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long beforeAssetIssueDev = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long beforetransferTokenContractAddressBalance = PublicMethed - .queryAccount(transferTokenContractAddress, blockingStubFull).getBalance(); - Long beforeDevBalance = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueCount); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDev:" + beforeAssetIssueDev); - - String fakeassetAccountId = Long.toString(0L); - - String param = "\"" + Base58.encode58Check(dev001Address) - + "\"," + fakeassetAccountId + ",\"1\""; - // user trigger A to transfer token to B - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 100000000L, "0", - 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(user001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - Long afterAssetIssueDev = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - Long aftertransferTokenContractAddressBalance = PublicMethed - .queryAccount(transferTokenContractAddress, blockingStubFull).getBalance(); - Long afterDevBalance = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getBalance(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueCount); - logger.info("afterAssetIssueContractAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueDev:" + afterAssetIssueDev); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertFalse(infoById.get().getResultValue() == 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - Assert.assertEquals(beforeAssetIssueCount, afterAssetIssueCount); - Assert.assertEquals(beforeAssetIssueContractAddress, afterAssetIssueContractAddress); - Assert.assertEquals(beforeAssetIssueDev, afterAssetIssueDev); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken052.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken052.java deleted file mode 100644 index a7c0b61920a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken052.java +++ /dev/null @@ -1,242 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken052 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - - @Test(enabled = true, description = "TransferToken to contract address tokenID is 0") - public void deployTransferTokenContract() { - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 6048000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, - 10000L, 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - // devAddress transfer token to A - PublicMethed.transferAsset(dev001Address, assetAccountId.toByteArray(), 101, user001Address, - user001Key, blockingStubFull); - - // deploy transferTokenContract - String filePath = "./src/test/resources/soliditycode/contractTrcToken052.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 10000, assetAccountId.toStringUtf8(), - 0, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert - .assertTrue(PublicMethed.sendcoin(transferTokenContractAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - // devAddress transfer token to userAddress - PublicMethed - .transferAsset(transferTokenContractAddress, assetAccountId.toByteArray(), 100, - user001Address, - user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - info = PublicMethed.queryAccount(user001Address, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long beforeAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long beforeAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long beforeAssetIssueDev = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - final Long beforetransferTokenContractAddressBalance = PublicMethed - .queryAccount(transferTokenContractAddress, blockingStubFull).getBalance(); - final Long beforeDevBalance = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getBalance(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("beforeAssetIssueCount:" + beforeAssetIssueCount); - logger.info("beforeAssetIssueContractAddress:" + beforeAssetIssueContractAddress); - logger.info("beforeAssetIssueDev:" + beforeAssetIssueDev); - String fakeassetAccountId = Long.toString(0L); - - String param = "\"" + Base58.encode58Check(transferTokenContractAddress) - + "\"," + fakeassetAccountId + ",\"1\""; - // user trigger A to transfer token to B - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 100000000L, "0", - 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account infoafter = PublicMethed.queryAccount(user001Address, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(user001Address, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterAssetIssueCount = PublicMethed - .getAssetIssueValue(user001Address, assetAccountId, - blockingStubFull); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long afterAssetIssueContractAddress = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, - assetAccountId, - blockingStubFull); - Long afterAssetIssueDev = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, - blockingStubFull); - final Long aftertransferTokenContractAddressBalance = PublicMethed - .queryAccount(transferTokenContractAddress, blockingStubFull).getBalance(); - final Long afterDevBalance = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getBalance(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("afterAssetIssueCount:" + afterAssetIssueCount); - logger.info("afterAssetIssueContractAddress:" + afterAssetIssueContractAddress); - logger.info("afterAssetIssueDev:" + afterAssetIssueDev); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Long fee = infoById.get().getFee(); - Assert.assertEquals(beforeAssetIssueCount, afterAssetIssueCount); - Assert.assertEquals( - beforetransferTokenContractAddressBalance, aftertransferTokenContractAddressBalance); - Assert.assertEquals(beforeDevBalance, afterDevBalance); - Assert.assertEquals(beforeAssetIssueCount, afterAssetIssueCount); - Assert.assertEquals(beforeAssetIssueContractAddress, afterAssetIssueContractAddress); - Assert.assertEquals(beforeAssetIssueDev, afterAssetIssueDev); - PublicMethed.unFreezeBalance(dev001Address, dev001Key, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(user001Address, user001Key, 1, - user001Address, blockingStubFull); - - } - - /** - * constructor. - */ - - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken054.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken054.java deleted file mode 100644 index ac35758c6b3..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken054.java +++ /dev/null @@ -1,296 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken054 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Trigger transferToken with 0 tokenValue") - public void testTriggerTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 70000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - //String contractName = "transferTokenContract"; - - String filePath = "./src/test/resources/soliditycode/contractTrcToken054.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 0; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, callValue, 0, 10000, - tokenId, tokenValue, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountAfter: " + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = assetAccountId.toStringUtf8(); - tokenValue = 0; - callValue = 5; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info( - "the value: " + PublicMethed.getStrings(infoById.get().getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(infoById.get().getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken055.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken055.java deleted file mode 100644 index 4ea05fe33d7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken055.java +++ /dev/null @@ -1,295 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken055 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Trigger TransferToken with 0 tokenId," - + " and not existed tokenValue") - public void triggerTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 70000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() - + ", devAssetCountBefore: " + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken055.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 0; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, callValue, 0, 10000, - tokenId, tokenValue, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - tokenId = Long.toString(Long.MAX_VALUE); - tokenValue = 0; - callValue = 5; - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info( - "the value: " + PublicMethed.getStrings(infoById.get().getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(infoById.get().getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken060.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken060.java deleted file mode 100644 index 9ffa0dd7d98..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken060.java +++ /dev/null @@ -1,245 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken060 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - } - - @Test(enabled = true, description = "DeployContract with 0 tokenValue") - public void deployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 130000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken060.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 0; - long callValue = 5; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(tokenValue), - Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100L + tokenValue), contractAssetCount); - - // get and verify the msg.value and msg.id - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - final String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getResultInCon()", "#", false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info("The msg value: " + PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray())); - - List retList = PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken061.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken061.java deleted file mode 100644 index 078785c3f75..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken061.java +++ /dev/null @@ -1,230 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken061 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - } - - @Test(enabled = true, description = "DeployContract with 0 tokenValue and not existed tokenId") - public void deployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 130000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken061.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String tokenId = Long.toString(Long.MAX_VALUE); - long tokenValue = 0; - long callValue = 10; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(tokenValue), - Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100L + tokenValue), contractAssetCount); - - // get and verify the msg.value and msg.id - - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getResultInCon()", "#", false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info("The msg value: " + PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray())); - - List retList = PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken064.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken064.java deleted file mode 100644 index 095fd394072..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken064.java +++ /dev/null @@ -1,497 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.protos.Protocol.TransactionInfo.code.FAILED; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken064 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static ByteString assetAccountUser = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - private byte[] resultContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue and " - + "tokenId in exception condition, deploy transfer contract") - public void test01DeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(user001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountUser = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getAssetIssuedID(); - logger.info("The assetAccountUser token name: " + tokenName); - logger.info("The assetAccountUser token ID: " + assetAccountUser.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken064.sol"; - String contractName = "transferTokenContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue and " - + "tokenId in exception condition, deploy receiver contract") - public void test02DeployRevContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - // before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken064.sol"; - String contractName = "Result"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String recieveTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 1000, assetAccountId.toStringUtf8(), - 100, null, dev001Key, dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(recieveTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (recieveTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy receive failed with message: " + infoById.get().getResMessage()); - } - resultContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed - .getContract(resultContractAddress, blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - // after deploy, check account resource - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue and " - + "tokenId in exception condition, trigger contract") - public void test03TriggerContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - Long callValue = Long.valueOf(0); - String param = "\"" + Base58.encode58Check(resultContractAddress) + "\""; - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTestValue0IdBigInteger(address)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info(infoById.get().getResMessage().toStringUtf8()); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - //Assert.assertEquals("BigInteger out of long range", - infoById.get().getResMessage().toStringUtf8()); - - //transfer to a normal account - param = "\"" + Base58.encode58Check(dev001Address) + "\""; - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTestValue0IdBigInteger(address)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - //Assert.assertEquals("BigInteger out of long range", - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - String tokenId = Long.toString(Long.MIN_VALUE); - Long tokenValue = Long.valueOf(0); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - tokenId = Long.toString(100_0000); - tokenValue = Long.valueOf(0); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - tokenId = Long.toString(-1); - tokenValue = Long.valueOf(0); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - tokenId = Long.toString(0); - tokenValue = Long.valueOf(0); - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - callValue = Long.valueOf(0); - - param = "\"" + Base58.encode58Check(resultContractAddress) + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTestValueMaxLong(address)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //transfer to a normal account - param = "\"" + Base58.encode58Check(dev001Address) + "\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTestValueMaxLong(address)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - Assert.assertEquals(receiveAssetAfter, receiveAssetBefore); - Assert.assertEquals(transferAssetBefore, transferAssetAfter); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken066.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken066.java deleted file mode 100644 index 5c606951c4a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken066.java +++ /dev/null @@ -1,458 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken066 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - private byte[] resultContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, deploy transferContract") - public void test01DeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 5048_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 4048_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken066.sol"; - String contractName = "transferTokenContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, deploy receive contract") - public void test02DeployRevContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken066.sol"; - String contractName = "Result"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String recieveTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 1000, assetAccountId.toStringUtf8(), - 100, null, dev001Key, dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(recieveTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (recieveTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy receive failed with message: " + infoById.get().getResMessage()); - } - - resultContractAddress = infoById.get().getContractAddress().toByteArray(); - - SmartContract smartContract = PublicMethed - .getContract(resultContractAddress, blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - // after deploy, check account resource - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, trigger transferContract") - public void test03TriggerContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed - .getAssetIssueValue(transferTokenContractAddress, assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - String tokenId = assetAccountId.toStringUtf8(); - Long tokenValue = Long.valueOf(0); - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - TransactionInfo transactionInfo = infoById.get(); - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - logger.info("the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(tokenId, msgId.toString()); - Assert.assertEquals(tokenValue, msgTokenValue); - Assert.assertEquals(callValue, msgCallValue); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - Assert.assertEquals(receiveAssetAfter - receiveAssetBefore, - transferAssetBefore + 2L - transferAssetAfter); - - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, get contract tokenBalance") - public void test04TriggerTokenBalanceContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 1000_000_000L, - 0, 1, user001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("before trigger, dev energy limit is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, dev energy usage is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, dev balance is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, - blockingStubFull).getBalance(); - - logger.info("before trigger, user energy limit is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, user energy usage is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, user balance is " + Long.toString(userBalanceBefore)); - - String param = "\"" + Base58.encode58Check(resultContractAddress) + "\",\"" - + assetAccountId.toStringUtf8() + "\""; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getTokenBalnce(address,trcToken)", - param, false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed.getTransactionInfoById(triggerTxid, - blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - logger.info("the receivercontract token: " + ByteArray - .toLong(infoById.get().getContractResult(0).toByteArray())); - Long assetIssueCount = PublicMethed.getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("the receivercontract token(getaccount): " + assetIssueCount); - - Assert.assertTrue(assetIssueCount == ByteArray - .toLong(ByteArray.fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken067.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken067.java deleted file mode 100644 index a8e06dd8b19..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken067.java +++ /dev/null @@ -1,463 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken067 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - private byte[] resultContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, " - + "and not existed tokenId, deploy transfer contract") - public void test01DeployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 5048_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 4048_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken067.sol"; - String contractName = "transferTokenContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - assetAccountId.toStringUtf8(), 100, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, " - + "and not existed tokenId, deploy receive contract") - public void test02DeployRevContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - // before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken067.sol"; - String contractName = "Result"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String recieveTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 1000, assetAccountId.toStringUtf8(), - 100, null, dev001Key, dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(recieveTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (recieveTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy receive failed with message: " + infoById.get().getResMessage()); - } - - // after deploy, check account resource - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed - .getAssetIssueValue(dev001Address, assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - resultContractAddress = infoById.get().getContractAddress().toByteArray(); - - SmartContract smartContract = PublicMethed - .getContract(resultContractAddress, blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - Long contractAssetCount = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100), contractAssetCount); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, " - + "and not existed tokenId, trigger transfer contract") - public void test03TriggerContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long receiveAssetBefore = PublicMethed.getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("before trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + receiveAssetBefore); - - String tokenId = Long.toString(Long.MAX_VALUE); - Long tokenValue = Long.valueOf(0); - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(resultContractAddress) - + "\",\"" + tokenValue + "\"," + tokenId; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "transferTokenTest(address,uint256,trcToken)", param, false, callValue, - 1000000000L, assetAccountId.toStringUtf8(), 2, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info( - "the value: " + PublicMethed.getStrings(transactionInfo.getLogList().get(0).getData() - .toByteArray())); - - List retList = PublicMethed.getStrings(transactionInfo.getLogList().get(0) - .getData().toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(tokenId, msgId.toString()); - Assert.assertEquals(tokenValue, msgTokenValue); - Assert.assertEquals(callValue, msgCallValue); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Long transferAssetAfter = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", transferAssetAfter is " + transferAssetAfter); - - Long receiveAssetAfter = PublicMethed.getAssetIssueValue(resultContractAddress, - assetAccountId, blockingStubFull); - logger.info("after trigger, resultContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", receiveAssetAfter is " + receiveAssetAfter); - - Assert.assertEquals(receiveAssetAfter - receiveAssetBefore, - transferAssetBefore + 2L - transferAssetAfter); - } - - @Test(enabled = true, description = "TransferToken with 0 tokenValue, " - + "and not existed tokenId, get tokenBalance") - public void test04TriggerTokenBalanceContract() { - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 1000_000_000L, - 0, 1, user001Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before trigger, dev energy limit is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, dev energy usage is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, dev balance is " + Long.toString(devBalanceBefore)); - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, - blockingStubFull).getBalance(); - logger.info("before trigger, user energy limit is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, user energy usage is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, user balance is " + Long.toString(userBalanceBefore)); - - String param = "\"" + Base58.encode58Check(resultContractAddress) + "\",\"" - + assetAccountId.toStringUtf8() + "\""; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getTokenBalnce(address,trcToken)", - param, false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed.getTransactionInfoById(triggerTxid, - blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - logger.info("the receivercontract token: " + ByteArray - .toLong(infoById.get().getContractResult(0).toByteArray())); - Long assetIssueCount = PublicMethed.getAssetIssueValue(resultContractAddress, assetAccountId, - blockingStubFull); - logger.info("the receivercontract token(getaccount): " + assetIssueCount); - Assert.assertTrue(assetIssueCount == ByteArray - .toLong(ByteArray.fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken073.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken073.java deleted file mode 100644 index 2b1bd92b09a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken073.java +++ /dev/null @@ -1,300 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken073 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - } - - @Test(enabled = true, description = "TokenBalance with correct tokenValue and tokenId") - public void testTokenBalanceContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 11000_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 300000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken073.sol"; - String contractName = "Dest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 5; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(tokenValue), - Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100L + tokenValue), contractAssetCount); - - // get and verify the msg.value and msg.id - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long devAssetBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - logger.info("before trigger, dev001Address has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + devAssetBefore); - - tokenId = assetAccountId.toStringUtf8(); - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getToken(trcToken)", tokenId, false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - logger.info("The msg value: " + infoById.get().getLogList().get(0).getTopicsList()); - - Long msgTokenBalance = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(1).toByteArray()); - Long msgId = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(2).toByteArray()); - Long msgTokenValue = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(3).toByteArray()); - - logger.info("msgTokenBalance: " + msgTokenBalance); - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - - Assert.assertEquals(msgTokenBalance, devAssetBefore); - - tokenId = Long.toString(Long.valueOf(assetAccountId.toStringUtf8()) + 1000); - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getToken(trcToken)", tokenId, false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info("The msg value: " + infoById.get().getLogList().get(0).getTopicsList()); - - msgTokenBalance = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(1).toByteArray()); - msgId = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(2).toByteArray()); - msgTokenValue = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(3).toByteArray()); - - logger.info("msgTokenBalance: " + msgTokenBalance); - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - - Assert.assertEquals(Long.valueOf(0), msgTokenBalance); - - tokenId = Long.toString(Long.MAX_VALUE); - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getToken(trcToken)", tokenId, false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info("The msg value: " + infoById.get().getLogList().get(0).getTopicsList()); - - msgTokenBalance = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(1).toByteArray()); - msgId = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(2).toByteArray()); - msgTokenValue = ByteArray - .toLong(infoById.get().getLogList().get(0).getTopicsList().get(3).toByteArray()); - - logger.info("msgTokenBalance: " + msgTokenBalance); - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - - Assert.assertEquals(Long.valueOf(0), msgTokenBalance); - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken075.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken075.java deleted file mode 100644 index 4a9a9d4ce0b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken075.java +++ /dev/null @@ -1,302 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import static org.tron.protos.Protocol.TransactionInfo.code.FAILED; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken075 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - } - - @Test(enabled = true, description = "TokenBalance with exception condition") - public void testTokenBalanceContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 11000_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 130000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed - .queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken075.sol"; - String contractName = "Dest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 5; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(tokenValue), - Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100L + tokenValue), contractAssetCount); - - // get and verify the msg.value and msg.id - - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - Long devAssetBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - logger.info("before trigger, dev001Address has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + devAssetBefore); - - tokenId = Long.toString(100_0000); - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getToken(trcToken)", tokenId, false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - - tokenId = Long.toString(0); - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getToken(trcToken)", tokenId, false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - - tokenId = Long.toString(-1); - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getToken(trcToken)", tokenId, false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - tokenId = Long.toString(Long.MIN_VALUE); - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getToken(trcToken)", tokenId, false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getTokenLongMin()", "#", false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getTokenLongMax()", "#", false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert.assertEquals(FAILED, infoById.get().getResult()); - //Assert.assertEquals("BigInteger out of long range", - Assert.assertEquals("REVERT opcode executed", - infoById.get().getResMessage().toStringUtf8()); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken076.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken076.java deleted file mode 100644 index 1735f9b604c..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken076.java +++ /dev/null @@ -1,149 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken076 { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress = ecKey1.getAddress(); - String testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - @Test(enabled = true, description = "Origin test ") - public void testDeployTransferTokenContract() { - PublicMethed - .sendcoin(grammarAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken076.sol"; - String contractName = "Test"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - contractAddress = infoById.get().getContractAddress().toByteArray(); - - PublicMethed.triggerContract(contractAddress, - "test()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - txid = PublicMethed.triggerContract(contractAddress, - "getResult1()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - logger.info("infoById:" + infoById); - Long returnnumber = ByteArray.toLong(ByteArray.fromHexString(ByteArray.toHexString( - infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber == 1); - - txid = PublicMethed.triggerContract(contractAddress, - "getResult2()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Deploy energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - logger.info("-------------------------"); - - logger.info("infoById:" + infoById); - Long returnnumber2 = ByteArray.toLong(ByteArray.fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - - Assert.assertTrue(returnnumber2 == 1); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken077.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken077.java deleted file mode 100644 index 57e6411a8cc..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken077.java +++ /dev/null @@ -1,195 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken077 { - - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] grammarAddress = ecKey1.getAddress(); - String testKeyForGrammarAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForGrammarAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - @Test(enabled = false) - public void testAddress001() { - PublicMethed - .sendcoin(grammarAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken077.sol"; - String contractName = "trcToken077"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String deployTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - Optional deployInfo = PublicMethed - .getTransactionInfoById(deployTxid, blockingStubFull); - contractAddress = deployInfo.get().getContractAddress().toByteArray(); - logger.info("Deploy energy is " + deployInfo.get().getReceipt().getEnergyUsageTotal()); - - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "addressTest()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - logger.info("Trigger energy is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - } - - @Test(enabled = true, description = "The value of address is not at the beginning of 41") - public void testAddress002() { - PublicMethed - .sendcoin(grammarAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String contractName = "trcToken077"; - - String code = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600" - + "080fd5b5060b0806100396000396000f3fe6080604052348015600f57600080fd5b50d38015601b57600080" - + "fd5b50d28015602757600080fd5b5060043610605c577c01000000000000000000000000000000000000000" - + "0000000000000000060003504636241c1d881146061575b600080fd5b60676079565b604080519182525190" - + "81900360200190f35b60405130908190529056fea165627a7a723058207b9b52e71420f2fa4cb55ffd55641" - + "355ec84e09d6d4545c629dde7cc01d74a100029"; - String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"addressTest\",\"outputs\":[{\"name" - + "\":\"addressValue\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonp" - + "ayable\",\"type\":\"function\"}]"; - - String deploytxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testKeyForGrammarAddress, - grammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional deployById = PublicMethed - .getTransactionInfoById(deploytxid, blockingStubFull); - contractAddress = deployById.get().getContractAddress().toByteArray(); - logger.info("infoById:" + deployById); - - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "addressTest()", "#", false, - 0, maxFeeLimit, grammarAddress, testKeyForGrammarAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - - Assert.assertNotNull(infoById); - byte[] a = infoById.get().getContractResult(0).toByteArray(); - byte[] b = subByte(a, 11, 1); - byte[] c = subByte(a, 0, 11); - byte[] e = "41".getBytes(); - byte[] d = subByte(a, 12, 20); - - logger.info("a:" + ByteArray.toHexString(a)); - - logger.info("b:" + ByteArray.toHexString(b)); - logger.info("c:" + ByteArray.toHexString(c)); - - logger.info("d:" + ByteArray.toHexString(d)); - - logger.info("41" + ByteArray.toHexString(d)); - String exceptedResult = "41" + ByteArray.toHexString(d); - String realResult = ByteArray.toHexString(b); - Assert.assertEquals(realResult, "00"); - Assert.assertNotEquals(realResult, "41"); - - Assert.assertEquals(exceptedResult, ByteArray.toHexString(contractAddress)); - - } - - - /** - * constructor. - */ - - public byte[] subByte(byte[] b, int off, int length) { - byte[] b1 = new byte[length]; - System.arraycopy(b, off, b1, 0, length); - return b1; - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken078.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken078.java deleted file mode 100644 index 4a5bfa91ada..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken078.java +++ /dev/null @@ -1,287 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j - -public class ContractTrcToken078 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] internalTxsAddress = ecKey1.getAddress(); - String testKeyForinternalTxsAddress = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - String priKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKeyForinternalTxsAddress); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - } - - - @Test(enabled = true, description = "Origin test call") - public void testOriginCall001() { - PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken078.sol"; - String contractName = "callerContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById : " + infoById); - contractAddress = infoById.get().getContractAddress().toByteArray(); - - String filePath1 = "./src/test/resources/soliditycode/contractTrcToken078.sol"; - String contractName1 = "calledContract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath1, contractName1); - - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - - txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById : " + infoById); - byte[] contractAddress1; - contractAddress1 = infoById.get().getContractAddress().toByteArray(); - - - String filePath2 = "./src/test/resources/soliditycode/contractTrcToken078.sol"; - String contractName2 = "c"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath2, contractName2); - - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - - txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - byte[] contractAddress2 = infoById.get().getContractAddress().toByteArray(); - logger.info("infoById : " + infoById); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) - + "\",\"" + Base58.encode58Check(contractAddress2) + "\""; - - String txid2 = ""; - txid2 = PublicMethed.triggerContract(contractAddress, - "sendToB2(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - logger.info("Trigger InfobyId: " + infoById2); - Account info1 = PublicMethed.queryAccount(internalTxsAddress, blockingStubFull); - AccountResourceMessage resourceInfo1 = PublicMethed.getAccountResource(internalTxsAddress, - blockingStubFull); - logger.info("getEnergyUsed " + resourceInfo1.getEnergyUsed()); - logger.info("getEnergyLimit " + resourceInfo1.getEnergyLimit()); - Assert.assertTrue(infoById2.get().getResultValue() == 0); - - - } - - @Test(enabled = true, description = "Origin test delegatecall") - public void testOriginDelegatecall001() { - PublicMethed - .sendcoin(internalTxsAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken078.sol"; - String contractName = "callerContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById : " + infoById); - contractAddress = infoById.get().getContractAddress().toByteArray(); - - String filePath1 = "./src/test/resources/soliditycode/contractTrcToken078.sol"; - String contractName1 = "calledContract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath1, contractName1); - - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName1, abi1, code1, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById : " + infoById); - byte[] contractAddress1; - contractAddress1 = infoById.get().getContractAddress().toByteArray(); - - String filePath2 = "./src/test/resources/soliditycode/contractTrcToken078.sol"; - String contractName2 = "c"; - HashMap retMap2 = PublicMethed.getBycodeAbi(filePath2, contractName2); - - String code2 = retMap2.get("byteCode").toString(); - String abi2 = retMap2.get("abI").toString(); - txid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName2, abi2, code2, "", maxFeeLimit, - 1000000L, 100, null, testKeyForinternalTxsAddress, - internalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById : " + infoById); - byte[] contractAddress2 = infoById.get().getContractAddress().toByteArray(); - - String initParmes = "\"" + Base58.encode58Check(contractAddress1) - + "\",\"" + Base58.encode58Check(contractAddress2) + "\""; - - String txid2 = ""; - txid2 = PublicMethed.triggerContract(contractAddress, - "sendToB(address,address)", initParmes, false, - 0, maxFeeLimit, internalTxsAddress, testKeyForinternalTxsAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid2, blockingStubFull); - logger.info("infoById : " + infoById2); - - Assert.assertTrue(infoById2.get().getResultValue() == 0); - - - } - - private List getStrings(byte[] data) { - int index = 0; - List ret = new ArrayList<>(); - while (index < data.length) { - ret.add(byte2HexStr(data, index, 32)); - index += 32; - } - return ret; - } - - /** - * constructor. - */ - - public static String byte2HexStr(byte[] b, int offset, int length) { - String stmp = ""; - StringBuilder sb = new StringBuilder(""); - for (int n = offset; n < offset + length && n < b.length; n++) { - stmp = Integer.toHexString(b[n] & 0xFF); - sb.append((stmp.length() == 1) ? "0" + stmp : stmp); - } - return sb.toString().toUpperCase().trim(); - } - - /** - * constructor. - */ - - public byte[] subByte(byte[] b, int off, int length) { - byte[] b1 = new byte[length]; - System.arraycopy(b, off, b1, 0, length); - return b1; - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken079.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken079.java deleted file mode 100644 index 79d596385f1..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken079.java +++ /dev/null @@ -1,294 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken079 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Trigger transferToken with 0 tokenValue and tokenId") - public void triggerTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 70000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken079.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String tokenId = assetAccountId.toStringUtf8(); - long tokenValue = 100; - long callValue = 0; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, callValue, 0, 10000, - tokenId, tokenValue, null, dev001Key, - dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(100), Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(200), contractAssetCount); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(user001Address, - assetAccountId.toByteArray(), 10L, dev001Address, dev001Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - PublicMethed - .sendcoin(transferTokenContractAddress, 5000000, fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - tokenId = Long.toString(0); - tokenValue = 0; - callValue = 5; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "msgTokenValueAndTokenIdTest()", "#", false, callValue, - 1000000000L, tokenId, tokenValue, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional trsById = PublicMethed.getTransactionById(triggerTxid, blockingStubFull); - long feeLimit = trsById.get().getRawData().getFeeLimit(); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - if (triggerTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - logger.info("the value: " + PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray())); - - List retList = PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken080.java b/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken080.java deleted file mode 100644 index 31a550bf082..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/trctoken/ContractTrcToken080.java +++ /dev/null @@ -1,226 +0,0 @@ -package stest.tron.wallet.dailybuild.trctoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ContractTrcToken080 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static ByteString assetAccountId = null; - private static final long TotalSupply = 1000L; - private byte[] transferTokenContractAddress = null; - - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - } - - @Test(enabled = true, description = "DeployContract with 0 tokenValue and tokenId") - public void deployTransferTokenContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 1100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 130000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(dev001Address, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, 100000L, - 1L, 1L, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(dev001Address, blockingStubFull).getAssetIssuedID(); - logger.info("The token name: " + tokenName); - logger.info("The token ID: " + assetAccountId.toStringUtf8()); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountBefore = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - logger.info("before AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountBefore: " - + devAssetCountBefore); - - String filePath = "./src/test/resources/soliditycode/contractTrcToken080.sol"; - String contractName = "tokenTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - String tokenId = Long.toString(0); - long tokenValue = 0; - long callValue = 10; - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, - callValue, 0, 10000, tokenId, tokenValue, - null, dev001Key, dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (transferTokenTxid == null || infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - transferTokenContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(transferTokenContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - Long devAssetCountAfter = PublicMethed.getAssetIssueValue(dev001Address, - assetAccountId, blockingStubFull); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - logger.info("after AssetId: " + assetAccountId.toStringUtf8() + ", devAssetCountAfter: " - + devAssetCountAfter); - - Assert.assertTrue(PublicMethed.transferAsset(transferTokenContractAddress, - assetAccountId.toByteArray(), 100L, dev001Address, dev001Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long contractAssetCount = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("Contract has AssetId: " + assetAccountId.toStringUtf8() + ", Count: " - + contractAssetCount); - - Assert.assertEquals(Long.valueOf(tokenValue), - Long.valueOf(devAssetCountBefore - devAssetCountAfter)); - Assert.assertEquals(Long.valueOf(100L + tokenValue), contractAssetCount); - - // get and verify the msg.value and msg.id - Long transferAssetBefore = PublicMethed.getAssetIssueValue(transferTokenContractAddress, - assetAccountId, blockingStubFull); - logger.info("before trigger, transferTokenContractAddress has AssetId " - + assetAccountId.toStringUtf8() + ", Count is " + transferAssetBefore); - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "getResultInCon()", "#", false, 0, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - logger.info("The msg value: " + PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray())); - - List retList = PublicMethed.getStrings(infoById.get() - .getContractResult(0).toByteArray()); - - Long msgId = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - Long msgTokenValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - Long msgCallValue = ByteArray.toLong(ByteArray.fromHexString(retList.get(2))); - - logger.info("msgId: " + msgId); - logger.info("msgTokenValue: " + msgTokenValue); - logger.info("msgCallValue: " + msgCallValue); - - Assert.assertEquals(msgId.toString(), tokenId); - Assert.assertEquals(Long.valueOf(msgTokenValue), Long.valueOf(tokenValue)); - Assert.assertEquals(Long.valueOf(msgCallValue), Long.valueOf(callValue)); - - // unfreeze resource - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi001.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi001.java deleted file mode 100644 index 5ea098d7ab5..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi001.java +++ /dev/null @@ -1,311 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi001 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress1 = ecKey2.getAddress(); - String contractExcKey1 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress1, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Clear a contract created by other account") - public void testClearAbi001() { - String filePath = "src/test/resources/soliditycode/ClearAbi001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(contractAddress, contractExcAddress1, contractExcKey1, - blockingStubFull); - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("is not the owner of the contract")); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - - } - - - @Test(enabled = true, description = "Clear a contract with ABI created by itself") - public void testClearAbi002() { - - String contractName = "testConstantContract"; - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - String txid1 = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - } - - - @Test(enabled = true, description = "Clear a contract without ABI") - public void testClearAbi003() { - - String contractName = "testConstantContract"; - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - - } - - @Test(enabled = true, description = "Clear a account address") - public void testClearAbi004() { - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(contractExcAddress, contractExcAddress, contractExcKey, - blockingStubFull); - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - } - - - @Test(enabled = true, description = "Clear a uninitialized account") - public void testClearAbi005() { - - ECKey ecKeyN = new ECKey(Utils.getRandom()); - byte[] contractExcAddressN = ecKeyN.getAddress(); - String contractExcKeyN = ByteArray.toHexString(ecKeyN.getPrivKeyBytes()); - - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(contractExcAddressN, contractExcAddress, contractExcKey, - blockingStubFull); - Assert.assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert.assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - - } - - @Test(enabled = true, description = "Clear a not meet the rules address") - public void testClearAbi006() { - byte[] fakeAddress = "412B5D".getBytes(); - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(fakeAddress, contractExcAddress, contractExcKey, - blockingStubFull); - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - byte[] fakeAddress1 = "412B5D3405B2D26767C9C09886D53DEAFF6EB718AC111".getBytes(); - - TransactionExtention transactionExtention1 = PublicMethed - .clearContractAbiForExtention(fakeAddress1, contractExcAddress, contractExcKey, - blockingStubFull); - Assert - .assertThat(transactionExtention1.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention1.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi002.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi002.java deleted file mode 100644 index 90c661d8994..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi002.java +++ /dev/null @@ -1,160 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi002 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "Clear a contract with ABI created by itself") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi003.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi003.java deleted file mode 100644 index 88557f48b8a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi003.java +++ /dev/null @@ -1,159 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi003 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "Clear a contract without ABI") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi004.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi004.java deleted file mode 100644 index f0a064753be..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi004.java +++ /dev/null @@ -1,126 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi004 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "Clear a account address") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(contractExcAddress, contractExcAddress, contractExcKey, - blockingStubFull); - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi005.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi005.java deleted file mode 100644 index 5036eeb6cfd..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi005.java +++ /dev/null @@ -1,208 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi005 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Clear a contract created by create2 (without ABI)") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi005.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - SmartContract smartContract = PublicMethed.getContract(returnAddressBytes, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(returnAddressBytes, contractExcAddress, contractExcKey, - blockingStubFull); - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("is not the owner of the contract")); - - smartContract = PublicMethed.getContract(returnAddressBytes, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - } - - - /** - * testClearAbitestClearAbi constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi006.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi006.java deleted file mode 100644 index 7928fdd8269..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi006.java +++ /dev/null @@ -1,124 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi006 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress1 = ecKey2.getAddress(); - String contractExcKey1 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "Clear a uninitialized account") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(contractExcAddress1, contractExcAddress, contractExcKey, - blockingStubFull); - Assert.assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert.assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi007.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi007.java deleted file mode 100644 index a44383429a0..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi007.java +++ /dev/null @@ -1,139 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi007 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress1 = ecKey2.getAddress(); - String contractExcKey1 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "Clear a not meet the rules address") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - byte[] fakeAddress = "412B5D".getBytes(); - TransactionExtention transactionExtention = PublicMethed - .clearContractAbiForExtention(fakeAddress, contractExcAddress, contractExcKey, - blockingStubFull); - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - byte[] fakeAddress1 = "412B5D3405B2D26767C9C09886D53DEAFF6EB718AC111".getBytes(); - - TransactionExtention transactionExtention1 = PublicMethed - .clearContractAbiForExtention(fakeAddress1, contractExcAddress, contractExcKey, - blockingStubFull); - Assert - .assertThat(transactionExtention1.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention1.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : Contract not exists")); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi008.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi008.java deleted file mode 100644 index 0b4d16f24f2..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/clearabi/ClearAbi008.java +++ /dev/null @@ -1,173 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.clearabi; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ClearAbi008 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "Clear a contract with ABI created by itself," - + "clear a contract by itself again") - public void testClearAbi() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - String txid1 = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(infoById1.get().getResultValue() == 0); - - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test001.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test001.java deleted file mode 100644 index c02ca74691b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test001.java +++ /dev/null @@ -1,561 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private byte[] factoryContractAddress = null; - private byte[] factoryContractAddress2 = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy factory contract generated by new solidity") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Trigger create2 command with test bytecode using factory") - public void test02TriggerCreate2ToDeployTestContract() { - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - // different contract address with different bytecode, same salt and address - Assert.assertNotEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(testContractAddress)); - } - - @Test(enabled = true, description = "Trigger create2 command with factory bytecode") - public void test02TriggerCreate2ToDeployFactory2Contract() { - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - factoryContractAddress2 = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed - .getContract(factoryContractAddress2, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger create2 command with test bytecode using factory2") - public void test03TriggerCreate2ToDeployTestContract2() { - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress2, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("Not enough energy for 'SWAP1' operation executing")); - } - - @Test(enabled = true, description = "Trigger create2 command without meta data hash in bytecode") - public void test04TriggerCreate2ToDeployTestContract() { - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testContractCode = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801" - + "561002a57600080fd5b5060c9806100396000396000f3fe6080604052348015600f57600080fd5b50d38015" - + "601b57600080fd5b50d28015602757600080fd5b50600436106066577c01000000000000000000000000000" - + "00000000000000000000000000000600035046368e5c0668114606b578063e5aa3d58146083575b600080fd" - + "5b60716089565b60408051918252519081900360200190f35b60716097565b6000805460010190819055905" - + "65b6000548156fe"; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - String msgSender = Base58.encode58Check(ByteArray.fromHexString(retList.get(2))); - Assert.assertNotEquals(msgSender, Base58.encode58Check(user001Address)); - } - - @Test(enabled = true, description = "Trigger create2 command with 0 extended bytecode") - public void test05TriggerCreate2ToDeployTestContract() { - Long callValue = Long.valueOf(0); - - String testContractCode = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801" - + "561002a57600080fd5b5060c9806100396000396000f3fe6080604052348015600f57600080fd5b50d38015" - + "601b57600080fd5b50d28015602757600080fd5b50600436106066577c01000000000000000000000000000" - + "00000000000000000000000000000600035046368e5c0668114606b578063e5aa3d58146083575b600080fd" - + "5b60716089565b60408051918252519081900360200190f35b60716097565b6000805460010190819055905" - + "65b6000548156fe0000000000000000000000000000000000000000000000000000000000000000000000"; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - } - - @Test(enabled = true, description = "Trigger Test contact") - public void test04TriggerTestContract() { - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test002.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test002.java deleted file mode 100644 index c65c7c0b403..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test002.java +++ /dev/null @@ -1,324 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - //PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = false, description = "Trigger create2 command without meta data hash in bytecode") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Long callValue = Long.valueOf(0); - - String testContractCode = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801" - + "561002a57600080fd5b5060c9806100396000396000f3fe6080604052348015600f57600080fd5b50d38015" - + "601b57600080fd5b50d28015602757600080fd5b50600436106066577c01000000000000000000000000000" - + "00000000000000000000000000000600035046368e5c0668114606b578063e5aa3d58146083575b600080fd" - + "5b60716089565b60408051918252519081900360200190f35b60716097565b6000805460010190819055905" - + "65b6000548156fe"; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - String msgSender = Base58.encode58Check(ByteArray.fromHexString(retList.get(2))); - Assert.assertNotEquals(msgSender, Base58.encode58Check(user001Address)); - } - - - @Test(enabled = false, description = "Trigger Test contract") - public void test03TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test003.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test003.java deleted file mode 100644 index 6dd83d4f52f..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test003.java +++ /dev/null @@ -1,489 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Trigger create2 command with invalid bytecode") - public void test02TriggerCreate2WithInvalidBytecode() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testContractCode = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801" - + "561002a57600080fd5b5060c9806100396000396000f5fe6080604052348015600f57600080fd5b50d38015" - + "601b57600080fd5b50d28015602757600080fd5b50600436106066577c01000000000000000000000000000" - + "00000000000000000000000000000600035046368e5c0668114606b578063e5aa3d58146083575b600080fd" - + "5b60716089565b60408051918252519081900360200190f35b60716097565b6000805460010190819055905" - + "65b6000548156fea165627a7a72305820f3e3c0646a8c8d521fe819f10a592327469f611f0d9e8206697f7f" - + "3436ff3c7d0029"; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("Not enough energy for 'SWAP1' operation executing")); - } - - @Test(enabled = true, description = "Trigger create2 command with empty bytecode") - public void test03TriggerCreate2WithEmptyBytecode() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testContractCode = ""; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("REVERT opcode executed")); - } - - @Test(enabled = true, description = "Trigger create2 command with \"6080\" bytecode") - public void test04TriggerCreate2WithShortBytecode() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testContractCode = "6080"; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("REVERT opcode executed")); - } - - @Test(enabled = true, description = "Trigger create2 command with \"00000000000\" bytecode") - public void test05TriggerCreate2WithZeroBytecode() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testContractCode = "000000000000000000000000000000"; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("REVERT opcode executed")); - } - - @Test(enabled = true, description = "Trigger create2 command with NULL bytecode") - public void test06TriggerCreate2WithNullBytecode() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testContractCode = null; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - boolean ret = false; - - try { - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - } catch (org.spongycastle.util.encoders.DecoderException e) { - logger.info("Expected org.spongycastle.util.encoders.DecoderException!"); - ret = true; - } - Assert.assertTrue(ret); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test004.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test004.java deleted file mode 100644 index 1b6760f3669..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test004.java +++ /dev/null @@ -1,471 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] factoryContractAddress2 = null; - private byte[] testContractAddress = null; - private byte[] testContractAddress2 = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - /*AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore));*/ - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - /*accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter));*/ - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Trigger create2 command with factory bytecode") - public void test02TriggerCreate2ToDeployFactory2Contract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 150000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - /*AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore));*/ - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - /*accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter));*/ - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - factoryContractAddress2 = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed - .getContract(factoryContractAddress2, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - - @Test(enabled = false, description = "Trigger create2 command with test bytecode using factory") - public void test03TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 80000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - /*AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore));*/ - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - /*accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter));*/ - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - // different contract address with different bytecode, same salt and address - Assert.assertNotEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(testContractAddress)); - } - - @Test(enabled = false, description = "Trigger create2 command with test bytecode using factory2") - public void test04TriggerCreate2ToDeployTestContract2() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 80000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - /*AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore));*/ - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress2, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - /*accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter));*/ - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("Not enough energy for 'SWAP1' operation executing")); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test005.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test005.java deleted file mode 100644 index 2c3069120cc..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test005.java +++ /dev/null @@ -1,358 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = false, description = "Trigger create2 command with 0 extended bytecode") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testContractCode = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801" - + "561002a57600080fd5b5060c9806100396000396000f3fe6080604052348015600f57600080fd5b50d38015" - + "601b57600080fd5b50d28015602757600080fd5b50600436106066577c01000000000000000000000000000" - + "00000000000000000000000000000600035046368e5c0668114606b578063e5aa3d58146083575b600080fd" - + "5b60716089565b60408051918252519081900360200190f35b60716097565b6000805460010190819055905" - + "65b6000548156fe0000000000000000000000000000000000000000000000000000000000000000000000"; - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = false, description = "Trigger test contract") - public void test03TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test006.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test006.java deleted file mode 100644 index c892288ad24..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test006.java +++ /dev/null @@ -1,1013 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Trigger create2 with salt empty") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - String param = "\"" + testContractCode + "\"," + null; - boolean ret = false; - try { - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - @Test(enabled = true, description = "Trigger create2 with salt 0") - public void test03TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 0L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(salt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger create2 with salt -1") - public void test04TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = -1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(salt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger create2 with salt 100") - public void test05TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 100L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(salt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger create2 with salt f * 64") - public void test06TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - String saltHexString = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; - logger.info("saltHexString: " + saltHexString); - - String param = "\"" + testContractCode + "\",\"" + saltHexString + "\""; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,bytes32)", param, false, callValue, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - // The first - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("addressHex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("addressFinal: " + addressFinal); - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - String actualSalt = retList.get(1); - logger.info("actualSalt: " + actualSalt); - - byte[] tmpSenderAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(2)), 12, tmpSenderAddress, 0, 20); - String senderAddressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("senderAddressHex: " + senderAddressHex); - String senderAddressFinal = Base58.encode58Check(ByteArray.fromHexString(senderAddressHex)); - logger.info("senderAddressFinal: " + senderAddressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(saltHexString, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger create2 with salt efffe") - public void test07TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - final String saltHexString = "EFFFE"; - final String expectedSalt = "0EFFFE0000000000000000000000000000000000000000000000000000000000"; - - logger.info("saltHexString: " + saltHexString); - - String param = "\"" + testContractCode + "\",\"" + saltHexString + "\""; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,bytes32)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - // The first - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("addressHex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("addressFinal: " + addressFinal); - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - String actualSalt = retList.get(1); - logger.info("actualSalt: " + actualSalt); - - byte[] tmpSenderAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(2)), 12, tmpSenderAddress, 0, 20); - String senderAddressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("senderAddressHex: " + senderAddressHex); - String senderAddressFinal = Base58.encode58Check(ByteArray.fromHexString(senderAddressHex)); - logger.info("senderAddressFinal: " + senderAddressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(expectedSalt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger create2 with salt affffa") - public void test08TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - final String saltHexString = "AFFFFA"; - final String expectedSalt = "AFFFFA0000000000000000000000000000000000000000000000000000000000"; - logger.info("saltHexString: " + saltHexString); - - String param = "\"" + testContractCode + "\",\"" + saltHexString + "\""; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,bytes32)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - // The first - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("addressHex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("addressFinal: " + addressFinal); - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - String actualSalt = retList.get(1); - logger.info("actualSalt: " + actualSalt); - - byte[] tmpSenderAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(2)), 12, tmpSenderAddress, 0, 20); - String senderAddressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("senderAddressHex: " + senderAddressHex); - String senderAddressFinal = Base58.encode58Check(ByteArray.fromHexString(senderAddressHex)); - logger.info("senderAddressFinal: " + senderAddressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(expectedSalt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - @Test(enabled = true, description = "Trigger test contract") - public void test09TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test007.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test007.java deleted file mode 100644 index f4ab1ea698f..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test007.java +++ /dev/null @@ -1,358 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Trigger create2 with salt -1") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = -1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(salt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = false, description = "Trigger test contract") - public void test03TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test008.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test008.java deleted file mode 100644 index 3bd45115367..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test008.java +++ /dev/null @@ -1,358 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test008 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Trigger create2 with salt 100") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 100L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(salt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = false, description = "Trigger test contract") - public void test03TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test009.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test009.java deleted file mode 100644 index cda26f9439e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test009.java +++ /dev/null @@ -1,365 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract generated by new solidity") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = false, description = "Trigger create2 function to deploy test contract") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - String[] parameter = {Base58.encode58Check(user001Address), testContractCode, salt.toString()}; - logger.info(PublicMethed.create2(parameter)); - - Assert.assertEquals(Base58.encode58Check(testContractAddress), PublicMethed.create2(parameter)); - - } - - - @Test(enabled = false, description = "Trigger Test contact") - public void test03TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test010.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test010.java deleted file mode 100644 index df968624a91..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test010.java +++ /dev/null @@ -1,210 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test010 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "TransferToken with correct value, deploy transfer contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = false, description = "Trigger create2 with salt empty") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - String param = "\"" + testContractCode + "\"," + null; - boolean ret = false; - try { - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - } catch (NullPointerException e) { - logger.info("Expected NullPointerException!"); - ret = true; - } - Assert.assertTrue(ret); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test011.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test011.java deleted file mode 100644 index d41603ce140..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test011.java +++ /dev/null @@ -1,369 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "FactoryBytes"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = false, description = "Trigger create2 with salt f * 64") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - String saltHexString = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; - logger.info("saltHexString: " + saltHexString); - - String param = "\"" + testContractCode + "\",\"" + saltHexString + "\""; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,bytes32)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - // The first - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("addressHex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("addressFinal: " + addressFinal); - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - String actualSalt = retList.get(1); - logger.info("actualSalt: " + actualSalt); - - byte[] tmpSenderAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(2)), 12, tmpSenderAddress, 0, 20); - String senderAddressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("senderAddressHex: " + senderAddressHex); - String senderAddressFinal = Base58.encode58Check(ByteArray.fromHexString(senderAddressHex)); - logger.info("senderAddressFinal: " + senderAddressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(saltHexString, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - - @Test(enabled = false, description = "Trigger test contract") - public void test03TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test012.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test012.java deleted file mode 100644 index 0d33efa7f04..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test012.java +++ /dev/null @@ -1,396 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test012 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - private byte[] testContractAddress2 = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = false, description = "Trigger create2 command with test bytecode and salt 1") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 80000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(salt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - - @Test(enabled = false, description = "Trigger create2 command with test bytecode and salt 2") - public void test03TriggerCreate2ToDeployTestContract2() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 80000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 2L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress2 = WalletClient.decodeFromBase58Check(addressFinal); - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(salt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - // contract address are different with different salt - Assert.assertNotEquals(Base58.encode58Check(testContractAddress), - Base58.encode58Check(testContractAddress2)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test013.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test013.java deleted file mode 100644 index 82d6c405ca8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test013.java +++ /dev/null @@ -1,436 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test013 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Trigger factory contract to deploy test contract") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = false, description = "Trigger factory contract to deploy test contract again " - + "with same code, salt and address") - public void test03TriggerCreate2ToDeployTestContractAgain() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("Not enough energy for 'SWAP1' operation executing")); - } - - @Test(enabled = false, description = "Trigger test1 contract") - public void test04TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test014.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test014.java deleted file mode 100644 index 974f0e4321c..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test014.java +++ /dev/null @@ -1,638 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test014 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - private byte[] testContractAddress2 = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = true, description = "Trigger factory contract with Test " - + "bytecode and salt using user account") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger factory contract to deploy test contract again " - + "with same code, salt and address") - public void test02TriggerCreate2ToDeployTestContractAgain() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert - .assertThat(infoById.get().getResMessage().toStringUtf8(), - containsString("Not enough energy for 'SWAP1' operation executing")); - } - - @Test(enabled = true, description = "Same code, salt and address," - + " create contract using develop account") - public void test03TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, dev001Address, dev001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress2 = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress2, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - // contract address are different - Assert.assertNotEquals(Base58.encode58Check(testContractAddress), - Base58.encode58Check(testContractAddress2)); - } - - @Test(enabled = true, description = "Trigger test1 contract") - public void test04TriggerTest1Contract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - } - - @Test(enabled = true, description = "Trigger test2 contract") - public void test05TriggerTest2Contract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress2, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test015.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test015.java deleted file mode 100644 index 65259f1bc09..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test015.java +++ /dev/null @@ -1,500 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test015 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] callerContractAddress = null; - private byte[] callContractAddress = null; - private byte[] delegateCallContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy caller contract") - public void test01DeployCallerContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2CallContract.sol"; - String contractName = "callerContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - callerContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(callerContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test02DeployFactoryContract() { - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Trigger callCreate2 function in caller contract " - + "with factory contract address") - public void test03TriggerCreate2ToDeployTestContract() { - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + Base58.encode58Check(factoryContractAddress) - + "\",\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(callerContractAddress, - "callCreate2(address,bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), - 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - callContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(callContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // call type make the caller contract to be the owner of - // test contract (the contract address in transaction info) - Assert.assertEquals(Base58.encode58Check(callerContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger delegateCallCreate2 function in caller contract " - + "with factory contract address") - public void test04TriggerCreate2ToDeployTestContract() { - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + Base58.encode58Check(factoryContractAddress) - + "\",\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(callerContractAddress, - "delegateCallCreate2(address,bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - delegateCallContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed - .getContract(delegateCallContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // delegatecall type make the caller contract to be the owner of test contract (contract info) - Assert.assertEquals(Base58.encode58Check(callerContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // call type make the caller contract to be the owner of test contract - // (the contract address in transaction info) - Assert.assertEquals(Base58.encode58Check(callerContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Trigger test contract") - public void test09TriggerTestContract() { - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(callContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test016.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test016.java deleted file mode 100644 index d4b45711d72..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test016.java +++ /dev/null @@ -1,422 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test016 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] callerContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy caller contract") - public void test01DeployCallerContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2CallContract.sol"; - String contractName = "callerContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - callerContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(callerContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test02DeployFactoryContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Trigger delegateCallCreate2 function in caller contract " - + "with factory contract address") - public void test03TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - Long salt = 1L; - - String param = "\"" + Base58.encode58Check(factoryContractAddress) - + "\",\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(callerContractAddress, - "delegateCallCreate2(address,bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // delegatecall type make the caller contract to be the owner of test contract (contract info) - Assert.assertEquals(Base58.encode58Check(callerContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // call type make the caller contract to be the owner of test contract - // (the contract address in transaction info) - Assert.assertEquals(Base58.encode58Check(callerContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = false, description = "Trigger test contract") - public void test04TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test017.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test017.java deleted file mode 100644 index 872dc4ebbc9..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test017.java +++ /dev/null @@ -1,405 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test017 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "FactoryBytes"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Trigger create2 with salt efffe") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - final String saltHexString = "EFFFE"; - final String expectedSalt = "0EFFFE0000000000000000000000000000000000000000000000000000000000"; - - logger.info("saltHexString: " + saltHexString); - - String param = "\"" + testContractCode + "\",\"" + saltHexString + "\""; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,bytes32)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - // The first - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("addressHex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("addressFinal: " + addressFinal); - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - String actualSalt = retList.get(1); - logger.info("actualSalt: " + actualSalt); - - byte[] tmpSenderAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(2)), 12, tmpSenderAddress, 0, 20); - String senderAddressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("senderAddressHex: " + senderAddressHex); - String senderAddressFinal = Base58.encode58Check(ByteArray.fromHexString(senderAddressHex)); - logger.info("senderAddressFinal: " + senderAddressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(expectedSalt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = false, description = "Trigger create2 with salt affffa") - public void test03TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - - final String saltHexString = "AFFFFA"; - final String expectedSalt = "AFFFFA0000000000000000000000000000000000000000000000000000000000"; - logger.info("saltHexString: " + saltHexString); - - String param = "\"" + testContractCode + "\",\"" + saltHexString + "\""; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,bytes32)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - // The first - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("addressHex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("addressFinal: " + addressFinal); - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - String actualSalt = retList.get(1); - logger.info("actualSalt: " + actualSalt); - - byte[] tmpSenderAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(2)), 12, tmpSenderAddress, 0, 20); - String senderAddressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("senderAddressHex: " + senderAddressHex); - String senderAddressFinal = Base58.encode58Check(ByteArray.fromHexString(senderAddressHex)); - logger.info("senderAddressFinal: " + senderAddressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - Assert.assertEquals(expectedSalt, actualSalt); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test018.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test018.java deleted file mode 100644 index c0a0096ae0e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test018.java +++ /dev/null @@ -1,360 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test018 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - private byte[] witnessAddress001 = PublicMethed.getFinalAddress(witnessKey001); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(witnessKey001); - } - - @Test(enabled = false, description = "Deploy factory contract generated by new solidity") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(witnessAddress001, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = false, description = "Trigger create2 function to deploy test contract " - + "using Witness account") - public void test02TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 9000_000_000_000L, 0, 1, - ByteString.copyFrom(witnessAddress001), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(witnessAddress001, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(witnessAddress001, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = new Random().nextLong(); - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, witnessAddress001, witnessKey001, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(witnessAddress001, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(witnessAddress001, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - - @Test(enabled = false, description = "Trigger Test contact") - public void test03TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(witnessAddress001, witnessKey001, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(witnessAddress001), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(witnessAddress001, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(witnessAddress001, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - final String triggerTxid = PublicMethed.triggerContract(testContractAddress, - "plusOne()", "#", false, callValue, - 1000000000L, "0", 0, witnessAddress001, witnessKey001, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(witnessAddress001, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(witnessAddress001, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - Long ret = ByteArray.toLong(ByteArray.fromHexString(retList.get(0))); - - logger.info("ret: " + ret); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " + infoById.get().getResMessage()); - } - - SmartContract smartContract = PublicMethed.getContract(infoById.get().getContractAddress() - .toByteArray(), blockingStubFull); - - long consumeUserPercent = smartContract.getConsumeUserResourcePercent(); - logger.info("ConsumeURPercent: " + consumeUserPercent); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - witnessAddress001, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - witnessAddress001, blockingStubFull); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test019.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test019.java deleted file mode 100644 index cce3d710083..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test019.java +++ /dev/null @@ -1,309 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; -import static org.tron.protos.Protocol.Transaction.Result.contractResult.SUCCESS_VALUE; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test019 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "seted Value of Contract that created by create2," - + " should not be stored after contact suicided ande create2 again") - public void testTriggerContract() { - String sendcoin = PublicMethed - .sendcoinGetTransactionId(contractExcAddress, 1000000000L, testNetAccountAddress, - testNetAccountKey, - blockingStubFull); - - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById0 = null; - infoById0 = PublicMethed.getTransactionInfoById(sendcoin, blockingStubFull); - logger.info("infoById0 " + infoById0.get()); - Assert.assertEquals(ByteArray.toHexString(infoById0.get().getContractResult(0).toByteArray()), - ""); - Assert.assertEquals(infoById0.get().getResult().getNumber(), 0); - Optional ById = PublicMethed.getTransactionById(sendcoin, blockingStubFull); - Assert.assertEquals(ById.get().getRet(0).getContractRet().getNumber(), - SUCCESS_VALUE); - Assert.assertEquals(ById.get().getRet(0).getContractRetValue(), SUCCESS_VALUE); - Assert.assertEquals(ById.get().getRet(0).getContractRet(), contractResult.SUCCESS); - String filePath = "src/test/resources/soliditycode/create2contractn2.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "set()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(5 == returnnumber); - - String param1 = "\"" + Base58.encode58Check(returnAddressBytes) + "\""; - - txid = PublicMethed - .triggerContract(returnAddressBytes, - "testSuicideNonexistentTarget(address)", param1, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById2 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - - Assert.assertEquals("suicide", ByteArray - .toStr(infoById2.get().getInternalTransactions(0).getNote().toByteArray())); - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_VALIDATE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("contract validate error : No contract or not a smart contract")); - - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById3 = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - byte[] returnAddressBytes1 = infoById3.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress1 = Base58.encode58Check(returnAddressBytes1); - Assert.assertEquals(returnAddress1, returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes1, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test020.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test020.java deleted file mode 100644 index 849177628fe..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test020.java +++ /dev/null @@ -1,913 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test020 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Deploy Factory contract, create2 with salt type : trcToken") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/create2contract22.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1000001; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,trcToken)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - } - - - @Test(enabled = true, description = "Deploy Factory contract, create2 with salt type : uint8") - public void testTriggerContract1() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - String filePath = "src/test/resources/soliditycode/create2contract22.sol"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1000001; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy1(bytes,uint8)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - - @Test(enabled = true, description = "Deploy Factory contract, create2 with salt type : address") - public void testTriggerContract2() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - String filePath = "src/test/resources/soliditycode/create2contract22.sol"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + ",\"" + Base58.encode58Check(contractExcAddress) + "\""; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy2(bytes,address)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - - @Test(enabled = true, description = "Deploy Factory contract, create2 with salt type : string") - public void testTriggerContract3() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - String filePath = "src/test/resources/soliditycode/create2contract22.sol"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + ",\"" + Base58.encode58Check(contractExcAddress) + "\""; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy3(bytes,string)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - - @Test(enabled = true, description = "TriggerContract a constant function created by create2") - public void testTriggerContract4() { - Account info; - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract1"; - String filePath = "src/test/resources/soliditycode/create2contract22.sol"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + ",\"" + Base58.encode58Check(contractAddress) + "\""; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy3(bytes,string)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(2 == returnnumber); - - txid = PublicMethed - .triggerContract(contractAddress, - "deploy3(bytes,string)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - Assert.assertTrue(infoById2.get().getResultValue() != 0); - Assert - .assertThat(ByteArray - .toStr(infoById2.get().getResMessage().toByteArray()), - containsString("Not enough energy")); - } - - - @Test(enabled = true, description = "TriggerContract a constant function created by create2") - public void testTriggerContract5() { - - Account info; - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract2"; - String filePath = "src/test/resources/soliditycode/create2contract22.sol"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + ",\"" + Base58.encode58Check(contractAddress) + "\""; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy3(bytes,string)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(3 == returnnumber); - num = "\"" + code1 + "\"" + ",\"" + Base58.encode58Check(testNetAccountAddress) + "\""; - - txid = PublicMethed - .triggerContract(contractAddress, - "deploy3(bytes,string)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - Assert.assertTrue(infoById2.get().getResultValue() != 0); - Assert - .assertThat(ByteArray - .toStr(infoById2.get().getResMessage().toByteArray()), - containsString("Not enough energy")); - } - - - @Test(enabled = true, description = "TriggerContract a constant function created by create2") - public void testTriggerContract6() { - - Account info; - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract3"; - String filePath = "src/test/resources/soliditycode/create2contract22.sol"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + ",\"" + Base58.encode58Check(contractAddress) + "\""; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy3(bytes,string)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(4 == returnnumber); - String fakeAddress = "FFFFFFF"; - - num = "\"" + code1 + "\"" + ",\"" + fakeAddress + "\""; - - txid = PublicMethed - .triggerContract(contractAddress, - "deploy3(bytes,string)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById2 = null; - infoById2 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - Assert.assertTrue(infoById2.get().getResultValue() != 0); - Assert - .assertThat(ByteArray - .toStr(infoById2.get().getResMessage().toByteArray()), - containsString("Not enough energy")); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test021.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test021.java deleted file mode 100644 index 52e5a104f02..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test021.java +++ /dev/null @@ -1,381 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test021 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] contractExcAddress = PublicMethed - .getFinalAddress("9fc9b78370cdeab1bc11ba5e387e5e4f205f17d1957b1bebf4ce6d0330a448a4"); - private String contractExcKey = - "9fc9b78370cdeab1bc11ba5e387e5e4f205f17d1957b1bebf4ce6d0330a448a4"; - byte[] bytes; - private static final long now = System.currentTimeMillis(); - private static final String name = "Asset008_" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - ByteString assetAccountId = null; - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] resourceOnwerAddress = ecKey2.getAddress(); - String resourceOnwerKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - PublicMethed.printAddress(resourceOnwerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - } - - @Test(enabled = true, description = "TriggerContract a constant function created by create2") - public void test1TriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .sendcoin(resourceOnwerAddress, 1000000000L + 1024000000L, testNetAccountAddress, - testNetAccountKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Create 3 the same name token. - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(resourceOnwerAddress, - name, totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, resourceOnwerKey, blockingStubFull)); - String filePath = "src/test/resources/soliditycode/create2contractn.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - bytes = ByteArray.fromHexString("416CED4D6BF0AE10676347961BEFB7F47A8664AE36"); - - String param2 = "\"" + Base58.encode58Check(contractExcAddress) + "\""; - String txidn = PublicMethed - .triggerContract(bytes, - "testSuicideNonexistentTarget(address)", param2, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(bytes, 1000000L, contractExcAddress, contractExcKey, blockingStubFull)); - //Trigger contract to transfer trx and token. - Account getAssetIdFromAccount = PublicMethed - .queryAccount(resourceOnwerAddress, blockingStubFull); - assetAccountId = getAssetIdFromAccount.getAssetIssuedID(); - Long contractBeforeBalance = PublicMethed.queryAccount(bytes, blockingStubFull).getBalance(); - - Assert.assertTrue( - PublicMethed.transferAsset(bytes, assetAccountId.toByteArray(), 100, resourceOnwerAddress, - resourceOnwerKey, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account account1 = PublicMethed.queryAccount(bytes, blockingStubFull); - int typeValue1 = account1.getTypeValue(); - Assert.assertEquals(0, typeValue1); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(resourceOnwerAddress, 1000000L, 0, 0, - ByteString.copyFrom(bytes), resourceOnwerKey, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(resourceOnwerAddress, 1000000L, 0, 1, - ByteString.copyFrom(bytes), resourceOnwerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - final Long beforeExcAccountBalance = PublicMethed - .queryAccount(resourceOnwerAddress, blockingStubFull).getBalance(); - Assert.assertTrue(PublicMethed.getAccountResource(bytes, blockingStubFull).getNetLimit() > 0); - Assert - .assertTrue(PublicMethed.getAccountResource(bytes, blockingStubFull).getEnergyLimit() > 0); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = "6080604052600160005534801561001557600080fd5b50d3801561002257600080fd5b50" - + "d2801561002f57600080fd5b506101fd8061003f6000396000f3fe60806040526004361061005b577" - + "c01000000000000000000000000000000000000000000000000000000006000350463040821fc8114" - + "61006057806317b6ad5b1461007f578063cc133e94146100b2578063e5aa3d58146100d5575b60008" - + "0fd5b61007d6004803603602081101561007657600080fd5b5035610116565b005b61007d60048036" - + "03602081101561009557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610" - + "147565b61007d600480360360408110156100c857600080fd5b5080359060200135610160565b3480" - + "156100e157600080fd5b50d380156100ee57600080fd5b50d280156100fb57600080fd5b506101046" - + "101cb565b60408051918252519081900360200190f35b604051339082156108fc0290839060008181" - + "81858888f19350505050158015610143573d6000803e3d6000fd5b5050565b8073fffffffffffffff" - + "fffffffffffffffffffffffff16ff5b3382156108fc0283838015801561017657600080fd5b508067" - + "80000000000000001115801561018e57600080fd5b5080620f4240101580156101a157600080fd5b5" - + "0604051600081818185878a8ad09450505050501580156101c6573d6000803e3d6000fd5b50505056" - + "5b6000548156fea165627a7a72305820485b773c60fed3b76621350dd3da7ecf152a2d37ca02dc195" - + "d6f8a26aec196850029"; - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertFalse(PublicMethed.freezeBalanceForReceiver(resourceOnwerAddress, 5000000L, 0, 0, - ByteString.copyFrom(bytes), resourceOnwerKey, blockingStubFull)); - Assert.assertFalse(PublicMethed.freezeBalanceForReceiver(resourceOnwerAddress, 5000000L, 0, 1, - ByteString.copyFrom(bytes), resourceOnwerKey, blockingStubFull)); - Long afterExcAccountBalance = PublicMethed.queryAccount(resourceOnwerAddress, blockingStubFull) - .getBalance(); - Assert.assertTrue(PublicMethed.getAccountResource(bytes, blockingStubFull).getNetLimit() == 0); - Assert - .assertTrue(PublicMethed.getAccountResource(bytes, blockingStubFull).getEnergyLimit() == 0); - logger.info("afterExcAccountBalance: " + afterExcAccountBalance); - logger.info("beforeExcAccountBalance:" + beforeExcAccountBalance); - - Assert.assertTrue(afterExcAccountBalance - beforeExcAccountBalance == 0); - - Assert.assertTrue(PublicMethed.unFreezeBalance(resourceOnwerAddress, resourceOnwerKey, - 0, bytes, blockingStubFull)); - Assert.assertTrue(PublicMethed.unFreezeBalance(resourceOnwerAddress, resourceOnwerKey, - 1, bytes, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long afterUnfreezeBalance = PublicMethed.queryAccount(resourceOnwerAddress, blockingStubFull) - .getBalance(); - Assert.assertTrue(afterUnfreezeBalance == beforeExcAccountBalance + 1000000L * 2); - - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - Assert.assertEquals(Base58.encode58Check(bytes), returnAddress); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "i()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - Account account = PublicMethed.queryAccount(returnAddressBytes, blockingStubFull); - int typeValue = account.getTypeValue(); - Assert.assertEquals(2, typeValue); - Assert.assertEquals(account.getBalance(), 1000000); - } - - @Test(enabled = true, description = "Create2 contract can transfer trx and token.") - public void test2TriggerContract() { - Account accountbefore = PublicMethed.queryAccount(bytes, blockingStubFull); - int typeValue = accountbefore.getTypeValue(); - Assert.assertEquals(2, typeValue); - long accountbeforeBalance = accountbefore.getBalance(); - Assert.assertEquals(accountbeforeBalance, 1000000); - Account contractExcAddressbefore = PublicMethed - .queryAccount(contractExcAddress, blockingStubFull); - long contractExcAddressbeforeBalance = contractExcAddressbefore.getBalance(); - - String num = "1"; - - String txid = PublicMethed - .triggerContract(bytes, - "testTransfer(uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional transactionInfoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(transactionInfoById.get().getResultValue() == 0); - Long fee1 = transactionInfoById.get().getFee(); - - Account accountafter = PublicMethed.queryAccount(bytes, blockingStubFull); - long accountafterBalance = accountafter.getBalance(); - Assert.assertTrue(accountbeforeBalance - 1 == accountafterBalance); - - Account contractExcAddressafter = PublicMethed - .queryAccount(contractExcAddress, blockingStubFull); - long contractExcAddressafterBalance = contractExcAddressafter.getBalance(); - Assert.assertTrue(contractExcAddressbeforeBalance + 1 - fee1 == contractExcAddressafterBalance); - - num = "1" + ",\"" + assetAccountId.toStringUtf8() + "\""; - Long returnAddressBytesAccountCountBefore = PublicMethed - .getAssetIssueValue(bytes, assetAccountId, blockingStubFull); - Long contractExcAddressAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - String txid1 = PublicMethed - .triggerContract(bytes, - "testTransferToken(uint256,trcToken)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - Optional transactionInfoById1 = PublicMethed - .getTransactionInfoById(txid1, blockingStubFull); - Assert.assertTrue(transactionInfoById1.get().getResultValue() == 0); - Long returnAddressBytesAccountCountAfter = PublicMethed - .getAssetIssueValue(bytes, assetAccountId, blockingStubFull); - - Long contractExcAddressAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Assert.assertTrue( - returnAddressBytesAccountCountBefore - 1 == returnAddressBytesAccountCountAfter); - Assert.assertTrue( - contractExcAddressAccountCountBefore + 1 == contractExcAddressAccountCountAfter); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test023.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test023.java deleted file mode 100644 index 99f313b910d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test023.java +++ /dev/null @@ -1,292 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test023 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - - public byte[] subByte(byte[] b, int off, int length) { - byte[] b1 = new byte[length]; - System.arraycopy(b, off, b1, 0, length); - return b1; - - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/Create2Test023.sol"; - String contractName = "factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "contract A new B contract,A suicide,contract B still exist") - public void test02TriggerTestContract() { - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "testCreate()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - - byte[] a = infoById.get().getContractResult(0).toByteArray(); - byte[] b = subByte(a, 11, 1); - byte[] c = subByte(a, 0, 11); - byte[] e = "41".getBytes(); - byte[] d = subByte(a, 12, 20); - - logger.info("a:" + ByteArray.toHexString(a)); - - logger.info("b:" + ByteArray.toHexString(b)); - logger.info("c:" + ByteArray.toHexString(c)); - - logger.info("d:" + ByteArray.toHexString(d)); - - logger.info("41" + ByteArray.toHexString(d)); - String exceptedResult = "41" + ByteArray.toHexString(d); - String realResult = ByteArray.toHexString(b); - Assert.assertEquals(realResult, "00"); - Assert.assertNotEquals(realResult, "41"); - - - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(exceptedResult)); - logger.info("B Address : " + addressFinal); - - //B Address is created by A, Trigger contract B - triggerTxid = PublicMethed.triggerContract(ByteArray.fromHexString(exceptedResult), - "test()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertEquals(infoById.get().getResultValue(),0); - Assert.assertEquals(ByteArray.toLong(infoById.get().getContractResult(0).toByteArray()),1); - Assert.assertEquals("SUCESS",infoById.get().getResult().toString()); - - - triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "kill()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - String note = ByteArray - .toStr(infoById.get().getInternalTransactions(0).getNote().toByteArray()); - - Assert.assertEquals(infoById.get().getResultValue(),0); - Assert.assertEquals("SUCESS",infoById.get().getResult().toString()); - Assert.assertEquals("suicide", note); - - - - triggerTxid = PublicMethed.triggerContract(ByteArray.fromHexString(exceptedResult), - "test()", "#", false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - Assert.assertEquals(infoById.get().getResultValue(),0); - Assert.assertEquals("SUCESS",infoById.get().getResult().toString()); - Assert.assertEquals(1,ByteArray.toInt(infoById.get().getContractResult(0).toByteArray())); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test024.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test024.java deleted file mode 100644 index 307960819a3..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test024.java +++ /dev/null @@ -1,277 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Create2Test024 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - - public byte[] subByte(byte[] b, int off, int length) { - byte[] b1 = new byte[length]; - System.arraycopy(b, off, b1, 0, length); - return b1; - - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/Create2Test024.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "create2 not allowed create2 twice in function") - public void test02TriggerTestContract() { - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/Create2Test024.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 4L; - - String param = "\"" + testContractCode + "\"," + salt; - - String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - byte[] a = infoById.get().getContractResult(0).toByteArray(); - byte[] b = subByte(a, 11, 1); - byte[] c = subByte(a, 0, 11); - byte[] e = "41".getBytes(); - byte[] d = subByte(a, 12, 20); - - logger.info("a:" + ByteArray.toHexString(a)); - - logger.info("b:" + ByteArray.toHexString(b)); - logger.info("c:" + ByteArray.toHexString(c)); - - logger.info("d:" + ByteArray.toHexString(d)); - - logger.info("41" + ByteArray.toHexString(d)); - String exceptedResult = "41" + ByteArray.toHexString(d); - String realResult = ByteArray.toHexString(b); - Assert.assertEquals(realResult, "00"); - Assert.assertNotEquals(realResult, "41"); - - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(exceptedResult)); - logger.info("create2 Address : " + addressFinal); - - Assert.assertEquals(infoById.get().getResult().toString(), "SUCESS"); - Assert.assertEquals(infoById.get().getResultValue(), 0); - - triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy2(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - devEnergyLimitAfter = accountResource.getEnergyLimit(); - devEnergyUsageAfter = accountResource.getEnergyUsed(); - devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - userEnergyLimitAfter = accountResource.getEnergyLimit(); - userEnergyUsageAfter = accountResource.getEnergyUsed(); - userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - Assert.assertEquals(infoById.get().getResultValue(), 1); - Assert.assertEquals(infoById.get().getResult().toString(), "FAILED"); - Assert.assertThat(ByteArray.toStr(infoById.get().getResMessage().toByteArray()), - containsString("Not enough energy for 'SWAP1' operation executing: ")); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test025.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test025.java deleted file mode 100644 index e63db5de9ef..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/create2/Create2Test025.java +++ /dev/null @@ -1,272 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.create2; - -import static org.hamcrest.core.StringContains.containsString; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import zmq.socket.pubsub.Pub; - -@Slf4j -public class Create2Test025 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] testContractAddress = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = false, description = "Deploy factory contract") - public void test01DeployFactoryContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/Create2Test025.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - code += "05"; - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "create2 bytecode with parm") - public void test02TriggerTestContract() { - //Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - // PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - // blockingStubFull), 0, 1, - // ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - String filePath = "./src/test/resources/soliditycode/Create2Test025.sol"; - String contractName = "TestContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - testContractCode += "0000000000000000000000000000000000000000000000000000000000000005"; - Long salt = 4L; - - String param = "\"" + testContractCode + "\"," + salt; - - String triggerTxid = null; - triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "create2(bytes,uint256)", param, false, 0L, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - - String txid = PublicMethed.triggerContract(testContractAddress, - "getNum()", "#", false, 0L, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - Optional infoById2 = PublicMethed.getTransactionInfoById(txid, - blockingStubFull); - TransactionInfo transactionInfo2 = infoById2.get(); - final int Num = ByteArray.toInt(transactionInfo2.getContractResult(0).toByteArray()); - - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - userEnergyLimitAfter = accountResource.getEnergyLimit(); - userEnergyUsageAfter = accountResource.getEnergyUsed(); - userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - logger.info("NUM :" + Num); - Assert.assertEquals(infoById.get().getResult().toString(),"SUCESS"); - Assert.assertEquals(infoById.get().getResultValue(),0); - Assert.assertEquals(5,Num); - - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest001.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest001.java deleted file mode 100644 index 60ec980a7fb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest001.java +++ /dev/null @@ -1,689 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - private String testContractAddress2 = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - private byte[] testAddress = ecKey3.getAddress(); - private String testKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - expectedCodeHash = ByteArray.toHexString(Hash.sha3(Hex.decode(code))); - logger.info("expectedCodeHash: " + expectedCodeHash); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = false, description = "Get the extcodehash of a normal address") - public void test02GetNormalAddressCodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(dev001Address) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("transaction failed with message: " - + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - - Assert.assertEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - - } - - @Test(enabled = true, description = "Get a contract extcodehash") - public void test03GetContactCodeHash() { - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(extCodeHashContractAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertNotEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - Assert.assertNotEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - @Test(enabled = true, description = "Get a not exist account extcodehash") - public void test04GetNotExistAddressCodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - } - - @Test(enabled = true, description = "Active the account and get extcodehash again") - public void test05ActiveAccountGetCodeHash() { - - Assert.assertTrue(PublicMethed.sendcoin(testAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - - } - - @Test(enabled = true, description = "Get a not deployed create2 extcodehash") - public void test06GetCreate2CodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - final String abi = retMap.get("abI").toString(); - - Long salt = 100L; - String[] parameter = {Base58.encode58Check(user001Address), code, salt.toString()}; - logger.info(PublicMethed.create2(parameter)); - testContractAddress2 = PublicMethed.create2(parameter); - - Long callValue = Long.valueOf(0); - - String param = "\"" - + Base58.encode58Check(WalletClient.decodeFromBase58Check(testContractAddress2)) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - /*PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull);*/ - } - - @Test(enabled = true, description = "Get the EXTCODEHASH of an account created " - + "in the current transaction") - public void test07DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHashConstruct.sol"; - String contractName = "CounterConstruct"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getTopics(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertNotEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - Assert.assertNotEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest002.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest002.java deleted file mode 100644 index eb3c733a7f1..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest002.java +++ /dev/null @@ -1,246 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.junit.runners.AllTests; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest002 { - private final boolean AllTest = false; - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = AllTest, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = AllTest, description = "Get a contract extcodehash") - public void test02GetContactCodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(extCodeHashContractAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertNotEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - Assert.assertNotEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest003.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest003.java deleted file mode 100644 index 3135f1d6fbc..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest003.java +++ /dev/null @@ -1,336 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest003 { - - private final boolean AllTest = false; - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - private byte[] testAddress = ecKey3.getAddress(); - private String testKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = AllTest, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = AllTest, description = "Get a not exist account extcodehash") - public void test02GetNotExistAddressCodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - } - - @Test(enabled = AllTest, description = "Active the account and get extcodehash again") - public void test03ActiveAccountGetCodeHash() { - - Assert.assertTrue(PublicMethed.sendcoin(testAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest004.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest004.java deleted file mode 100644 index eb60051b1fb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest004.java +++ /dev/null @@ -1,255 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest004 { - - private final boolean AllTest = false; - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private String testContractAddress = null; - - private String expectedCodeHash = null; - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = AllTest, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - final String abi = retMap.get("abI").toString(); - - expectedCodeHash = ByteArray.toHexString(Hash.sha3(Hex.decode(code))); - logger.info("expectedCodeHash: " + expectedCodeHash); - - Long salt = 100L; - String[] parameter = {Base58.encode58Check(user001Address), code, salt.toString()}; - logger.info(PublicMethed.create2(parameter)); - testContractAddress = PublicMethed.create2(parameter); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = AllTest, description = "Get a not deployed create2 extcodehash") - public void test02GetCreate2CodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = - "\"" + Base58.encode58Check(WalletClient.decodeFromBase58Check(testContractAddress)) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest005.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest005.java deleted file mode 100644 index 15edc1d6140..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest005.java +++ /dev/null @@ -1,716 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.runtime.vm.DataWord; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String contractCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - private byte[] testAddress = ecKey3.getAddress(); - private String testKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - - String fakeAddress = ""; - - logger.info("realAddress: " + fakeAddress); - byte[] fullHexAddr = new DataWord(fakeAddress).getData(); - logger.info("fullHexAddr ++= " + Hex.toHexString(fullHexAddr)); - - fakeAddress = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; - - logger.info("realAddress: " + fakeAddress); - fullHexAddr = new DataWord(fakeAddress).getData(); - logger.info("fullHexAddr ++= " + Hex.toHexString(fullHexAddr)); - - } - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Get codehash of a real contract by uint") - public void test02GetContractCodeHash() { - - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String testAddress = ByteArray.toHexString(extCodeHashContractAddress); - logger.info("realAddress: " + testAddress); - byte[] fullHexAddr = new DataWord(testAddress).getData(); - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByUint(uint256)", Hex.toHexString(fullHexAddr), true, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertNotEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - Assert.assertNotEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - contractCodeHash = retList.get(0); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - } - - @Test(enabled = true, description = "Get codehash of a fake address by uint") - public void test03GetInvalidAddressCodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String fakeAddress = "41660757B2543F4849D3F42B90F58DE1C14C7E0038"; - logger.info("realAddress: " + fakeAddress); - byte[] fullHexAddr = new DataWord(fakeAddress).getData(); - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByUint(uint256)", Hex.toHexString(fullHexAddr), true, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - } - - @Test(enabled = true, description = "Get codehash of a normal account by uint") - public void test04GetNormalAddressCodeHash() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String fakeAddress = ByteArray.toHexString(user001Address); - logger.info("realAddress: " + fakeAddress); - byte[] fullHexAddr = new DataWord(fakeAddress).getData(); - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByUint(uint256)", Hex.toHexString(fullHexAddr), true, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - Assert.assertFalse(retList.isEmpty()); - - Assert.assertEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - } - - @Test(enabled = true, description = "Get codehash of a empty address by uint") - public void test05GetEmptyAddressCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String fakeAddress = ""; - - logger.info("realAddress: " + fakeAddress); - byte[] fullHexAddr = new DataWord(fakeAddress).getData(); - logger.info("fullHexAddr ++= " + Hex.toHexString(fullHexAddr)); - - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByUint(uint256)", Hex.toHexString(fullHexAddr), true, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - Assert.assertFalse(retList.isEmpty()); - - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - } - - @Test(enabled = true, description = "Get codehash of a fffffff*64 address by uint") - public void test06GetFakeAddressCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String fakeAddress = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; - - logger.info("realAddress: " + fakeAddress); - byte[] fullHexAddr = new DataWord(fakeAddress).getData(); - logger.info("fullHexAddr ++= " + Hex.toHexString(fullHexAddr)); - - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByUint(uint256)", Hex.toHexString(fullHexAddr), true, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - Assert.assertFalse(retList.isEmpty()); - - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - } - - @Test(enabled = true, description = "Get codehash of a real contract plus 2**160 by uint") - public void test07GetContractAddress96CodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - BigInteger bigIntAddr = new DataWord(extCodeHashContractAddress).sValue(); - String bigIntAddrChange = BigInteger.valueOf(2).pow(160).add(bigIntAddr).toString(16); - byte[] fullHexAddr = new DataWord(bigIntAddrChange).getData(); - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByUint(uint256)", Hex.toHexString(fullHexAddr), true, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - Assert.assertFalse(retList.isEmpty()); - - // expect the code hash same - Assert.assertEquals(contractCodeHash, retList.get(0)); - - SmartContract smartContract = PublicMethed - .getContract(extCodeHashContractAddress, blockingStubFull); - logger.info(smartContract.getBytecode().toStringUtf8()); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest006.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest006.java deleted file mode 100644 index de1a2b185fc..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest006.java +++ /dev/null @@ -1,184 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest006 { - private final boolean AllTest = false; - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - private byte[] testAddress = ecKey3.getAddress(); - private String testKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = AllTest, description = "Get the EXTCODEHASH of an account created " - + "in the current transaction") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHashConstruct.sol"; - String contractName = "CounterConstruct"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getTopics(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertNotEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - Assert.assertNotEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest007.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest007.java deleted file mode 100644 index 336744f4dee..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest007.java +++ /dev/null @@ -1,616 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] testAddressOld = null; - private byte[] testAddressNew = null; - private byte[] testAddress2 = null; - private byte[] extCodeHashContractAddress = null; - - private String expectedCodeHash = null; - private String expectedCodeHashOld = null; - - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy testNoPayable contract using old solidity") - public void test01DeployTestContractOld() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String contractName = "testExtHashContract"; - String code = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a576000" - + "80fd5b5060ef806100396000396000f30060806040526004361060485763ffffffff7c010000000000000000" - + "0000000000000000000000000000000000000000600035041663c518aa0f8114604d578063e5aa3d58146089" - + "575b600080fd5b348015605857600080fd5b50d38015606457600080fd5b50d28015607057600080fd5b5060" - + "7760b3565b60408051918252519081900360200190f35b348015609457600080fd5b50d3801560a057600080" - + "fd5b50d2801560ac57600080fd5b50607760bd565b6001600081905590565b600054815600a165627a7a7230" - + "5820766b4e2fca9081689cd89419411d2cbc5588a17a5c9fa900fd9cfe4b0d9652be0029"; - String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"testNoPayable\"," - + "\"outputs\":[{\"name\":\"z\",\"type\":\"uint256\"}],\"payable\":false," - + "\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true," - + "\"inputs\":[],\"name\":\"i\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}]," - + "\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]"; - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - testAddressOld = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(testAddressOld, - blockingStubFull); - } - - @Test(enabled = true, description = "Deploy testNoPayable contract using new solidity") - public void test02DeployTestContractNew() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String contractName = "testConstantContract"; - String code = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a5760" - + "0080fd5b5060c5806100396000396000f3fe6080604052348015600f57600080fd5b50d38015601b576000" - + "80fd5b50d28015602757600080fd5b50600436106066577c01000000000000000000000000000000000000" - + "000000000000000000006000350463c518aa0f8114606b578063e5aa3d58146083575b600080fd5b607160" - + "89565b60408051918252519081900360200190f35b60716093565b6001600081905590565b6000548156fe" - + "a165627a7a723058205c5aadfbd06ea264db7b73e7b7f3c36ac64a9d520ba46b4bc7f1dc56252f17ac0029"; - String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"testNoPayable\",\"outputs\":[{\"" - + "name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable" - + "\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"i\",\"outputs\":" - + "[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"" - + "type\":\"function\"}]"; - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - testAddressNew = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(testAddressNew, - blockingStubFull); - } - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test03DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - } - - @Test(enabled = true, description = "Get contract code hash with old solidity") - public void test04GetTestOldCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddressOld) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - - expectedCodeHashOld = retList.get(0); - Assert.assertEquals( - "B4AB5B9FF1A4FF7793E60EBFF0C769443AF66D0A6F9455AF145432CE8BA78175",expectedCodeHashOld); - Assert.assertFalse(retList.isEmpty()); - } - - @Test(enabled = true, description = "Get contract code hash with new solidity") - public void test05GetTestNewCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddressNew) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - Assert.assertFalse(retList.isEmpty()); - - Assert.assertNotEquals(retList.get(0), expectedCodeHashOld); - expectedCodeHash = retList.get(0); - Assert.assertEquals( - "34DB53BD1F7214367E8D6B2A7A6FBBF0E3B7DDB4939ECADE4CDEF6749C27A2DA",expectedCodeHash); - } - - @Test(enabled = true, description = "Deploy contract using new solidity again") - public void test06DeployTest2Contract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String contractName = "testConstantContract"; - String code = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a5760" - + "0080fd5b5060c5806100396000396000f3fe6080604052348015600f57600080fd5b50d38015601b576000" - + "80fd5b50d28015602757600080fd5b50600436106066577c01000000000000000000000000000000000000" - + "000000000000000000006000350463c518aa0f8114606b578063e5aa3d58146083575b600080fd5b607160" - + "89565b60408051918252519081900360200190f35b60716093565b6001600081905590565b6000548156fe" - + "a165627a7a723058205c5aadfbd06ea264db7b73e7b7f3c36ac64a9d520ba46b4bc7f1dc56252f17ac0029"; - String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"testNoPayable\",\"outputs\":[{\"" - + "name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable" - + "\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"i\",\"outputs\":" - + "[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"" - + "type\":\"function\"}]"; - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - testAddress2 = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(testAddress2, - blockingStubFull); - } - - @Test(enabled = true, description = "Get contract code hash with test2") - public void test07GetTest2CodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddress2) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - Assert.assertFalse(retList.isEmpty()); - - Assert.assertEquals(expectedCodeHash, retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest008.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest008.java deleted file mode 100644 index 6ef73cdfb29..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest008.java +++ /dev/null @@ -1,512 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest008 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - } - - @Test(enabled = true, description = "Get code hash of create2 empty contract") - public void test02GetTestContractCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String[] parameter = {Base58.encode58Check(user001Address), testContractCode, salt.toString()}; - logger.info(PublicMethed.create2(parameter)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + PublicMethed.create2(parameter) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test03DeployFactoryContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Trigger create2 function to deploy test contract") - public void test04TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Get code hash of test contract") - public void test05GetTestContractCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testContractAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertNotEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - Assert.assertNotEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest009.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest009.java deleted file mode 100644 index 963ab54a07a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest009.java +++ /dev/null @@ -1,512 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash.sol"; - String contractName = "TestExtCodeHash"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - } - - @Test(enabled = true, description = "Get code hash of create2 empty contract") - public void test02GetTestContractCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String[] parameter = {Base58.encode58Check(user001Address), testContractCode, salt.toString()}; - logger.info(PublicMethed.create2(parameter)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + PublicMethed.create2(parameter) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - } - - @Test(enabled = true, description = "Deploy factory contract") - public void test03DeployFactoryContract() { - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(dev001Address, dev001Key, 170000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, 10_000_000L, - 0, 0, ByteString.copyFrom(dev001Address), testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - factoryContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(factoryContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - @Test(enabled = true, description = "Trigger create2 function to deploy test contract") - public void test04TriggerCreate2ToDeployTestContract() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String filePath = "./src/test/resources/soliditycode/create2contract.sol"; - String contractName = "TestConstract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - final String triggerTxid = PublicMethed.triggerContract(factoryContractAddress, - "deploy(bytes,uint256)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger.info( - "the value: " + PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray())); - - List retList = PublicMethed - .getStrings(transactionInfo.getLogList().get(0).getData().toByteArray()); - - Long actualSalt = ByteArray.toLong(ByteArray.fromHexString(retList.get(1))); - - logger.info("actualSalt: " + actualSalt); - - byte[] tmpAddress = new byte[20]; - System.arraycopy(ByteArray.fromHexString(retList.get(0)), 12, tmpAddress, 0, 20); - String addressHex = "41" + ByteArray.toHexString(tmpAddress); - logger.info("address_hex: " + addressHex); - String addressFinal = Base58.encode58Check(ByteArray.fromHexString(addressHex)); - logger.info("address_final: " + addressFinal); - - testContractAddress = WalletClient.decodeFromBase58Check(addressFinal); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - SmartContract smartContract = PublicMethed.getContract(testContractAddress, blockingStubFull); - - // contract created by create2, doesn't have ABI - Assert.assertEquals(0, smartContract.getAbi().getEntrysCount()); - - // the contract owner of contract created by create2 is the factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(smartContract.getOriginAddress().toByteArray())); - - // the contract address in transaction info, - // contract address of create2 contract is factory contract - Assert.assertEquals(Base58.encode58Check(factoryContractAddress), - Base58.encode58Check(infoById.get().getContractAddress().toByteArray())); - } - - @Test(enabled = true, description = "Get code hash of test contract") - public void test05GetTestContractCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testContractAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", param, false, callValue, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertNotEquals("C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470", - retList.get(0)); - Assert.assertNotEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - dev001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - user001Address, blockingStubFull); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest010.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest010.java deleted file mode 100644 index dc32ba60c46..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest010.java +++ /dev/null @@ -1,379 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest010 { - - final boolean AllTest = false; - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] factoryContractAddress = null; - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = AllTest, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/ExtCodeHashTest010.sol"; - String contractName = "Counter"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage()); - } - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - } - - - @Test(enabled = AllTest, description = "The EXTCODEHASH of an account that selfdestructed in the " - + "current transaction. but later been revert") - public void test02GetTestContractCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashRevert()", "#", false, 0L, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - } - - - @Test(enabled = AllTest, description = "The EXTCODEHASH of an account that create in the current " - + "transaction. but later been revert") - public void test03GetTestContractCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashCreate()", "#", false, 0L, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - } - - @Test(enabled = AllTest, description = "The EXTCODEHASH of an account that selfdestructed in the" - + " current transaction.") - public void test04GetTestContractCodeHash() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long devEnergyLimitBefore = accountResource.getEnergyLimit(); - long devEnergyUsageBefore = accountResource.getEnergyUsed(); - long devBalanceBefore = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("before trigger, devEnergyLimitBefore is " + Long.toString(devEnergyLimitBefore)); - logger.info("before trigger, devEnergyUsageBefore is " + Long.toString(devEnergyUsageBefore)); - logger.info("before trigger, devBalanceBefore is " + Long.toString(devBalanceBefore)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitBefore = accountResource.getEnergyLimit(); - long userEnergyUsageBefore = accountResource.getEnergyUsed(); - long userBalanceBefore = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("before trigger, userEnergyLimitBefore is " + Long.toString(userEnergyLimitBefore)); - logger.info("before trigger, userEnergyUsageBefore is " + Long.toString(userEnergyUsageBefore)); - logger.info("before trigger, userBalanceBefore is " + Long.toString(userBalanceBefore)); - - - String param = "\"" + Base58.encode58Check(extCodeHashContractAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashSuicide(address)", param, false, 0L, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - long devEnergyLimitAfter = accountResource.getEnergyLimit(); - long devEnergyUsageAfter = accountResource.getEnergyUsed(); - long devBalanceAfter = PublicMethed.queryAccount(dev001Address, blockingStubFull).getBalance(); - - logger.info("after trigger, devEnergyLimitAfter is " + Long.toString(devEnergyLimitAfter)); - logger.info("after trigger, devEnergyUsageAfter is " + Long.toString(devEnergyUsageAfter)); - logger.info("after trigger, devBalanceAfter is " + Long.toString(devBalanceAfter)); - - accountResource = PublicMethed.getAccountResource(user001Address, blockingStubFull); - long userEnergyLimitAfter = accountResource.getEnergyLimit(); - long userEnergyUsageAfter = accountResource.getEnergyUsed(); - long userBalanceAfter = PublicMethed.queryAccount(user001Address, blockingStubFull) - .getBalance(); - - logger.info("after trigger, userEnergyLimitAfter is " + Long.toString(userEnergyLimitAfter)); - logger.info("after trigger, userEnergyUsageAfter is " + Long.toString(userEnergyUsageAfter)); - logger.info("after trigger, userBalanceAfter is " + Long.toString(userBalanceAfter)); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info("the value: " + retList); - - Assert.assertFalse(retList.isEmpty()); - Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000000", - retList.get(0)); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest011.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest011.java deleted file mode 100644 index 28c5fe7bde5..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/extCodeHash/ExtCodeHashTest011.java +++ /dev/null @@ -1,369 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.extCodeHash; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.crypto.Hash; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashTest011 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private byte[] testContractAddress = null; - - private String expectedCodeHash = null; - - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - private byte[] dev001Address = ecKey1.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash11.sol"; - String contractName = "Counter"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - expectedCodeHash = ByteArray.toHexString(Hash.sha3(Hex.decode(code))); - logger.info("expectedCodeHash: " + expectedCodeHash); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - transferTokenTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr()", "#", false, 0, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - Assert.assertTrue(infoById.get().getResultValue() != 0); - Assert - .assertThat(ByteArray - .toStr(infoById.get().getResMessage().toByteArray()), - containsString("REVERT opcode executed")); - } - - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract1() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash11.sol"; - String contractName = "Counter1"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - expectedCodeHash = ByteArray.toHexString(Hash.sha3(Hex.decode(code))); - logger.info("expectedCodeHash: " + expectedCodeHash); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - transferTokenTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr()", "#", false, 0, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - - Assert.assertEquals(retList.get(1), - retList.get(0)); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract2() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash11.sol"; - String contractName = "Counter2"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - expectedCodeHash = ByteArray.toHexString(Hash.sha3(Hex.decode(code))); - logger.info("expectedCodeHash: " + expectedCodeHash); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - String num = "\"" + Base58.encode58Check(dev001Address) + "\""; - - transferTokenTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", num, false, 0, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - Assert.assertEquals(retList.get(1), - retList.get(0)); - } - - - @Test(enabled = true, description = "Deploy extcodehash contract") - public void test01DeployExtCodeHashContract3() { - Assert.assertTrue(PublicMethed.sendcoin(dev001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHash11.sol"; - String contractName = "Counter2"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - expectedCodeHash = ByteArray.toHexString(Hash.sha3(Hex.decode(code))); - logger.info("expectedCodeHash: " + expectedCodeHash); - - String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - extCodeHashContractAddress = infoById.get().getContractAddress().toByteArray(); - - accountResource = PublicMethed.getAccountResource(dev001Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - energyUsage = accountResource.getEnergyUsed(); - long balanceAfter = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - - logger.info("after energyLimit is " + Long.toString(energyLimit)); - logger.info("after energyUsage is " + Long.toString(energyUsage)); - logger.info("after balanceAfter is " + Long.toString(balanceAfter)); - - String num = "\"" + Base58.encode58Check(dev001Address) + "\""; - - transferTokenTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "getCodeHashByAddr(address)", num, false, 0, - 1000000000L, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - List retList = PublicMethed - .getStrings(transactionInfo.getContractResult(0).toByteArray()); - - logger.info( - "the value: " + retList); - Assert.assertEquals(retList.get(1), - retList.get(0)); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand001.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand001.java deleted file mode 100644 index 5362d481943..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand001.java +++ /dev/null @@ -1,264 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.shiftcommand; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ShiftCommand001 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test(enabled = true, description = "Trigger old ShiftLeft ShiftRight") - public void test1OldInstruction() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TvmOldCommand001.sol"; - String contractName = "binaryRightContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1"; - txid = PublicMethed.triggerContract(contractAddress, - "binaryMoveR(int256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - txid = PublicMethed.triggerContract(contractAddress, - "binaryLiftR(int256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - - } - - @Test(enabled = true, description = "Trigger new ShiftLeft ShiftRight ShiftRightSigned") - public void test2NewInstruction() { - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1" + "," + "5"; - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertEquals(10,ByteArray.toInt(infoById.get().getContractResult(0).toByteArray())); - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertEquals(2,ByteArray.toInt(infoById.get().getContractResult(0).toByteArray())); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand002.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand002.java deleted file mode 100644 index eac053fb372..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand002.java +++ /dev/null @@ -1,281 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.shiftcommand; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ShiftCommand002 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test(enabled = true, description = "OLd compiler compile shift instruction") - public void test1Oldcompile() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - String contractName = "TestBitwiseShift"; - String code = "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a5" - + "7600080fd5b506101478061003a6000396000f3006080604052600436106100565763ffffffff7c0100" - + "000000000000000000000000000000000000000000000000000000600035041663614eb4da811461005" - + "b578063b5675d6d146100a2578063baf27c0c146100d7575b600080fd5b34801561006757600080fd5b" - + "50d3801561007457600080fd5b50d2801561008157600080fd5b5061009060043560243561010c565b6" - + "0408051918252519081900360200190f35b3480156100ae57600080fd5b50d380156100bb57600080fd" - + "5b50d280156100c857600080fd5b50610090600435602435610111565b3480156100e357600080fd5b5" - + "0d380156100f057600080fd5b50d280156100fd57600080fd5b50610090600435602435610116565b90" - + "1b90565b901d90565b901c905600a165627a7a723058200d5cc53ffdc6db62c4d7414d8b7d95c98218e" - + "50b4c1ea5961d527de1439733450029"; - String abi = "[{\"constant\":false,\"inputs\":[{\"name\":\"num\",\"type\":\"uint256\"}," - + "{\"name\":\"input\",\"type\":\"uint256\"}],\"name\":\"shlTest\",\"outputs\":" - + "[{\"name\":\"out\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":" - + "\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":" - + "\"num\",\"type\":\"uint256\"},{\"name\":\"input\",\"type\":\"uint256\"}],\"name" - + "\":\"sarTest\",\"outputs\":[{\"name\":\"out\",\"type\":\"bytes32\"}],\"payable" - + "\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant" - + "\":false,\"inputs\":[{\"name\":\"num\",\"type\":\"uint256\"},{\"name\":\"input\"" - + ",\"type\":\"uint256\"}],\"name\":\"shrTest\",\"outputs\":[{\"name\":\"out\",\"" - + "type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"" - + "type\":\"function\"}]"; - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1" + "," + "5"; - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - } - - @Test(enabled = true, description = "New compiler compile shift instruction") - public void test2Newcompile() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1" + "," + "5"; - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand003.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand003.java deleted file mode 100644 index 87e08eed76e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand003.java +++ /dev/null @@ -1,343 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.shiftcommand; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.DataWord; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ShiftCommand003 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft with displacement number too short ") - public void test1ShiftLeft() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - logger.info("param:" + param); - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRight with displacement number too short ") - public void test2ShiftRight() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - logger.info("param:" + param); - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("00007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRightSigned " - + "with displacement number too short ") - public void test3ShiftRightSigned() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - logger.info("param:" + param); - String txid = ""; - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("00007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand004.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand004.java deleted file mode 100644 index 49a16cfbae5..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand004.java +++ /dev/null @@ -1,1051 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.shiftcommand; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.DataWord; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ShiftCommand004 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x00") - public void test1ShiftLeft() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x00")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x01") - public void test2ShiftLeft() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0x01")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000002")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0xff") - public void test3ShiftLeft() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0xff")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x0100") - public void test4ShiftLeft() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0100")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x0101") - public void test5ShiftLeft() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0101")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x00") - public void test6ShiftLeft() { - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x00")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x01") - public void test7ShiftLeft() { - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0xff") - public void test8ShiftLeft() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0xff")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0100") - public void test9ShiftLeft() { - - Account info; - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0100")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x01") - public void testShiftLeft10() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x01") - public void testShiftLeft11() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftLeft,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0101") - public void testShiftLeft12() { - - String filePath = "src/test/resources/soliditycode/TvmNewCommand043.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0101")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shlTest(int256,int256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand005.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand005.java deleted file mode 100644 index 33291d18812..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand005.java +++ /dev/null @@ -1,1060 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.shiftcommand; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.DataWord; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ShiftCommand005 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x00") - public void test1ShiftRight() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x00")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x01") - public void test2ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x01") - public void test3ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - String originNumber = String.valueOf(ByteArray.toLong(ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000"))); - String valueNumber = String.valueOf(ByteArray.toLong((ByteArray - .fromHexString("0x01")))); - String num = valueNumber + "," + originNumber; - - logger.info("returnnumber:" + originNumber); - logger.info("returnnumber1:" + valueNumber); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x4000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0xff") - public void test4ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0xff")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x0100") - public void test5ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0100")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x0101") - public void test6ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0101")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x00") - public void test7ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x00")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x01") - public void test8ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0xff") - public void test9ShiftRight() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0xff")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0100") - public void testShiftRight10() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0100")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x01") - public void testShiftRight11() { - - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRight,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0101") - public void testShiftRight12() { - - String filePath = "src/test/resources/soliditycode/TvmNewCommand043.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0101")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "shrTest(int256,int256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand006.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand006.java deleted file mode 100644 index 80258809be0..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/shiftcommand/ShiftCommand006.java +++ /dev/null @@ -1,1549 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.shiftcommand; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.DataWord; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ShiftCommand006 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x00") - public void test1ShiftRightSigned() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - String filePath = "src/test/resources/soliditycode/ShiftCommand001.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x00")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000001 and Displacement number" - + "is 0x01") - public void test2ShiftRightSigned() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x01") - public void test3ShiftRightSigned() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x01")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xc000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0xff") - public void test4ShiftRightSigned() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0xff")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x0100") - public void test5ShiftRightSigned() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0100")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x8000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x0101") - public void test6ShiftRightSigned() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x8000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0101")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x00") - public void test7ShiftRightSigned() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0x00")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x01") - public void test8ShiftRightSigned() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0x01")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0xff") - public void test9ShiftRightSigned() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0xff")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0100") - public void testShiftRightSigned10() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0x0100")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x0000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0x01") - public void testShiftRightSigned11() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0x01")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x4000000000000000000000000000000000000000000000000000000000000000 and Displacement number" - + "is 0xfe") - public void testShiftRightSigned12() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x4000000000000000000000000000000000000000000000000000000000000000")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0xfe")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0xf8") - public void testShiftRightSigned13() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0xf8")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x000000000000000000000000000000000000000000000000000000000000007f")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0xfe") - public void testShiftRightSigned14() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0xfe")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0xff") - public void testShiftRightSigned15() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0xff")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0100") - public void testShiftRightSigned16() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0100")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(uint256,uint256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0101") - public void testShiftRightSigned17() { - - String filePath = "src/test/resources/soliditycode/TvmNewCommand043.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray - .fromHexString("0x0101")) - .getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - String param = Hex.toHexString(paramBytes); - - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(int256,int256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber14 = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - @Test(enabled = true, description = "Trigger new ShiftRightSigned,value is " - + "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and Displacement number" - + "is 0x0101") - public void testShiftRightSigned18() { - - String filePath = "src/test/resources/soliditycode/TvmNewCommand043.sol"; - String contractName = "TestBitwiseShift"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - byte[] originNumber = new DataWord( - ByteArray - .fromHexString("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) - .getData(); - byte[] valueNumber = new DataWord( - ByteArray.fromHexString("0x0101")).getData(); - byte[] paramBytes = new byte[originNumber.length + valueNumber.length]; - System.arraycopy(valueNumber, 0, paramBytes, 0, valueNumber.length); - System.arraycopy(originNumber, 0, paramBytes, valueNumber.length, originNumber.length); - - String param = Hex.toHexString(paramBytes); - txid = PublicMethed.triggerContract(contractAddress, - "sarTest(int256,int256)", param, true, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - String returnString = (ByteArray - .toHexString(infoById.get().getContractResult(0).toByteArray())); - logger.info("returnString:" + returnString); - Assert.assertEquals(ByteArray.toLong(ByteArray - .fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000")), - ByteArray.toLong(ByteArray - .fromHexString( - ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())))); - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TestResourceReceiver.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TestResourceReceiver.java deleted file mode 100644 index 697e8b22c02..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TestResourceReceiver.java +++ /dev/null @@ -1,200 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TestResourceReceiver { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test(enabled = false, description = "Suicide existent Target") - public void test1SuicideExistentTarget() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TransferFailed001.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 3000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(testNetAccountAddress, - 1000000, 0, 1, - ByteString.copyFrom(contractAddress), testNetAccountKey, blockingStubFull)); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] existentAddress = ecKey2.getAddress(); - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - String num = "\"" + Base58.encode58Check(contractAddress) + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testSuicideNonexistentTarget(address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Account contractafter = PublicMethed.queryAccount(contractAddress, blockingStubFull1); - long contractBalance = contractafter.getBalance(); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertEquals(contractBalance, 0); - txid = PublicMethed.triggerContract(contractAddress, - "testSuicideNonexistentTarget(address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Assert.assertNull(txid); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - PublicMethed.unFreezeBalance(testNetAccountAddress, testNetAccountKey, 1, - contractAddress, blockingStubFull); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed001.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed001.java deleted file mode 100644 index 007fced4680..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed001.java +++ /dev/null @@ -1,832 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import static org.tron.protos.Protocol.TransactionInfo.code.FAILED; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TransferFailed001 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Transfer trx insufficient balance") - public void test1TransferTrxInsufficientBalance() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - String filePath = "src/test/resources/soliditycode/TransferFailed001.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1"; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTrxInsufficientBalance(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("infoById:" + infoById); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "REVERT opcode executed", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "Transfer balance enough") - public void test2TransferEnough() { - - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 3000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1"; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTrxInsufficientBalance(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - logger.info("infoById" + infoById); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee - 1 == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - - } - - - @Test(enabled = true, description = "Transfer trx nonexistent target") - public void test3TransferTrxNonexistentTarget() { - - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - String txid = ""; - String num = "1" + ",\"" + Base58.encode58Check(nonexistentAddress) + "\""; - - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTrxNonexistentTarget(uint256,address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer trx failed: Validate InternalTransfer error, no ToAccount." - + " And not allowed to create account in smart contract.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "Transfer trx to myself") - public void test4TransferTrxSelf() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1"; - - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTrxSelf(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer trx failed: Cannot transfer trx to yourself.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "Transfer trx nonexistent target and insufficient balance") - public void test5TransferTrxNonexistentTarget() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - String txid = ""; - String num = "10000000" + ",\"" + Base58.encode58Check(nonexistentAddress) + "\""; - - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTrxNonexistentTarget(uint256,address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull1); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "REVERT opcode executed", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "Transfer trx to myself and insufficient balance") - public void test6TransferTrxSelf() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - String txid = ""; - String num = "1000000000"; - - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTrxSelf(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "REVERT opcode executed", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - @Test(enabled = true, description = "PreCompiled transfertoken with value," - + " long.max < value or long.min > value") - public void test7TransferTrckenPreCompiled() { - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Account info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String txid = ""; - String num = "1"; - - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenCompiledLongMax1()", "#", false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - beforeBalance = info.getBalance(); - beforeEnergyUsed = resourceInfo.getEnergyUsed(); - beforeNetUsed = resourceInfo.getNetUsed(); - beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertTrue(energyUsageTotal < maxFeeLimit / 10); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenCompiledLongMin1()", "#", false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - fee = infoById.get().getFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - beforeBalance = info.getBalance(); - beforeEnergyUsed = resourceInfo.getEnergyUsed(); - beforeNetUsed = resourceInfo.getNetUsed(); - beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertEquals(FAILED, infoById.get().getResult()); - Assert.assertTrue(energyUsageTotal < maxFeeLimit / 10); - Assert.assertEquals("REVERT opcode executed", infoById.get().getResMessage().toStringUtf8()); - - } - - @Test(enabled = false, description = "PreCompiled tokenbalance") - public void test8TransferTrctoken() { - - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000_000_000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ByteString assetAccountId = null; - final long TotalSupply = 10000000L; - long now = System.currentTimeMillis(); - String tokenName = "testAssetIssue_" + Long.toString(now); - - //Create a new AssetIssue success. - Assert - .assertTrue(PublicMethed.createAssetIssue(contractExcAddress, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, contractExcKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(contractExcAddress, blockingStubFull) - .getAssetIssuedID(); - - String filePath = "src/test/resources/soliditycode/TransferFailed001.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.transferAsset(contractAddress, - assetAccountId.toByteArray(), 100L, contractExcAddress, contractExcKey, - blockingStubFull)); - - Long returnAddressBytesAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("returnAddressBytesAccountCountBefore : " + returnAddressBytesAccountCountBefore); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - String num = - "\"" + Base58.encode58Check(contractAddress) + "\"," + "\"" + assetAccountId.toStringUtf8() - + "\""; - //String num = "\""+Base58.encode58Check(contractAddress) +"\","+ "\"" + -1 + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenTest(address,uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(energyUsageTotal < maxFeeLimit / 10); - Assert.assertEquals(100, ByteArray.toInt(infoById.get().getContractResult(0).toByteArray())); - - - } - - @Test(enabled = true, description = "PreCompiled address(0x1) query tokenbalance") - public void test9TransferTrctoken() { - //address: 410000000000000000000000000000000000000001 - String addressx = "T9yD14Nj9j7xAB4dbGeiX9h8unkKLxmGkn"; - byte[] addressxx = WalletClient.decodeFromBase58Check(addressx); - - Assert.assertTrue(PublicMethed - .sendcoin(addressxx, 1000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - ByteString assetAccountId = null; - final long TotalSupply = 10000000L; - long now = System.currentTimeMillis(); - String tokenName = "testAssetIssue_" + Long.toString(now); - - //Create a new AssetIssue success. - Assert - .assertTrue(PublicMethed.createAssetIssue(contractExcAddress, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, contractExcKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - assetAccountId = PublicMethed.queryAccount(contractExcAddress, blockingStubFull) - .getAssetIssuedID(); - - Assert.assertTrue(PublicMethed.transferAsset(addressxx, - assetAccountId.toByteArray(), 100L, contractExcAddress, contractExcKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long returnAddressBytesAccountCountBefore = PublicMethed - .getAssetIssueValue(addressxx, assetAccountId, blockingStubFull); - logger.info("returnAddressBytesAccountCountBefore : " + returnAddressBytesAccountCountBefore); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - //String num = "\""+Base58.encode58Check(contractAddress) - // +"\","+ "\"" + assetAccountId.toStringUtf8() + "\""; - String num = "\"" + assetAccountId.toStringUtf8() + "\""; - //String num = "\""+Base58.encode58Check(contractAddress) +"\","+ "\"" + -1 + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenCompiledTokenId(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(energyUsageTotal < maxFeeLimit / 10); - Assert.assertEquals(100, ByteArray.toInt(infoById.get().getContractResult(0).toByteArray())); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed002.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed002.java deleted file mode 100644 index 489a10f615b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed002.java +++ /dev/null @@ -1,496 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TransferFailed002 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Send balance not enough") - public void test1SendNotEnough() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 100000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - String filePath = "src/test/resources/soliditycode/TransferFailed001.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1"; - txid = PublicMethed.triggerContract(contractAddress, - "testSendTrxInsufficientBalance(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("infoById:" + infoById); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - @Test(enabled = true, description = "Send balance enough") - public void test2SendEnough() { - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 3000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1"; - txid = PublicMethed.triggerContract(contractAddress, - "testSendTrxInsufficientBalance(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("infoById:" + infoById); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee - 1 == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - } - - - @Test(enabled = true, description = "Send trx nonexistent target") - public void test3SendTrxNonexistentTarget() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - String txid = ""; - String num = "1" + ",\"" + Base58.encode58Check(nonexistentAddress) + "\""; - - txid = PublicMethed.triggerContract(contractAddress, - "testSendTrxNonexistentTarget(uint256,address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer trx failed: Validate InternalTransfer error, no ToAccount." - + " And not allowed to create account in smart contract.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "Send trx self") - public void test4SendTrxSelf() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "1"; - txid = PublicMethed.triggerContract(contractAddress, - "testSendTrxSelf(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer trx failed: Cannot transfer trx to yourself.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "Send trx nonexistent target and balance not enough") - public void test5SendTrxNonexistentTarget() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - String txid = ""; - - String num = "100000000" + ",\"" + Base58.encode58Check(contractExcAddress) + "\""; - - txid = PublicMethed.triggerContract(contractAddress, - "testSendTrxNonexistentTarget(uint256,address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - } - - - @Test(enabled = true, description = "Send trx self and balance not enough") - public void test6SendTrxSelf() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - String txid = ""; - - String num = "1000000000"; - - txid = PublicMethed.triggerContract(contractAddress, - "testSendTrxSelf(uint256)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed003.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed003.java deleted file mode 100644 index 328f0dfed80..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed003.java +++ /dev/null @@ -1,697 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TransferFailed003 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private static ByteString assetAccountId = null; - private static final long now = System.currentTimeMillis(); - private static String tokenName = "testAssetIssue_" + Long.toString(now); - private static final long TotalSupply = 10000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test(enabled = true, description = "TransferToken enough tokenBalance") - public void test1TransferTokenEnough() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000_000_000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - long start = System.currentTimeMillis() + 2000; - long end = System.currentTimeMillis() + 1000000000; - - //Create a new AssetIssue success. - Assert - .assertTrue(PublicMethed.createAssetIssue(contractExcAddress, tokenName, TotalSupply, 1, - 10000, start, end, 1, description, url, 100000L, - 100000L, 1L, 1L, contractExcKey, blockingStubFull)); - assetAccountId = PublicMethed.queryAccount(contractExcAddress, blockingStubFull) - .getAssetIssuedID(); - - String filePath = "src/test/resources/soliditycode/TransferFailed001.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.transferAsset(contractAddress, - assetAccountId.toByteArray(), 100L, contractExcAddress, contractExcKey, - blockingStubFull)); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - String num = "1" + ",\"" + assetAccountId.toStringUtf8() + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenInsufficientBalance(uint256,trcToken)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(testNetAccountCountBefore + 1 == testNetAccountCountAfter); - Assert.assertTrue(contractAccountCountBefore - 1 == contractAccountCountAfter); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - - } - - @Test(enabled = true, description = "TransferToken insufficient tokenBalance") - public void test2TransferTokenNotEnough() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - String num = "1000" + ",\"" + assetAccountId.toStringUtf8() + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenInsufficientBalance(uint256,trcToken)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - logger.info("infoById:" + infoById); - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "REVERT opcode executed", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertEquals(testNetAccountCountBefore, testNetAccountCountAfter); - Assert.assertEquals(contractAccountCountBefore, contractAccountCountAfter); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - } - - - @Test(enabled = true, description = "TransferToken to nonexistent target") - public void test3TransferTokenNonexistentTarget() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - String num = - "\"1" + "\",\"" + Base58.encode58Check(nonexistentAddress) + "\",\"" + assetAccountId - .toStringUtf8() + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenNonexistentTarget(uint256,address,trcToken)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer trc10 failed: Validate InternalTransfer error, no ToAccount." - + " And not allowed to create account in smart contract.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertEquals(testNetAccountCountBefore, testNetAccountCountAfter); - Assert.assertEquals(contractAccountCountBefore, contractAccountCountAfter); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "TransferToken to myself") - public void test4TransferTokenSelf() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - String num = "1" + ",\"" + assetAccountId.toStringUtf8() + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenSelf(uint256,trcToken)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer trc10 failed: Cannot transfer asset to yourself.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertEquals(testNetAccountCountBefore, testNetAccountCountAfter); - Assert.assertEquals(contractAccountCountBefore, contractAccountCountAfter); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "TransferToken notexist tokenID ") - public void test5TransferTokenNotexist() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - String fakeassetAccountId = Long.toString(0L); - - String num = "1" + ",\"" + fakeassetAccountId + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenInsufficientBalance(uint256,trcToken)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "REVERT opcode executed", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertEquals(testNetAccountCountBefore, testNetAccountCountAfter); - Assert.assertEquals(contractAccountCountBefore, contractAccountCountAfter); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - - } - - - @Test(enabled = true, description = "TransferToken to nonexistent target and " - + "insufficient tokenBalance") - public void test7TransferTokenNonexistentTarget() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - String num = - "\"100000000000" + "\",\"" + Base58.encode58Check(nonexistentAddress) + "\",\"" - + assetAccountId - .toStringUtf8() + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenNonexistentTarget(uint256,address,trcToken)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "REVERT opcode executed", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertEquals(testNetAccountCountBefore, testNetAccountCountAfter); - Assert.assertEquals(contractAccountCountBefore, contractAccountCountAfter); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - - @Test(enabled = true, description = "TransferToken to myself and insufficient tokenBalance") - public void test8TransferTokenSelf() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - Long testNetAccountCountBefore = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountBefore = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - logger.info("testNetAccountCountBefore:" + testNetAccountCountBefore); - logger.info("contractAccountCountBefore:" + contractAccountCountBefore); - String txid = ""; - String num = "1000000000000000" + ",\"" + assetAccountId.toStringUtf8() + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testTransferTokenSelf(uint256,trcToken)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infoById:" + infoById); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - Long testNetAccountCountAfter = PublicMethed - .getAssetIssueValue(contractExcAddress, assetAccountId, blockingStubFull); - Long contractAccountCountAfter = PublicMethed - .getAssetIssueValue(contractAddress, assetAccountId, blockingStubFull); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - logger.info("testNetAccountCountAfter:" + testNetAccountCountAfter); - logger.info("contractAccountCountAfter:" + contractAccountCountAfter); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.REVERT, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "REVERT opcode executed", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertEquals(testNetAccountCountBefore, testNetAccountCountAfter); - Assert.assertEquals(contractAccountCountBefore, contractAccountCountAfter); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - Assert.assertNotEquals(10000000, energyUsageTotal); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed004.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed004.java deleted file mode 100644 index e6f455fc2a1..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed004.java +++ /dev/null @@ -1,261 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction.Result.contractResult; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TransferFailed004 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] nonexistentAddress = ecKey2.getAddress(); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "Suicide nonexistent target") - public void test1SuicideNonexistentTarget() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - String filePath = "src/test/resources/soliditycode/TransferFailed001.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - String num = "\"" + Base58.encode58Check(nonexistentAddress) + "\""; - - txid = PublicMethed.triggerContract(contractAddress, - "testSuicideNonexistentTarget(address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("infobyid : --- " + infoById); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 1); - Assert.assertEquals(contractResult.TRANSFER_FAILED, infoById.get().getReceipt().getResult()); - Assert.assertEquals( - "transfer all token or transfer all trx failed in suicide: " - + "Validate InternalTransfer error, no ToAccount. And not allowed " - + "to create account in smart contract.", - ByteArray.toStr(infoById.get().getResMessage().toByteArray())); - - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Assert.assertNotEquals(10000000, energyUsageTotal); - - - } - - @Test(enabled = true, description = "Suicide existent target") - public void test2SuicideExistentTarget() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertTrue(PublicMethed - .sendcoin(nonexistentAddress, 1000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String txid = ""; - String num = "\"" + Base58.encode58Check(nonexistentAddress) + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testSuicideNonexistentTarget(address)", num, false, - 0, maxFeeLimit, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull1); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull1); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - Account contractafter = PublicMethed.queryAccount(contractAddress, blockingStubFull1); - long contractBalance = contractafter.getBalance(); - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertEquals(contractBalance, 0); - - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - - - } - - - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed005.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed005.java deleted file mode 100644 index 88bae7d9ea1..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed005.java +++ /dev/null @@ -1,509 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TransferFailed005 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private final Long maxFeeLimit = Configuration.getByPath("testng.cong") - .getLong("defaultParameter.maxFeeLimit"); - - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - byte[] contractAddress = null; - byte[] contractAddress1 = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] accountExcAddress = ecKey1.getAddress(); - String accountExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(accountExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - { - Assert.assertTrue(PublicMethed - .sendcoin(accountExcAddress, 10000_000_000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/TransferFailed005.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - - filePath = "src/test/resources/soliditycode/TransferFailed005.sol"; - contractName = "Caller"; - retMap = PublicMethed.getBycodeAbi(filePath, contractName); - code = retMap.get("byteCode").toString(); - abi = retMap.get("abI").toString(); - - contractAddress1 = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - } - } - - @Test(enabled = false, description = "Deploy contract for trigger") - public void deployContract() { - Assert.assertTrue(PublicMethed - .sendcoin(accountExcAddress, 10000_000_000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/TransferFailed005.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - String Txid1 = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(Txid1, blockingStubFull); - contractAddress = infoById.get().getContractAddress().toByteArray(); - Assert.assertEquals(0, infoById.get().getResultValue()); - - filePath = "src/test/resources/soliditycode/TransferFailed005.sol"; - contractName = "Caller"; - retMap = PublicMethed.getBycodeAbi(filePath, contractName); - code = retMap.get("byteCode").toString(); - abi = retMap.get("abI").toString(); - - contractAddress1 = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - Txid1 = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(Txid1, blockingStubFull); - contractAddress1 = infoById.get().getContractAddress().toByteArray(); - logger.info("caller address : " + Base58.encode58Check(contractAddress1)); - Assert.assertEquals(0, infoById.get().getResultValue()); - } - - @Test(enabled = true, description = "TransferFailed for function call_value ") - public void triggerContract01() { - Account info = null; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(accountExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(accountExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000100L, accountExcAddress, accountExcKey, blockingStubFull)); - //Assert.assertTrue(PublicMethed - // .sendcoin(contractAddress1, 1, accountExcAddress, accountExcKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - logger.info( - "callerAddress balance before: " + PublicMethed - .queryAccount(contractAddress1, blockingStubFull) - .getBalance()); - long paramValue = 1000000; - - // transfer trx to self`s account - String param = "\"" + paramValue + "\",\"" + Base58.encode58Check(contractAddress) + "\""; - String triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCallTrxInsufficientBalance(uint256,address)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertEquals(infoById.get().getResultValue(), 1); - Assert.assertEquals("FAILED", infoById.get().getResult().toString()); - Assert.assertEquals("TRANSFER_FAILED", infoById.get().getReceipt().getResult().toString()); - Assert.assertEquals("transfer trx failed: Cannot transfer trx to yourself.", - infoById.get().getResMessage().toStringUtf8()); - Assert.assertEquals(1000100L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertEquals(0L, - PublicMethed.queryAccount(contractAddress1, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - // transfer trx to unactivate account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] accountExcAddress2 = ecKey2.getAddress(); - param = "\"" + paramValue + "\",\"" + Base58.encode58Check(accountExcAddress2) + "\""; - triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCallTrxInsufficientBalance(uint256,address)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Assert.assertEquals(infoById.get().getResultValue(), 1); - Assert.assertEquals("FAILED", infoById.get().getResult().toString()); - Assert.assertEquals("TRANSFER_FAILED", infoById.get().getReceipt().getResult().toString()); - Assert.assertEquals( - "transfer trx failed: Validate InternalTransfer error, no ToAccount. " - + "And not allowed to create account in smart contract.", - infoById.get().getResMessage().toStringUtf8()); - Assert.assertEquals(1000100L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertEquals(0L, - PublicMethed.queryAccount(contractAddress1, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - // transfer trx to caller, value enough , function success contractResult(call_value) failed - param = "\"" + paramValue + "\",\"" + Base58.encode58Check(contractAddress1) + "\""; - triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCallTrxInsufficientBalance(uint256,address)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info(infoById.get().getReceipt().getResult() + ""); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - int contractResult = ByteArray - .toInt(infoById.get().getContractResult(0).toByteArray()); - Assert.assertEquals(1, contractResult); - - Assert.assertEquals(infoById.get().getResultValue(), 0); - Assert.assertEquals(infoById.get().getResult().toString(), "SUCESS"); - Assert.assertEquals(100L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertEquals(1000000L, - PublicMethed.queryAccount(contractAddress1, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - // transfer trx to caller, value not enough, function success - // but contractResult(call_value) failed - triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCallTrxInsufficientBalance(uint256,address)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - fee = infoById.get().getFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - //contractResult`s first boolean value - contractResult = ByteArray - .toInt(infoById.get().getContractResult(0).toByteArray()); - Assert.assertEquals(0, contractResult); - Assert.assertEquals(infoById.get().getResultValue(), 0); - Assert.assertEquals(infoById.get().getResult().toString(), "SUCESS"); - Assert.assertEquals(100L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertEquals(1000000L, - PublicMethed.queryAccount(contractAddress1, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - - } - - @Test(enabled = true, description = "TransferFailed for create") - public void triggerContract02() { - Account info = null; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(accountExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(accountExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000100L, accountExcAddress, accountExcKey, blockingStubFull)); - //Assert.assertTrue(PublicMethed - // .sendcoin(contractAddress1, 1, accountExcAddress, accountExcKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - logger.info( - "callerAddress balance before: " + PublicMethed - .queryAccount(contractAddress1, blockingStubFull) - .getBalance()); - long paramValue = 1000000; - String param = "\"" + paramValue + "\""; - - String triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCreateTrxInsufficientBalance(uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info(infoById.get().getReceipt().getResult() + ""); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - logger.info( - "callerAddress balance before: " + PublicMethed - .queryAccount(contractAddress1, blockingStubFull) - .getBalance()); - Assert.assertEquals(infoById.get().getResultValue(), 0); - Assert.assertFalse(infoById.get().getInternalTransactions(0).getRejected()); - Assert.assertEquals(200L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCreateTrxInsufficientBalance(uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - fee = infoById.get().getFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - logger.info( - "callerAddress balance before: " + PublicMethed - .queryAccount(contractAddress1, blockingStubFull) - .getBalance()); - - Assert.assertEquals(infoById.get().getResultValue(), 1); - Assert.assertEquals(infoById.get().getResMessage().toStringUtf8(), "REVERT opcode executed"); - Assert.assertEquals(200L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertEquals(1000000L, - PublicMethed.queryAccount(contractAddress1, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - - } - - @Test(enabled = true, description = "TransferFailed for create2") - public void triggerContract03() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(accountExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(accountExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 15L, accountExcAddress, accountExcKey, blockingStubFull)); - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - - String filePath = "./src/test/resources/soliditycode/TransferFailed007.sol"; - String contractName = "Caller"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - String triggerTxid = PublicMethed.triggerContract(contractAddress, - "deploy(bytes,uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - long afterBalance = 0L; - afterBalance = PublicMethed.queryAccount(contractAddress, blockingStubFull) - .getBalance(); - logger.info( - "contractAddress balance after : " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - Assert.assertEquals(0, infoById.get().getResultValue()); - Assert.assertEquals("SUCESS", infoById.get().getResult().toString()); - Assert.assertEquals(205L, afterBalance); - Assert.assertFalse(infoById.get().getInternalTransactions(0).getRejected()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - triggerTxid = PublicMethed.triggerContract(contractAddress, - "deploy2(bytes,uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - fee = infoById.get().getFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - afterBalance = PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance(); - logger.info( - "contractAddress balance after : " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - Assert.assertEquals(1, infoById.get().getResultValue()); - Assert.assertEquals("FAILED", infoById.get().getResult().toString()); - Assert.assertEquals(205L, afterBalance); - Assert.assertEquals(0, ByteArray.toInt( - infoById.get().getContractResult(0).toByteArray())); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - } - - - /** - * constructor. - */ - @AfterClass - - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed006.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed006.java deleted file mode 100644 index 1fa6ed77279..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed006.java +++ /dev/null @@ -1,240 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TransferFailed006 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private final Long maxFeeLimit = Configuration.getByPath("testng.cong") - .getLong("defaultParameter.maxFeeLimit"); - - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - byte[] contractAddress = null; - byte[] contractAddress1 = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] accountExcAddress = ecKey1.getAddress(); - String accountExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(accountExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - } - - @Test(enabled = false, description = "Deploy contract for trigger") - public void deployContract() { - Assert.assertTrue(PublicMethed - .sendcoin(accountExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/TransferFailed006.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String Txid1 = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(Txid1, blockingStubFull); - contractAddress = infoById.get().getContractAddress().toByteArray(); - Assert.assertEquals(0, infoById.get().getResultValue()); - - filePath = "src/test/resources/soliditycode/TransferFailed006.sol"; - contractName = "Caller"; - retMap = PublicMethed.getBycodeAbi(filePath, contractName); - code = retMap.get("byteCode").toString(); - abi = retMap.get("abI").toString(); - - Txid1 = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(Txid1, blockingStubFull); - contractAddress1 = infoById.get().getContractAddress().toByteArray(); - logger.info("caller address : " + Base58.encode58Check(contractAddress1)); - Assert.assertEquals(0, infoById.get().getResultValue()); - } - - @Test(enabled = false, description = "TransferFailed for create") - public void triggerContract() { - Account info = null; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(accountExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(accountExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 1000100L, accountExcAddress, accountExcKey, blockingStubFull)); - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress1, 1, accountExcAddress, accountExcKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - logger.info( - "callerAddress balance before: " + PublicMethed - .queryAccount(contractAddress1, blockingStubFull) - .getBalance()); - long paramValue = 1000000; - String param = "\"" + paramValue + "\""; - - String triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCreateTrxInsufficientBalance(uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - logger.info(infoById.get().getReceipt().getResult() + ""); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - logger.info( - "callerAddress balance before: " + PublicMethed - .queryAccount(contractAddress1, blockingStubFull) - .getBalance()); - Assert.assertEquals(infoById.get().getResultValue(), 0); - Assert.assertFalse(infoById.get().getInternalTransactions(0).getRejected()); - Assert.assertEquals(100L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - triggerTxid = PublicMethed.triggerContract(contractAddress, - "testCreateTrxInsufficientBalance(uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(triggerTxid, blockingStubFull); - fee = infoById.get().getFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - logger.info( - "callerAddress balance before: " + PublicMethed - .queryAccount(contractAddress1, blockingStubFull) - .getBalance()); - - Assert.assertEquals(infoById.get().getResultValue(), 1); - Assert.assertEquals(infoById.get().getResMessage().toStringUtf8(), "REVERT opcode executed"); - Assert.assertEquals(100L, - PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance()); - Assert.assertEquals(1L, - PublicMethed.queryAccount(contractAddress1, blockingStubFull).getBalance()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - - } - - /** - * constructor. - */ - @AfterClass - - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed007.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed007.java deleted file mode 100644 index ae98ce42096..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/transferfailed/TransferFailed007.java +++ /dev/null @@ -1,211 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.transferfailed; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TransferFailed007 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private final Long maxFeeLimit = Configuration.getByPath("testng.cong") - .getLong("defaultParameter.maxFeeLimit"); - - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - byte[] contractAddress = null; - byte[] contractAddress1 = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] accountExcAddress = ecKey1.getAddress(); - String accountExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(accountExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - } - - @Test(enabled = false, description = "Deploy contract for trigger") - public void deployContract() { - Assert.assertTrue(PublicMethed - .sendcoin(accountExcAddress, 10000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - String filePath = "src/test/resources/soliditycode/TransferFailed007.sol"; - String contractName = "EnergyOfTransferFailedTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - String Txid1 = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, code, "", maxFeeLimit, 0L, 100L, - null, accountExcKey, accountExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = PublicMethed - .getTransactionInfoById(Txid1, blockingStubFull); - contractAddress = infoById.get().getContractAddress().toByteArray(); - Assert.assertEquals(0, infoById.get().getResultValue()); - } - - @Test(enabled = false, description = "TransferFailed for create2") - public void triggerContract() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(accountExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(accountExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - Assert.assertTrue(PublicMethed - .sendcoin(contractAddress, 15L, accountExcAddress, accountExcKey, blockingStubFull)); - logger.info( - "contractAddress balance before: " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - - String filePath = "./src/test/resources/soliditycode/TransferFailed007.sol"; - String contractName = "Caller"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String testContractCode = retMap.get("byteCode").toString(); - Long salt = 1L; - - String param = "\"" + testContractCode + "\"," + salt; - - String triggerTxid = PublicMethed.triggerContract(contractAddress, - "deploy(bytes,uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - long afterBalance = 0L; - afterBalance = PublicMethed.queryAccount(contractAddress, blockingStubFull) - .getBalance(); - logger.info( - "contractAddress balance after : " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - Assert.assertEquals(0, infoById.get().getResultValue()); - Assert.assertEquals("SUCESS", infoById.get().getResult().toString()); - Assert.assertEquals(5L, afterBalance); - Assert.assertFalse(infoById.get().getInternalTransactions(0).getRejected()); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - triggerTxid = PublicMethed.triggerContract(contractAddress, - "deploy(bytes,uint256)", param, false, 0L, - maxFeeLimit, accountExcAddress, accountExcKey, blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - fee = infoById.get().getFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - afterBalance = PublicMethed.queryAccount(contractAddress, blockingStubFull).getBalance(); - logger.info( - "contractAddress balance after : " + PublicMethed - .queryAccount(contractAddress, blockingStubFull) - .getBalance()); - Assert.assertEquals(0, infoById.get().getResultValue()); - Assert.assertEquals("SUCESS", infoById.get().getResult().toString()); - Assert.assertEquals(5L, afterBalance); - Assert.assertEquals(0, ByteArray.toInt(infoById.get().getContractResult(0).toByteArray())); - Assert.assertTrue(infoById.get().getReceipt().getEnergyUsageTotal() < 10000000); - - } - - /** - * constructor. - */ - @AfterClass - - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant001.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant001.java deleted file mode 100644 index 0f0a046c7de..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant001.java +++ /dev/null @@ -1,813 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant001 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddressNoAbi = null; - byte[] contractAddressWithAbi = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 10000_000_000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - final String abi = retMap.get("abI").toString(); - - contractAddressNoAbi = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract( - contractAddressNoAbi, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - contractAddressWithAbi = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract2 = PublicMethed.getContract( - contractAddressWithAbi, blockingStubFull); - Assert.assertFalse(smartContract2.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract2.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract2.getBytecode().toString().isEmpty()); - - } - } - - @Test(enabled = true, description = "TriggerConstantContract a payable function without ABI") - public void test01TriggerConstantContract() { - - String txid = ""; - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressNoAbi, - "testPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - - - } - - @Test(enabled = true, description = "TriggerConstantContract a non-payable function without ABI") - public void test02TriggerConstantContract() { - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressNoAbi, - "testNoPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - - - } - - @Test(enabled = true, description = "TriggerConstantContract a view function without ABI") - public void test03TriggerConstantContract() { - - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressNoAbi, - "testView()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - } - - @Test(enabled = true, description = "TriggerConstantContract a pure function without ABI") - public void test04TriggerConstantContract() { - - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressNoAbi, - "testPure()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - - } - - @Test(enabled = true, description = "TriggerConstantContract a payable function with ABI") - public void test05TriggerConstantContract() { - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressNoAbi, - "testPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert.assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert.assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - - } - - @Test(enabled = true, description = "TriggerConstantContract a non-payable function with ABI") - public void test06TriggerConstantContract() { - - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressWithAbi, - "testNoPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert.assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert.assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - - } - - @Test(enabled = true, description = "TriggerConstantContract a view function with ABI") - public void test07TriggerConstantContract() { - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressWithAbi, - "testView()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - - } - - @Test(enabled = true, description = "TriggerConstantContract a pure function with ABI") - public void test08TriggerConstantContract() { - - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressWithAbi, - "testPure()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - - } - - @Test(enabled = true, description = "TriggerContract a payable function without ABI") - public void test09TriggerContract() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddressNoAbi, - "testPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - @Test(enabled = true, description = "TriggerContract a non-payable function without ABI") - public void test10TriggerContract() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddressNoAbi, - "testNoPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - @Test(enabled = true, description = "TriggerContract a view function without ABI") - public void test11TriggerContract() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddressNoAbi, - "testView()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - @Test(enabled = true, description = "TriggerContract a pure function without ABI") - public void test12TriggerContract() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddressNoAbi, - "testPure()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - @Test(enabled = true, description = "TriggerContract a pure function with ABI") - public void test18TriggerContract() { - - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(contractAddressWithAbi, - "testPure()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - } - - @Test(enabled = true, description = "TriggerContract a payable function with ABI") - public void test19TriggerContract() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - txid = PublicMethed - .triggerContract(contractAddressWithAbi, - "testPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - } - - @Test(enabled = true, description = "TriggerContract a non-payable function with ABI") - public void test20TriggerContract() { - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - txid = PublicMethed - .triggerContract(contractAddressNoAbi, - "testNoPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - } - - @Test(enabled = true, description = "TriggerContract a view function with ABI") - public void test21TriggerContract() { - - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(contractAddressWithAbi, - "testView()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - } - - @Test(enabled = true, description = "TriggerConstantContract a view method with ABI ,method has " - + "revert()") - public void test24TriggerConstantContract() { - - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressWithAbi, - "testView2()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - - Assert - .assertThat(transaction.getRet(0).getRet().toString(), - containsString("FAILED")); - Assert - .assertThat(ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray()), - containsString("REVERT opcode executed")); - - - } - - @Test(enabled = true, description = "TriggerContract a view method with ABI ,method has " - + "revert()") - public void test25TriggerContract() { - - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(contractAddressWithAbi, - "testView2()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - - Assert.assertThat(transaction.getRet(0).getRet().toString(), - containsString("FAILED")); - Assert.assertThat(ByteArray.toStr(transactionExtention.getResult().getMessage().toByteArray()), - containsString("REVERT opcode executed")); - - - } - - @Test(enabled = true, description = "TriggerConstantContract a view method without ABI,method has" - + "revert()") - public void testTriggerConstantContract() { - - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddressNoAbi, - "testView2()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert - .assertThat(transaction.getRet(0).getRet().toString(), - containsString("FAILED")); - Assert - .assertThat(ByteArray.toStr(transactionExtention.getResult().getMessage().toByteArray()), - containsString("REVERT opcode executed")); - - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant002.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant002.java deleted file mode 100644 index acc77a07a5b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant002.java +++ /dev/null @@ -1,161 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant002 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a non-payable function without ABI") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant002.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testNoPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant003.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant003.java deleted file mode 100644 index bdc4e1bb730..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant003.java +++ /dev/null @@ -1,218 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant003 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "TriggerConstantContract a view function without ABI") - public void test001TriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant003.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testView()", "#", false, - 0, 1000000000, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - } - - - @Test(enabled = true, description = "TriggerConstantContract a payable function with ABI") - public void test002TriggerConstantContract() { - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPayable()", "#", false, - 0, 1000000000, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - Assert.assertEquals("SUCESS", transaction.getRet(0).getRet().toString()); - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPayable()", "#", false, - 1L, 1000000000, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - transaction = transactionExtention.getTransaction(); - - result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - Assert.assertEquals("constant cannot set call value or call token value.", - ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - Assert.assertEquals("FAILED", transaction.getRet(0).getRet().toString()); - - - } - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant004.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant004.java deleted file mode 100644 index 94da7df47ee..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant004.java +++ /dev/null @@ -1,163 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant004 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a pure function without ABI") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPure()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant005.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant005.java deleted file mode 100644 index bb592dccfeb..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant005.java +++ /dev/null @@ -1,159 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant005 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "TriggerConstantContract a payable function with ABI") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert.assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert.assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant006.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant006.java deleted file mode 100644 index b9cb1998d4b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant006.java +++ /dev/null @@ -1,160 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant006 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a non-payable function with ABI") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant002.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testNoPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert.assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert.assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant007.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant007.java deleted file mode 100644 index 6dc8e0f33bf..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant007.java +++ /dev/null @@ -1,163 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant007 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a view function with ABI") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant003.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testView()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant008.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant008.java deleted file mode 100644 index a714d5de1be..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant008.java +++ /dev/null @@ -1,163 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant008 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a pure function with ABI") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPure()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant009.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant009.java deleted file mode 100644 index 31c6ecc7ef7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant009.java +++ /dev/null @@ -1,187 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant009 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a payable function without ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddress, - "testPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant010.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant010.java deleted file mode 100644 index d5268d6aeb2..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant010.java +++ /dev/null @@ -1,187 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant010 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a non-payable function without ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant002.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddress, - "testNoPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant011.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant011.java deleted file mode 100644 index f74c9663e93..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant011.java +++ /dev/null @@ -1,187 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant011 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a view function without ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant003.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddress, - "testView()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant012.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant012.java deleted file mode 100644 index d6d2a31738c..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant012.java +++ /dev/null @@ -1,187 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant012 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a pure function without ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - - txid = PublicMethed - .triggerContract(contractAddress, - "testPure()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant013.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant013.java deleted file mode 100644 index f35c7b4c86b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant013.java +++ /dev/null @@ -1,257 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant013 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - byte[] returnAddressBytes = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "triggerContract a constant function created by create2") - public void test01TriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant015.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "plusOne()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - } - - - @Test(enabled = true, description = "TriggerConstantContract a constant function " - + "created by create2") - public void test15TriggerConstantContract() { - - SmartContract smartContract = PublicMethed.getContract(returnAddressBytes, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(returnAddressBytes, - "plusOne()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant014.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant014.java deleted file mode 100644 index c35d9eea84d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant014.java +++ /dev/null @@ -1,252 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant014 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - byte[] returnAddressBytes = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "TriggerContract a non-constant function created by create2") - public void test01TriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi005.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - txid = PublicMethed - .triggerContract(returnAddressBytes, - "plusOne()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById1 = null; - infoById1 = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee1 = infoById1.get().getFee(); - Long netUsed1 = infoById1.get().getReceipt().getNetUsage(); - Long energyUsed1 = infoById1.get().getReceipt().getEnergyUsage(); - Long netFee1 = infoById1.get().getReceipt().getNetFee(); - long energyUsageTotal1 = infoById1.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee1:" + fee1); - logger.info("netUsed1:" + netUsed1); - logger.info("energyUsed1:" + energyUsed1); - logger.info("netFee1:" + netFee1); - logger.info("energyUsageTotal1:" + energyUsageTotal1); - - Account infoafter1 = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter1 = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance1 = infoafter1.getBalance(); - Long afterEnergyUsed1 = resourceInfoafter1.getEnergyUsed(); - Long afterNetUsed1 = resourceInfoafter1.getNetUsed(); - Long afterFreeNetUsed1 = resourceInfoafter1.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance1); - logger.info("afterEnergyUsed:" + afterEnergyUsed1); - logger.info("afterNetUsed:" + afterNetUsed1); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed1); - - Assert.assertTrue(infoById1.get().getResultValue() == 0); - Assert.assertTrue(afterBalance1 + fee1 == afterBalance); - Assert.assertTrue(afterEnergyUsed + energyUsed1 >= afterEnergyUsed1); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById1.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - } - - @Test(enabled = true, description = "TriggerConstantContract a non-constant function " - + "created by create2") - public void test16TriggerConstantContract() { - - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(returnAddressBytes, - "plusOne()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant015.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant015.java deleted file mode 100644 index 088d2c2c53e..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant015.java +++ /dev/null @@ -1,211 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant015 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a constant function " - + "created by create2") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant015.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - SmartContract smartContract = PublicMethed.getContract(returnAddressBytes, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(returnAddressBytes, - "plusOne()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant016.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant016.java deleted file mode 100644 index 02876fe2289..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant016.java +++ /dev/null @@ -1,206 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant016 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a non-constant function " - + "created by create2") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi005.sol"; - String contractName = "Factory"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - String contractName1 = "TestConstract"; - HashMap retMap1 = PublicMethed.getBycodeAbi(filePath, contractName1); - String code1 = retMap1.get("byteCode").toString(); - String abi1 = retMap1.get("abI").toString(); - String txid = ""; - String num = "\"" + code1 + "\"" + "," + 1; - txid = PublicMethed - .triggerContract(contractAddress, - "deploy(bytes,uint256)", num, false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - byte[] returnAddressBytes = infoById.get().getInternalTransactions(0).getTransferToAddress() - .toByteArray(); - String returnAddress = Base58.encode58Check(returnAddressBytes); - logger.info("returnAddress:" + returnAddress); - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(returnAddressBytes, - "plusOne()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant017.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant017.java deleted file mode 100644 index f43f98d8417..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant017.java +++ /dev/null @@ -1,185 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant017 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true, description = "TriggerConstantContract a constant function which is " - + "deployed with ABI, but cleared ABI later") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 100000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/ClearAbi001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - String txid = ""; - txid = PublicMethed - .clearContractAbi(contractAddress, contractExcAddress, contractExcKey, blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - - TransactionExtention transactionExtention1 = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testPayable()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - Transaction transaction1 = transactionExtention1.getTransaction(); - - byte[] result1 = transactionExtention1.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction1.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention1.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result1)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result1)))); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant018.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant018.java deleted file mode 100644 index ac5c092a472..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant018.java +++ /dev/null @@ -1,161 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant018 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a pure function with ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(contractAddress, - "testPure()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant019.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant019.java deleted file mode 100644 index 1c34629672a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant019.java +++ /dev/null @@ -1,185 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant019 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a payable function with ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant001.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - txid = PublicMethed - .triggerContract(contractAddress, - "testPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant020.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant020.java deleted file mode 100644 index f110a68dde6..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant020.java +++ /dev/null @@ -1,185 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant020 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a non-payable function with ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant002.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - String txid = ""; - txid = PublicMethed - .triggerContract(contractAddress, - "testNoPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Optional infoById = null; - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Long fee = infoById.get().getFee(); - Long netUsed = infoById.get().getReceipt().getNetUsage(); - Long energyUsed = infoById.get().getReceipt().getEnergyUsage(); - Long netFee = infoById.get().getReceipt().getNetFee(); - long energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - - logger.info("fee:" + fee); - logger.info("netUsed:" + netUsed); - logger.info("energyUsed:" + energyUsed); - logger.info("netFee:" + netFee); - logger.info("energyUsageTotal:" + energyUsageTotal); - - Account infoafter = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - AccountResourceMessage resourceInfoafter = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - Long afterBalance = infoafter.getBalance(); - Long afterEnergyUsed = resourceInfoafter.getEnergyUsed(); - Long afterNetUsed = resourceInfoafter.getNetUsed(); - Long afterFreeNetUsed = resourceInfoafter.getFreeNetUsed(); - logger.info("afterBalance:" + afterBalance); - logger.info("afterEnergyUsed:" + afterEnergyUsed); - logger.info("afterNetUsed:" + afterNetUsed); - logger.info("afterFreeNetUsed:" + afterFreeNetUsed); - - Assert.assertTrue(infoById.get().getResultValue() == 0); - Assert.assertTrue(afterBalance + fee == beforeBalance); - Assert.assertTrue(beforeEnergyUsed + energyUsed >= afterEnergyUsed); - Assert.assertTrue(beforeFreeNetUsed + netUsed >= afterFreeNetUsed); - Assert.assertTrue(beforeNetUsed + netUsed >= afterNetUsed); - Long returnnumber = ByteArray.toLong(ByteArray - .fromHexString(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()))); - Assert.assertTrue(1 == returnnumber); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant021.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant021.java deleted file mode 100644 index 4bc9c426825..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant021.java +++ /dev/null @@ -1,161 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant021 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a view function with ABI") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant003.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(contractAddress, - "testView()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert.assertEquals(1, ByteArray.toLong(ByteArray - .fromHexString(Hex - .toHexString(result)))); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant022.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant022.java deleted file mode 100644 index b1462c4c8e8..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant022.java +++ /dev/null @@ -1,164 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant022 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a non-payable function " - + "with ABI(constant ABI)") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant002.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = "[{\"constant\":true,\"inputs\":[],\"name\":\"testNoPayable\",\"outputs\":[{\"" - + "name\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable" - + "\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"i\",\"outputs\":" - + "[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\"," - + "\"type\":\"function\"}]"; - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(contractAddress, - "testNoPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant023.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant023.java deleted file mode 100644 index 255aadf3d16..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant023.java +++ /dev/null @@ -1,164 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant023 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a non-payable function with" - + " ABI(constant ABI )") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant002.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = "[{\"constant\":true,\"inputs\":[],\"name\":\"testNoPayable\",\"outputs\":[{\"name" - + "\":\"z\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"" - + "type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"i\",\"outputs\":[{\"na" - + "me\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\"" - + ":\"function\"}]"; - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testNoPayable()", "#", false, - 0, maxFeeLimit, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - System.out.println("Code = " + transactionExtention.getResult().getCode()); - System.out - .println("Message = " + transactionExtention.getResult().getMessage().toStringUtf8()); - - Assert - .assertThat(transactionExtention.getResult().getCode().toString(), - containsString("CONTRACT_EXE_ERROR")); - Assert - .assertThat(transactionExtention.getResult().getMessage().toStringUtf8(), - containsString("Attempt to call a state modifying opcode inside STATICCALL")); - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant024.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant024.java deleted file mode 100644 index c18cb73d435..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant024.java +++ /dev/null @@ -1,168 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant024 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a view method with ABI ,method has " - + "revert()") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant024.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testView()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - - Assert - .assertThat(transaction.getRet(0).getRet().toString(), - containsString("FAILED")); - Assert - .assertThat(ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray()), - containsString("REVERT opcode executed")); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant025.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant025.java deleted file mode 100644 index 50d6b6cdc83..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant025.java +++ /dev/null @@ -1,165 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant025 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerContract a view method with ABI ,method has " - + "revert()") - public void testTriggerContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant024.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerContractForExtention(contractAddress, - "testView()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - - Assert.assertThat(transaction.getRet(0).getRet().toString(), - containsString("FAILED")); - Assert.assertThat(ByteArray.toStr(transactionExtention.getResult().getMessage().toByteArray()), - containsString("REVERT opcode executed")); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant026.java b/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant026.java deleted file mode 100644 index 802d23722a7..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/triggerconstant/TriggerConstant026.java +++ /dev/null @@ -1,169 +0,0 @@ -package stest.tron.wallet.dailybuild.tvmnewcommand.triggerconstant; - -import static org.hamcrest.core.StringContains.containsString; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.GrpcAPI.TransactionExtention; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TriggerConstant026 { - - private final String testNetAccountKey = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelSolidity = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contractExcAddress = ecKey1.getAddress(); - String contractExcKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contractExcKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = false, description = "TriggerConstantContract a view method without ABI," - + "method has revert()") - public void testTriggerConstantContract() { - Assert.assertTrue(PublicMethed - .sendcoin(contractExcAddress, 1000000000L, testNetAccountAddress, testNetAccountKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String filePath = "src/test/resources/soliditycode/TriggerConstant004.sol"; - String contractName = "testConstantContract"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - contractAddress = PublicMethed.deployContract(contractName, "[]", code, "", maxFeeLimit, - 0L, 100, null, contractExcKey, - contractExcAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - Account info; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(contractExcAddress, - blockingStubFull); - info = PublicMethed.queryAccount(contractExcKey, blockingStubFull); - Long beforeBalance = info.getBalance(); - Long beforeEnergyUsed = resourceInfo.getEnergyUsed(); - Long beforeNetUsed = resourceInfo.getNetUsed(); - Long beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beforeBalance:" + beforeBalance); - logger.info("beforeEnergyUsed:" + beforeEnergyUsed); - logger.info("beforeNetUsed:" + beforeNetUsed); - logger.info("beforeFreeNetUsed:" + beforeFreeNetUsed); - - TransactionExtention transactionExtention = PublicMethed - .triggerConstantContractForExtention(contractAddress, - "testView()", "#", false, - 0, 0, "0", 0, contractExcAddress, contractExcKey, blockingStubFull); - - Transaction transaction = transactionExtention.getTransaction(); - - byte[] result = transactionExtention.getConstantResult(0).toByteArray(); - System.out.println("message:" + transaction.getRet(0).getRet()); - System.out.println(":" + ByteArray - .toStr(transactionExtention.getResult().getMessage().toByteArray())); - System.out.println("Result:" + Hex.toHexString(result)); - - Assert - .assertThat(transaction.getRet(0).getRet().toString(), - containsString("FAILED")); - Assert - .assertThat(ByteArray.toStr(transactionExtention.getResult().getMessage().toByteArray()), - containsString("REVERT opcode executed")); - - - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken001.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken001.java deleted file mode 100644 index 343650cb8e1..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken001.java +++ /dev/null @@ -1,263 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.GrpcAPI.SpendResult; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - -@Slf4j -public class WalletTestZenToken001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional shieldAddressInfo; - String shieldAddress; - List shieldOutList = new ArrayList<>(); - List shieldInputList = new ArrayList<>(); - DecryptNotes notes; - String memo; - Note note; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 8 * zenTokenFee; - private Long sendTokenAmount = 3 * zenTokenFee; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - if (PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getCreateTime() == 0) { - PublicMethed.sendcoin(foundationZenTokenAddress, 20480000000000L, fromAddress, - testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String name = "shieldToken"; - Long start = System.currentTimeMillis() + 20000; - Long end = System.currentTimeMillis() + 10000000000L; - Long totalSupply = 15000000000000001L; - String description = "This asset issue is use for exchange transaction stress"; - String url = "This asset issue is use for exchange transaction stress"; - PublicMethed.createAssetIssue(foundationZenTokenAddress, name, totalSupply, 1, 1, - start, end, 1, description, url, 1000L, 1000L, - 1L, 1L, foundationZenTokenKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account getAssetIdFromThisAccount = - PublicMethed.queryAccount(foundationZenTokenAddress, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - logger.info("AssetId:" + assetAccountId.toString()); - } - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Public to shield transaction") - public void test1Public2ShieldTransaction() { - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - logger.info("shieldAddress:" + shieldAddress); - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long beforeNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull).getFreeNetUsed(); - - memo = "aaaaaaa"; - - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + (sendTokenAmount - zenTokenFee), memo); - - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, sendTokenAmount, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Long afterNetUsed = PublicMethed.getAccountResource(zenTokenOwnerAddress, blockingStubFull) - .getFreeNetUsed(); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == sendTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount = note.getValue(); - Assert.assertTrue(receiverShieldTokenAmount == sendTokenAmount - zenTokenFee); - Assert.assertEquals(memo, PublicMethed.getMemo(note)); - } - - @Test(enabled = true, description = "Shield to public transaction") - public void test2Shield2PublicTransaction() { - note = notes.getNoteTxs(0).getNote(); - SpendResult result = PublicMethed.getSpendResult(shieldAddressInfo.get(), - notes.getNoteTxs(0), blockingStubFull); - Assert.assertTrue(!result.getResult()); - - shieldOutList.clear(); - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - zenTokenOwnerAddress, note.getValue() - zenTokenFee, - zenTokenOwnerKey, blockingStubFull)); - - //When you want to send shield coin to public account,you should add one zero output amount cm - /* shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "0", memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - zenTokenOwnerAddress, note.getValue() - zenTokenFee, - zenTokenOwnerKey, blockingStubFull));*/ - - PublicMethed.waitProduceNextBlock(blockingStubFull); - result = PublicMethed.getSpendResult(shieldAddressInfo.get(), notes.getNoteTxs(0), - blockingStubFull); - Assert.assertTrue(result.getResult()); - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Assert.assertTrue(afterAssetBalance - beforeAssetBalance == note.getValue() - zenTokenFee); - logger.info("beforeAssetBalance:" + beforeAssetBalance); - logger.info("afterAssetBalance :" + afterAssetBalance); - } - - - @Test(enabled = true, description = "Output amount can't be zero or below zero") - public void test3Shield2PublicAmountIsZero() { - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - memo = "Shield to public amount is zero"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + (sendTokenAmount - zenTokenFee), memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, sendTokenAmount, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + (note.getValue() - zenTokenFee - (zenTokenFee - note.getValue())), memo); - Assert.assertFalse(PublicMethed.sendShieldCoin( - null, 0, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - zenTokenOwnerAddress, zenTokenFee - note.getValue(), - zenTokenOwnerKey, blockingStubFull)); - - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + (note.getValue() - zenTokenFee), memo); - - Assert.assertFalse(PublicMethed.sendShieldCoin( - null, 0, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - zenTokenOwnerAddress, 0, - zenTokenOwnerKey, blockingStubFull)); - - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + (-zenTokenFee), memo); - Assert.assertFalse(PublicMethed.sendShieldCoin( - null, 0, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - zenTokenOwnerAddress, note.getValue(), - zenTokenOwnerKey, blockingStubFull)); - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken002.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken002.java deleted file mode 100644 index 8e4c9343727..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken002.java +++ /dev/null @@ -1,326 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import org.tron.protos.Contract.IncrementalMerkleVoucherInfo; -import org.tron.protos.Contract.OutputPoint; -import org.tron.protos.Contract.OutputPointInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - - -@Slf4j -public class WalletTestZenToken002 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional sendShieldAddressInfo; - Optional receiverShieldAddressInfo; - String sendShieldAddress; - String receiverShieldAddress; - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - String memo; - Note sendNote; - Note receiverNote; - private static ByteString assetAccountId = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private ManagedChannel channelSolidity1 = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity1 = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - private String soliditynode1 = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 10 * zenTokenFee; - private Long sendTokenAmount = 8 * zenTokenFee; - IncrementalMerkleVoucherInfo firstMerkleVoucherInfo; - IncrementalMerkleVoucherInfo secondMerkleVoucherInfo; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode).usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - channelSolidity1 = ManagedChannelBuilder.forTarget(soliditynode1) - .usePlaintext(true) - .build(); - blockingStubSolidity1 = WalletSolidityGrpc.newBlockingStub(channelSolidity1); - - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddressInfo:" + sendShieldAddressInfo); - memo = "Shield memo in" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + (sendTokenAmount - zenTokenFee), memo); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress, sendTokenAmount, null, - null, shieldOutList, null, 0, zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - sendNote = notes.getNoteTxs(0).getNote(); - } - - @Test(enabled = true, description = "Get merkle tree voucher info") - public void test1GetMerkleTreeVoucherInfo() { - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - sendNote = notes.getNoteTxs(0).getNote(); - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(notes.getNoteTxs(0).getTxid().toByteArray())); - outPointBuild.setIndex(notes.getNoteTxs(0).getIndex()); - request.addOutPoints(outPointBuild.build()); - firstMerkleVoucherInfo = blockingStubFull - .getMerkleTreeVoucherInfo(request.build()); - } - - - @Test(enabled = true, description = "Shield to shield transaction") - public void test2Shield2ShieldTransaction() { - receiverShieldAddressInfo = PublicMethed.generateShieldAddress(); - receiverShieldAddress = receiverShieldAddressInfo.get().getAddress(); - - shieldOutList.clear(); - ; - memo = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, receiverShieldAddress, - "" + (sendNote.getValue() - zenTokenFee), memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(receiverShieldAddressInfo, blockingStubFull); - receiverNote = notes.getNoteTxs(0).getNote(); - logger.info("Receiver note:" + receiverNote.toString()); - Assert.assertTrue(receiverNote.getValue() == sendNote.getValue() - zenTokenFee); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Scan note by ivk and scan not by ivk on FullNode") - public void test3ScanNoteByIvkAndOvk() { - //Scan sender note by ovk equals scan receiver note by ivk on FullNode - Note scanNoteByIvk = PublicMethed - .getShieldNotesByIvk(receiverShieldAddressInfo, blockingStubFull).getNoteTxs(0).getNote(); - Note scanNoteByOvk = PublicMethed - .getShieldNotesByOvk(sendShieldAddressInfo, blockingStubFull).getNoteTxs(0).getNote(); - Assert.assertEquals(scanNoteByIvk.getValue(), scanNoteByOvk.getValue()); - Assert.assertEquals(scanNoteByIvk.getMemo(), scanNoteByOvk.getMemo()); - Assert.assertEquals(scanNoteByIvk.getRcm(), scanNoteByOvk.getRcm()); - Assert.assertEquals(scanNoteByIvk.getPaymentAddress(), scanNoteByOvk.getPaymentAddress()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Scan note by ivk and scan not by ivk on solidity") - public void test4ScanNoteByIvkAndOvkOnSolidityServer() { - - //Scan sender note by ovk equals scan receiver note by ivk in Solidity - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity); - Note scanNoteByIvk = PublicMethed - .getShieldNotesByIvkOnSolidity(receiverShieldAddressInfo, blockingStubSolidity) - .getNoteTxs(0).getNote(); - Note scanNoteByOvk = PublicMethed - .getShieldNotesByOvkOnSolidity(sendShieldAddressInfo, blockingStubSolidity) - .getNoteTxs(0).getNote(); - Assert.assertEquals(scanNoteByIvk.getValue(), scanNoteByOvk.getValue()); - Assert.assertEquals(scanNoteByIvk.getMemo(), scanNoteByOvk.getMemo()); - Assert.assertEquals(scanNoteByIvk.getRcm(), scanNoteByOvk.getRcm()); - Assert.assertEquals(scanNoteByIvk.getPaymentAddress(), scanNoteByOvk.getPaymentAddress()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Scan note by ivk and scan not by ivk on solidity") - public void test5ScanNoteByIvkAndOvkOnSolidityServer() { - //Scan sender note by ovk equals scan receiver note by ivk in Solidity - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity1); - Note scanNoteByIvk = PublicMethed - .getShieldNotesByIvkOnSolidity(receiverShieldAddressInfo, blockingStubSolidity1) - .getNoteTxs(0).getNote(); - Note scanNoteByOvk = PublicMethed - .getShieldNotesByOvkOnSolidity(sendShieldAddressInfo, blockingStubSolidity1) - - .getNoteTxs(0).getNote(); - Assert.assertEquals(scanNoteByIvk.getValue(), scanNoteByOvk.getValue()); - Assert.assertEquals(scanNoteByIvk.getMemo(), scanNoteByOvk.getMemo()); - Assert.assertEquals(scanNoteByIvk.getRcm(), scanNoteByOvk.getRcm()); - Assert.assertEquals(scanNoteByIvk.getPaymentAddress(), scanNoteByOvk.getPaymentAddress()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Query whether note is spend on solidity") - public void test6QueryNoteIsSpendOnSolidity() { - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - //Scan sender note by ovk equals scan receiver note by ivk in Solidity - Assert.assertTrue(PublicMethed.getSpendResult(sendShieldAddressInfo.get(), - notes.getNoteTxs(0), blockingStubFull).getResult()); - Assert.assertTrue(PublicMethed.getSpendResultOnSolidity(sendShieldAddressInfo.get(), - notes.getNoteTxs(0), blockingStubSolidity).getResult()); - Assert.assertTrue(PublicMethed.getSpendResultOnSolidity(sendShieldAddressInfo.get(), - notes.getNoteTxs(0), blockingStubSolidity1).getResult()); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Query note and spend status on fullnode and solidity") - public void test7QueryNoteAndSpendStatusOnFullnode() { - Assert.assertFalse( - PublicMethed.getShieldNotesAndMarkByIvk(receiverShieldAddressInfo, blockingStubFull) - .getNoteTxs(0).getIsSpend()); - Note scanNoteByIvk = PublicMethed - .getShieldNotesByIvk(receiverShieldAddressInfo, blockingStubFull) - .getNoteTxs(0).getNote(); - Assert.assertEquals(scanNoteByIvk, - PublicMethed.getShieldNotesAndMarkByIvk(receiverShieldAddressInfo, blockingStubFull) - .getNoteTxs(0).getNote()); - - Assert.assertFalse(PublicMethed - .getShieldNotesAndMarkByIvkOnSolidity(receiverShieldAddressInfo, blockingStubSolidity) - .getNoteTxs(0).getIsSpend()); - scanNoteByIvk = PublicMethed - .getShieldNotesByIvkOnSolidity(receiverShieldAddressInfo, blockingStubSolidity) - .getNoteTxs(0).getNote(); - Assert.assertEquals(scanNoteByIvk, PublicMethed - .getShieldNotesAndMarkByIvkOnSolidity(receiverShieldAddressInfo, blockingStubSolidity) - .getNoteTxs(0).getNote()); - - shieldOutList.clear(); - memo = "Query note and spend status on fullnode " + System.currentTimeMillis(); - notes = PublicMethed.listShieldNote(receiverShieldAddressInfo, blockingStubFull); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + (notes.getNoteTxs(0).getNote().getValue() - zenTokenFee), memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - receiverShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity); - - Assert.assertTrue( - PublicMethed.getShieldNotesAndMarkByIvk(receiverShieldAddressInfo, blockingStubFull) - .getNoteTxs(0).getIsSpend()); - - Assert.assertTrue(PublicMethed - .getShieldNotesAndMarkByIvkOnSolidity(receiverShieldAddressInfo, blockingStubSolidity) - .getNoteTxs(0).getIsSpend()); - } - - @Test(enabled = true, description = "Get merkle tree voucher info") - public void test8GetMerkleTreeVoucherInfo() { - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - sendNote = notes.getNoteTxs(0).getNote(); - OutputPointInfo.Builder request = OutputPointInfo.newBuilder(); - - //ShieldNoteInfo noteInfo = shieldWrapper.getUtxoMapNote().get(shieldInputList.get(i)); - OutputPoint.Builder outPointBuild = OutputPoint.newBuilder(); - outPointBuild.setHash(ByteString.copyFrom(notes.getNoteTxs(0).getTxid().toByteArray())); - outPointBuild.setIndex(notes.getNoteTxs(0).getIndex()); - request.addOutPoints(outPointBuild.build()); - secondMerkleVoucherInfo = blockingStubFull - .getMerkleTreeVoucherInfo(request.build()); - - Assert.assertEquals(firstMerkleVoucherInfo, secondMerkleVoucherInfo); - } - - - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity1 != null) { - channelSolidity1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken003.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken003.java deleted file mode 100644 index db07473ee97..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken003.java +++ /dev/null @@ -1,474 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - -@Slf4j -public class WalletTestZenToken003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - Note note; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 10 * zenTokenFee; - private String txid; - private Optional infoById; - private Optional byId; - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverPublicAddress = ecKey2.getAddress(); - String receiverPublicKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - } - - @Test(enabled = true, description = "Public to two shield transaction") - public void test1Public2ShieldTransaction() { - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - Optional shieldAddressInfo2 = PublicMethed.generateShieldAddress(); - String shieldAddress2 = shieldAddressInfo2.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - logger.info("shieldAddress2:" + shieldAddress2); - - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long beforeNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull).getFreeNetUsed(); - - Long sendToShiledAddress1Amount = 3 * zenTokenFee; - Long sendToShiledAddress2Amount = costTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - String memo1 = "Public to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - String memo2 = "Public to shield address2 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - txid = PublicMethed.sendShieldCoinGetTxid( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getShieldedTransactionFee() == zenTokenFee); - byId = PublicMethed.getTransactionById(txid, blockingStubFull); - Assert.assertTrue(byId.get().getSignatureCount() == 1); - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long afterNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull) - .getFreeNetUsed(); - logger.info("beforeAssetBalance:" + beforeAssetBalance); - logger.info("afterAssetBalance:" + afterAssetBalance); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == costTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - notes = PublicMethed.listShieldNote(shieldAddressInfo1, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - logger.info("receiverShieldTokenAmount1:" + receiverShieldTokenAmount1); - logger.info("sendToShiledAddress1Amount:" + sendToShiledAddress1Amount); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - notes = PublicMethed.listShieldNote(shieldAddressInfo2, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount2 = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount2, sendToShiledAddress2Amount); - Assert.assertEquals(memo2, PublicMethed.getMemo(note)); - - } - - @Test(enabled = true, description = "Public to one public and one shield transaction") - public void test2Public2OneShieldAndOnePublicTransaction() { - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long beforeNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull).getFreeNetUsed(); - - final Long beforeBalance = PublicMethed - .queryAccount(receiverPublicAddress,blockingStubFull).getBalance(); - Long sendToShiledAddress1Amount = 1 * zenTokenFee; - Long sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - shieldOutList.clear(); - String memo1 = "Public to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - - txid = PublicMethed.sendShieldCoinGetTxid( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, - zenTokenOwnerKey, blockingStubFull); - logger.info("txid:" + txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getShieldedTransactionFee() == zenTokenFee); - byId = PublicMethed.getTransactionById(txid, blockingStubFull); - Assert.assertTrue(byId.get().getSignatureCount() == 1); - - - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long afterNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull) - .getFreeNetUsed(); - final Long afterBalance = PublicMethed - .queryAccount(receiverPublicAddress,blockingStubFull).getBalance(); - logger.info("beforeAssetBalance:" + beforeAssetBalance); - logger.info("afterAssetBalance:" + afterAssetBalance); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == costTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - Assert.assertTrue(beforeBalance - afterBalance == 0); - - notes = PublicMethed.listShieldNote(shieldAddressInfo1, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - logger.info("receiverShieldTokenAmount1:" + receiverShieldTokenAmount1); - logger.info("sendToShiledAddress1Amount:" + sendToShiledAddress1Amount); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - Long afterReceiverPublicAssetBalance = PublicMethed.getAssetIssueValue(receiverPublicAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Assert.assertEquals(afterReceiverPublicAssetBalance, sendToPublicAddressAmount); - } - - @Test(enabled = true, description = "Public to one public and two shield transaction") - public void test3Public2OneShieldAndOnePublicTransaction() { - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - Optional shieldAddressInfo2 = PublicMethed.generateShieldAddress(); - String shieldAddress2 = shieldAddressInfo2.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - logger.info("shieldAddress2:" + shieldAddress2); - - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long beforeNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull).getFreeNetUsed(); - - Long sendToShiledAddress1Amount = 1 * zenTokenFee; - Long sendToShiledAddress2Amount = 2 * zenTokenFee; - final Long sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - - sendToShiledAddress2Amount - zenTokenFee; - shieldOutList.clear(); - String memo1 = "Public to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - String memo2 = "Public to shield address2 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - final Long beforeReceiverPublicAssetBalance = PublicMethed - .getAssetIssueValue(receiverPublicAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - - txid = PublicMethed.sendShieldCoinGetTxid( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, - zenTokenOwnerKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getShieldedTransactionFee() == zenTokenFee); - byId = PublicMethed.getTransactionById(txid, blockingStubFull); - Assert.assertTrue(byId.get().getSignatureCount() == 1); - - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long afterNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull) - .getFreeNetUsed(); - logger.info("beforeAssetBalance:" + beforeAssetBalance); - logger.info("afterAssetBalance:" + afterAssetBalance); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == costTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - - notes = PublicMethed.listShieldNote(shieldAddressInfo1, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - notes = PublicMethed.listShieldNote(shieldAddressInfo2, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount2 = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount2, sendToShiledAddress2Amount); - Assert.assertEquals(memo2, PublicMethed.getMemo(note)); - - Long afterReceiverPublicAssetBalance = PublicMethed.getAssetIssueValue(receiverPublicAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Assert.assertTrue(afterReceiverPublicAssetBalance - - beforeReceiverPublicAssetBalance == sendToPublicAddressAmount); - } - - @Test(enabled = true, description = "Public to one smart contract and one shield transaction") - public void test4Public2OneShieldAndOneSmartContractAddressTransaction() { - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long beforeNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull).getFreeNetUsed(); - - final Long beforeBalance = PublicMethed - .queryAccount(receiverPublicAddress,blockingStubFull).getBalance(); - Long sendToShiledAddress1Amount = 1 * zenTokenFee; - - shieldOutList.clear(); - String memo1 = "Public to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - - String contractName = "tokenBalanceContract"; - String code = "608060405260ff806100126000396000f30060806040526" - + "004361060485763ffffffff7c010000000000000" - + "0000000000000000000000000000000000000000000600035041663a730416e8114604d578063b69ef8a8146" - + "081575b600080fd5b606f73ffffffffffffffffffffffffffffffffffffffff6004351660243560ab565b604" - + "08051918252519081900360200190f35b348015608c57600080fd5b50d38015609857600080fd5b50d280156" - + "0a457600080fd5b50606f60cd565b73ffffffffffffffffffffffffffffffffffffffff90911690d16000908" - + "15590565b600054815600a165627a7a723058202b6235122df66c062c2e723ad58a9fea93346f3bc19898971" - + "8f211aa1dbd2d7a0029"; - String abi = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}," - + "{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":" - + "[{\"name\":\"b\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":" - + "\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":" - + "\"balance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false," - + "\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true," - + "\"stateMutability\":\"payable\",\"type\":\"constructor\"}]"; - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 100, null, testKey002, fromAddress, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - logger.info(txid); - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - com.google.protobuf.ByteString contractAddress = infoById.get().getContractAddress(); - SmartContract smartContract = PublicMethed - .getContract(contractAddress.toByteArray(), blockingStubFull); - org.junit.Assert.assertTrue(smartContract.getAbi() != null); - Long sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - txid = PublicMethed.sendShieldCoinGetTxid( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - contractAddress.toByteArray(), sendToPublicAddressAmount, - zenTokenOwnerKey, blockingStubFull); - logger.info("txid:" + txid); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getShieldedTransactionFee() == zenTokenFee); - byId = PublicMethed.getTransactionById(txid, blockingStubFull); - Assert.assertTrue(byId.get().getSignatureCount() == 1); - - - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long afterNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull) - .getFreeNetUsed(); - final Long afterBalance = PublicMethed - .queryAccount(receiverPublicAddress,blockingStubFull).getBalance(); - logger.info("beforeAssetBalance:" + beforeAssetBalance); - logger.info("afterAssetBalance:" + afterAssetBalance); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == costTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - Assert.assertTrue(beforeBalance - afterBalance == 0); - - notes = PublicMethed.listShieldNote(shieldAddressInfo1, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - logger.info("receiverShieldTokenAmount1:" + receiverShieldTokenAmount1); - logger.info("sendToShiledAddress1Amount:" + sendToShiledAddress1Amount); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - Long afterReceiverPublicAssetBalance = PublicMethed - .getAssetIssueValue(contractAddress.toByteArray(), - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Assert.assertEquals(afterReceiverPublicAssetBalance, sendToPublicAddressAmount); - } - - - @Test(enabled = true, description = "Public to two same shield address") - public void test5Public2TwoSameShieldAddress() { - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - - logger.info("shieldAddress1:" + shieldAddress1); - - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long beforeNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull).getFreeNetUsed(); - - Long sendToShiledAddress1Amount = 3 * zenTokenFee; - Long sendToShiledAddress2Amount = costTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - shieldOutList.clear(); - String memo1 = "First public to shield same address transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - String memo2 = "Second public to shield same address transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress2Amount, memo2); - txid = PublicMethed.sendShieldCoinGetTxid( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getShieldedTransactionFee() == zenTokenFee); - byId = PublicMethed.getTransactionById(txid, blockingStubFull); - Assert.assertTrue(byId.get().getSignatureCount() == 1); - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long afterNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull) - .getFreeNetUsed(); - logger.info("beforeAssetBalance:" + beforeAssetBalance); - logger.info("afterAssetBalance:" + afterAssetBalance); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == costTokenAmount); - Assert.assertTrue(beforeNetUsed == afterNetUsed); - notes = PublicMethed.getShieldNotesByIvk(shieldAddressInfo1, blockingStubFull); - Assert.assertTrue(notes.getNoteTxsCount() == 2); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - logger.info("receiverShieldTokenAmount1:" + receiverShieldTokenAmount1); - logger.info("sendToShiledAddress1Amount:" + sendToShiledAddress1Amount); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - note = notes.getNoteTxs(1).getNote(); - Long receiverShieldTokenAmount2 = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount2, sendToShiledAddress2Amount); - Assert.assertEquals(memo2, PublicMethed.getMemo(note)); - - } - - - - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken004.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken004.java deleted file mode 100644 index 1d5b770036d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken004.java +++ /dev/null @@ -1,291 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - -@Slf4j -public class WalletTestZenToken004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - Note note; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 10 * zenTokenFee; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverPublicAddress = ecKey2.getAddress(); - String receiverPublicKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Optional sendShieldAddressInfo; - String sendshieldAddress; - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - Assert.assertTrue(PublicMethed.sendcoin(receiverPublicAddress, 1000000L, - fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Shield to two shield transaction") - public void test1Shield2TwoShieldTransaction() { - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendshieldAddress = sendShieldAddressInfo.get().getAddress(); - String memo = "Use to TestZenToken004 shield address"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendshieldAddress, - "" + costTokenAmount, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - foundationZenTokenAddress, costTokenAmount + zenTokenFee, - null, null, - shieldOutList, - null, 0, - foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - Optional shieldAddressInfo2 = PublicMethed.generateShieldAddress(); - String shieldAddress2 = shieldAddressInfo2.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - logger.info("shieldAddress2:" + shieldAddress2); - - Long sendToShiledAddress1Amount = 3 * zenTokenFee; - Long sendToShiledAddress2Amount = costTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - String memo1 = "Shield to shield address1 transaction"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - String memo2 = "Shield to shield address2 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - Assert.assertTrue(PublicMethed.getSpendResult(sendShieldAddressInfo.get(), - notes.getNoteTxs(0), blockingStubFull).getResult()); - - notes = PublicMethed.listShieldNote(shieldAddressInfo1, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - logger.info("receiverShieldTokenAmount1:" + receiverShieldTokenAmount1); - logger.info("sendToShiledAddress1Amount:" + sendToShiledAddress1Amount); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - notes = PublicMethed.listShieldNote(shieldAddressInfo2, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount2 = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount2, sendToShiledAddress2Amount); - Assert.assertEquals(memo2, PublicMethed.getMemo(note)); - - } - - @Test(enabled = true, description = "Shield to one public and one shield transaction") - public void test2Shield2OneShieldAndOnePublicTransaction() { - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendshieldAddress = sendShieldAddressInfo.get().getAddress(); - String memo = "Use to TestZenToken004 shield address"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendshieldAddress, - "" + costTokenAmount, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - foundationZenTokenAddress, costTokenAmount + zenTokenFee, - null, null, - shieldOutList, - null, 0, - foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - - Long sendToShiledAddress1Amount = 1 * zenTokenFee; - Long sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - zenTokenFee; - shieldOutList.clear(); - String memo1 = "Shield to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - Assert.assertTrue(PublicMethed.getSpendResult(sendShieldAddressInfo.get(), - notes.getNoteTxs(0), blockingStubFull).getResult()); - - notes = PublicMethed.listShieldNote(shieldAddressInfo1, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - logger.info("receiverShieldTokenAmount1:" + receiverShieldTokenAmount1); - logger.info("sendToShiledAddress1Amount:" + sendToShiledAddress1Amount); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - Long afterReceiverPublicAssetBalance = PublicMethed.getAssetIssueValue(receiverPublicAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Assert.assertEquals(afterReceiverPublicAssetBalance, sendToPublicAddressAmount); - } - - @Test(enabled = true, description = "Shield to one public and two shield transaction") - public void test3Public2OneShieldAndOnePublicTransaction() { - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendshieldAddress = sendShieldAddressInfo.get().getAddress(); - String memo = "Use to TestZenToken004 shield address"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendshieldAddress, - "" + costTokenAmount, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - foundationZenTokenAddress, costTokenAmount + zenTokenFee, - null, null, - shieldOutList, - null, 0, - foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - Optional shieldAddressInfo2 = PublicMethed.generateShieldAddress(); - String shieldAddress2 = shieldAddressInfo2.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - logger.info("shieldAddress2:" + shieldAddress2); - - Long sendToShiledAddress1Amount = 3 * zenTokenFee; - Long sendToShiledAddress2Amount = 4 * zenTokenFee; - final Long sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - - sendToShiledAddress2Amount - zenTokenFee; - shieldOutList.clear(); - String memo1 = "Shield to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - String memo2 = "Shield to shield address2 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - final Long beforeReceiverPublicAssetBalance = PublicMethed - .getAssetIssueValue(receiverPublicAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - Assert.assertTrue(PublicMethed.getSpendResult(sendShieldAddressInfo.get(), - notes.getNoteTxs(0), blockingStubFull).getResult()); - - notes = PublicMethed.listShieldNote(shieldAddressInfo1, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount1 = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount1, sendToShiledAddress1Amount); - Assert.assertEquals(memo1, PublicMethed.getMemo(note)); - - notes = PublicMethed.listShieldNote(shieldAddressInfo2, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount2 = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount2, sendToShiledAddress2Amount); - Assert.assertEquals(memo2, PublicMethed.getMemo(note)); - - final Long afterReceiverPublicAssetBalance = PublicMethed - .getAssetIssueValue(receiverPublicAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Assert.assertTrue(afterReceiverPublicAssetBalance - beforeReceiverPublicAssetBalance - == sendToPublicAddressAmount); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken005.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken005.java deleted file mode 100644 index d9970bf8ce4..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken005.java +++ /dev/null @@ -1,219 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - -@Slf4j -public class WalletTestZenToken005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - Note note; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 10 * zenTokenFee; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiverPublicAddress = ecKey2.getAddress(); - String receiverPublicKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(receiverPublicAddress, 1000000L, - fromAddress, testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - } - - @Test(enabled = true, description = "The receiver shield address can't more then 2") - public void test1ReceiverShieldAddressCanNotMoreThenTwo() { - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - Optional shieldAddressInfo2 = PublicMethed.generateShieldAddress(); - String shieldAddress2 = shieldAddressInfo2.get().getAddress(); - Optional shieldAddressInfo3 = PublicMethed.generateShieldAddress(); - String shieldAddress3 = shieldAddressInfo3.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - logger.info("shieldAddress2:" + shieldAddress2); - logger.info("shieldAddress3:" + shieldAddress3); - - Long sendToShiledAddress1Amount = 3 * zenTokenFee; - Long sendToShiledAddress2Amount = 2 * zenTokenFee; - Long sendToShiledAddress3Amount = costTokenAmount - sendToShiledAddress1Amount - - sendToShiledAddress2Amount - zenTokenFee; - String memo1 = "Shield to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - String memo2 = "Shield to shield address2 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - String memo3 = "Shield to shield address3 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress3, - "" + sendToShiledAddress3Amount, memo3); - - Assert.assertFalse(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - } - - @Test(enabled = true, description = "The receiver can't only one public address") - public void test2ReceiverPublicCanNotOnlyOnePublic() { - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - shieldOutList.clear(); - Assert.assertFalse(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - receiverPublicAddress, costTokenAmount - zenTokenFee, - zenTokenOwnerKey, blockingStubFull)); - } - - @Test(enabled = true, description = "Public send amount must equal receiver amount + shieldFee") - public void test3SendAmountMustEqualReceiverAmountPlusShieldFee() { - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional shieldAddressInfo1 = PublicMethed.generateShieldAddress(); - String shieldAddress1 = shieldAddressInfo1.get().getAddress(); - Optional shieldAddressInfo2 = PublicMethed.generateShieldAddress(); - String shieldAddress2 = shieldAddressInfo2.get().getAddress(); - logger.info("shieldAddress1:" + shieldAddress1); - logger.info("shieldAddress2:" + shieldAddress2); - - Long sendToShiledAddress1Amount = 1 * zenTokenFee; - Long sendToShiledAddress2Amount = 2 * zenTokenFee; - - shieldOutList.clear(); - String memo1 = "Public to shield address1 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - String memo2 = "Public to shield address2 transaction"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - - //Public receiver amount is wrong - Long sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - - sendToShiledAddress2Amount - zenTokenFee; - Assert.assertFalse(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount - 1, - zenTokenOwnerKey, blockingStubFull)); - - //Shield receiver amount is wrong - sendToShiledAddress1Amount = 1 * zenTokenFee; - sendToShiledAddress2Amount = 2 * zenTokenFee; - sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - - sendToShiledAddress2Amount - zenTokenFee; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + (sendToShiledAddress1Amount - 1), memo1); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - Assert.assertFalse(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, - zenTokenOwnerKey, blockingStubFull)); - - sendToShiledAddress1Amount = 1 * zenTokenFee; - sendToShiledAddress2Amount = 2 * zenTokenFee; - sendToPublicAddressAmount = costTokenAmount - sendToShiledAddress1Amount - - sendToShiledAddress2Amount - zenTokenFee; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress1, - "" + sendToShiledAddress1Amount, memo1); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress2, - "" + sendToShiledAddress2Amount, memo2); - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, costTokenAmount, - null, null, - shieldOutList, - receiverPublicAddress, sendToPublicAddressAmount, - zenTokenOwnerKey, blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken006.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken006.java deleted file mode 100644 index 0e6e109d8c2..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken006.java +++ /dev/null @@ -1,273 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - -@Slf4j -public class WalletTestZenToken006 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional shieldAddressInfo; - String shieldAddress; - List shieldOutList = new ArrayList<>(); - List shieldInputList = new ArrayList<>(); - DecryptNotes notes; - String memo; - Note note; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 10 * zenTokenFee; - private Long sendTokenAmount = 3 * zenTokenFee; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - } - - @Test(enabled = true, description = "Shield note memo is one char") - public void test1ShieldMemoIsOneChar() { - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - logger.info("shieldAddress:" + shieldAddress); - - //One char. - memo = "."; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + zenTokenFee, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, zenTokenFee * 2, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount, zenTokenFee); - Assert.assertEquals(memo, PublicMethed.getMemo(note)); - } - - @Test(enabled = true, description = "Shield note memo is 512 char") - public void test2ShieldMemoIs512Char() { - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - logger.info("shieldAddress:" + shieldAddress); - - //512 char. - memo = "1234567812345678123456781234567812345678123456781234567812345678123456781234567812" - + "345678123456781234567812345678123456781234567812345678123456781234567812345678123456" - + "781234567812345678123456781234567812345678123456781234567812345678123456781234567812" - + "345678123456781234567812345678123456781234567812345678123456781234567812345678123456" - + "781234567812345678123456781234567812345678123456781234567812345678123456781234567812" - + "345678123456781234567812345678123456781234567812345678123456781234567812345678123456" - + "7812345678"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + zenTokenFee, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, zenTokenFee * 2, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount, zenTokenFee); - Assert.assertEquals(memo, PublicMethed.getMemo(note)); - - Assert.assertFalse(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, zenTokenFee * 2, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - } - - @Test(enabled = true, description = "Shield note memo is 514 char") - public void test3ShieldMemoIs513Char() { - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - logger.info("shieldAddress:" + shieldAddress); - - //514 char. - memo = "-1234567812345678123456781234567812345678123456781234567812345678123456781234567812" - + "345678123456781234567812345678123456781234567812345678123456781234567812345678123456" - + "781234567812345678123456781234567812345678123456781234567812345678123456781234567812" - + "345678123456781234567812345678123456781234567812345678123456781234567812345678123456" - + "781234567812345678123456781234567812345678123456781234567812345678123456781234567812" - + "345678123456781234567812345678123456781234567812345678123456781234567812345678123456" - + "7812345678"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + zenTokenFee, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, zenTokenFee * 2, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount, zenTokenFee); - logger.info(PublicMethed.getMemo(note)); - Assert.assertTrue(PublicMethed.getMemo(note).length() == 512); - Assert.assertEquals(PublicMethed.getMemo(note),memo.substring(0,512)); - } - - @Test(enabled = true, description = "Shield note memo is empty") - public void test4ShieldMemoIsEmpty() { - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - logger.info("shieldAddress:" + shieldAddress); - - //Empty memo - memo = ""; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + zenTokenFee, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, 2 * zenTokenFee, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount, zenTokenFee); - Assert.assertEquals(memo, PublicMethed.getMemo(note)); - - //Shield send to it self - memo = ""; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "0", memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - shieldAddressInfo.get(), - PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull).getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - } - - - @Test(enabled = true, description = "Shield note memo is empty") - public void test5ShieldMemoIsEmpty() { - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - logger.info("shieldAddress:" + shieldAddress); - - memo = "{\n" - + " note {\n" - + " value: 49957\n" - + " payment_address: \"ztron1f42n7h0l3p8mlaq0d0rxdkhq" - + "n6xuq49xhvj593wfduy24kn3xrmxfpqt8lnmh9ysnu5nzt3zgzx\"\n" - + " rcm: \"\\210x\\256\\211\\256v\\0344\\267\\240\\375\\377xs\\3" - + "50\\3558^Y\\200i0$S\\312KK\\326l\\234J\\b\"\n" - + " memo: \"System.exit(1);\"\n" - + " }\n" - + " txid: \"\\215\\332\\304\\241\\362\\vbt\\250\\364\\353\\30" - + "7\\'o\\275\\313ya*)\\320>\\001\\262B%\\371\\'\\005w\\354\\200\"\n" - + "}"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + zenTokenFee, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - zenTokenOwnerAddress, 2 * zenTokenFee, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount = note.getValue(); - Assert.assertEquals(receiverShieldTokenAmount, zenTokenFee); - Assert.assertEquals(memo, PublicMethed.getMemo(note)); - - - } - - - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken007.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken007.java deleted file mode 100644 index 11191c4da7d..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken007.java +++ /dev/null @@ -1,645 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.DiversifierMessage; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ExpandedSpendingKeyMessage; -import org.tron.api.GrpcAPI.IncomingViewingKeyDiversifierMessage; -import org.tron.api.GrpcAPI.IncomingViewingKeyMessage; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.GrpcAPI.PaymentAddressMessage; -import org.tron.api.GrpcAPI.ViewingKeyMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import org.tron.core.zen.address.DiversifierT; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - -@Slf4j -public class WalletTestZenToken007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional sendShieldAddressInfo1; - Optional sendShieldAddressInfo2; - Optional sendShieldAddressInfo3; - Optional receiverShieldAddressInfo; - String sendShieldAddress1; - String sendShieldAddress2; - String sendShieldAddress3; - String receiverShieldAddress1; - String receiverShieldAddress2; - String receiverShieldAddress3; - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - String memo1; - String memo2; - String memo3; - Note sendNote1; - Note sendNote2; - Note sendNote3; - Note receiverNote1; - Note receiverNote2; - Note receiverNote3; - private static ByteString assetAccountId = null; - BytesMessage ak; - BytesMessage nk; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private ManagedChannel channelSolidity1 = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity1 = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - private String soliditynode1 = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 10 * zenTokenFee; - private Long sendTokenAmount = 8 * zenTokenFee; - BytesMessage sk; - ExpandedSpendingKeyMessage expandedSpendingKeyMessage; - DiversifierMessage diversifierMessage1; - DiversifierMessage diversifierMessage2; - DiversifierMessage diversifierMessage3; - IncomingViewingKeyMessage ivk; - ShieldAddressInfo addressInfo1 = new ShieldAddressInfo(); - ShieldAddressInfo addressInfo2 = new ShieldAddressInfo(); - ShieldAddressInfo addressInfo3 = new ShieldAddressInfo(); - - Optional receiverAddressInfo1; - Optional receiverAddressInfo2; - Optional receiverAddressInfo3; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress1 = ecKey1.getAddress(); - String zenTokenOwnerKey1 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress2 = ecKey2.getAddress(); - String zenTokenOwnerKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress3 = ecKey3.getAddress(); - String zenTokenOwnerKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress4 = ecKey4.getAddress(); - String zenTokenOwnerKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey1); - PublicMethed.printAddress(zenTokenOwnerKey2); - PublicMethed.printAddress(zenTokenOwnerKey3); - PublicMethed.printAddress(zenTokenOwnerKey4); - channelFull = ManagedChannelBuilder.forTarget(fullnode).usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - channelSolidity1 = ManagedChannelBuilder.forTarget(soliditynode1) - .usePlaintext(true) - .build(); - blockingStubSolidity1 = WalletSolidityGrpc.newBlockingStub(channelSolidity1); - - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress1, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress2, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress3, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress4, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - sendShieldAddressInfo1 = PublicMethed.generateShieldAddress(); - sendShieldAddressInfo2 = PublicMethed.generateShieldAddress(); - sendShieldAddressInfo3 = PublicMethed.generateShieldAddress(); - sendShieldAddress1 = sendShieldAddressInfo1.get().getAddress(); - sendShieldAddress2 = sendShieldAddressInfo2.get().getAddress(); - sendShieldAddress3 = sendShieldAddressInfo3.get().getAddress(); - logger.info("sendShieldAddressInfo1:" + sendShieldAddressInfo1); - logger.info("sendShieldAddressInfo2:" + sendShieldAddressInfo2); - logger.info("sendShieldAddressInfo3:" + sendShieldAddressInfo3); - memo1 = "Shield memo1 in " + System.currentTimeMillis(); - memo2 = "Shield memo2 in " + System.currentTimeMillis(); - memo3 = "Shield memo3 in " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress1, - "" + (sendTokenAmount - zenTokenFee),memo1); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress1,sendTokenAmount,null, - null,shieldOutList,null,0,zenTokenOwnerKey1,blockingStubFull)); - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress2, - "" + (sendTokenAmount - zenTokenFee),memo2); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress2,sendTokenAmount,null, - null,shieldOutList,null,0,zenTokenOwnerKey2,blockingStubFull)); - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress3, - "" + (sendTokenAmount - zenTokenFee),memo3); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress3,sendTokenAmount,null, - null,shieldOutList,null,0,zenTokenOwnerKey3,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo1,blockingStubFull); - sendNote1 = notes.getNoteTxs(0).getNote(); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo2,blockingStubFull); - sendNote2 = notes.getNoteTxs(0).getNote(); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo3,blockingStubFull); - sendNote3 = notes.getNoteTxs(0).getNote(); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get spending key") - public void test01GetSpendingKey() { - sk = blockingStubFull.getSpendingKey(EmptyMessage.newBuilder().build()); - logger.info("sk: " + ByteArray.toHexString(sk.getValue().toByteArray())); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get diversifier") - public void test02GetDiversifier() { - diversifierMessage1 = blockingStubFull.getDiversifier(EmptyMessage.newBuilder().build()); - logger.info("d1: " + ByteArray.toHexString(diversifierMessage1.getD().toByteArray())); - diversifierMessage2 = blockingStubFull.getDiversifier(EmptyMessage.newBuilder().build()); - logger.info("d2: " + ByteArray.toHexString(diversifierMessage2.getD().toByteArray())); - diversifierMessage3 = blockingStubFull.getDiversifier(EmptyMessage.newBuilder().build()); - logger.info("d3: " + ByteArray.toHexString(diversifierMessage3.getD().toByteArray())); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get expanded spending key") - public void test03GetExpandedSpendingKey() { - expandedSpendingKeyMessage = blockingStubFull.getExpandedSpendingKey(sk); - logger.info("ask: " + ByteArray.toHexString(expandedSpendingKeyMessage.getAsk().toByteArray())); - logger.info("nsk: " + ByteArray.toHexString(expandedSpendingKeyMessage.getNsk().toByteArray())); - logger.info("ovk: " + ByteArray.toHexString(expandedSpendingKeyMessage.getOvk().toByteArray())); - - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get AK from ASK") - public void test04GetAkFromAsk() { - BytesMessage.Builder askBuilder = BytesMessage.newBuilder(); - askBuilder.setValue(expandedSpendingKeyMessage.getAsk()); - ak = blockingStubFull.getAkFromAsk(askBuilder.build()); - logger.info("ak: " + ByteArray.toHexString(ak.getValue().toByteArray())); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get Nk from Nsk") - public void test05GetNkFromNsk() { - BytesMessage.Builder nskBuilder = BytesMessage.newBuilder(); - nskBuilder.setValue(expandedSpendingKeyMessage.getNsk()); - nk = blockingStubFull.getNkFromNsk(nskBuilder.build()); - logger.info("nk: " + ByteArray.toHexString(nk.getValue().toByteArray())); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get incoming viewing Key") - public void test06GetIncomingViewingKey() { - ViewingKeyMessage.Builder viewBuilder = ViewingKeyMessage.newBuilder(); - viewBuilder.setAk(ak.getValue()); - viewBuilder.setNk(nk.getValue()); - ivk = blockingStubFull.getIncomingViewingKey(viewBuilder.build()); - logger.info("ivk: " + ByteArray.toHexString(ivk.getIvk().toByteArray())); - } - - /** - * constructor. - */ - @Test(enabled = true, description = "Get Zen Payment Address") - public void test07GetZenPaymentAddress() { - IncomingViewingKeyDiversifierMessage.Builder builder = - IncomingViewingKeyDiversifierMessage.newBuilder(); - builder.setD(diversifierMessage1); - builder.setIvk(ivk); - PaymentAddressMessage addressMessage = blockingStubFull.getZenPaymentAddress(builder.build()); - System.out.println("pkd1: " + ByteArray.toHexString(addressMessage.getPkD().toByteArray())); - System.out.println("address1: " + addressMessage.getPaymentAddress()); - addressInfo1.setSk(sk.getValue().toByteArray()); - addressInfo1.setD(new DiversifierT(diversifierMessage1.getD().toByteArray())); - addressInfo1.setIvk(ivk.getIvk().toByteArray()); - addressInfo1.setOvk(expandedSpendingKeyMessage.getOvk().toByteArray()); - addressInfo1.setPkD(addressMessage.getPkD().toByteArray()); - receiverAddressInfo1 = Optional.of(addressInfo1); - - builder.clear(); - builder = IncomingViewingKeyDiversifierMessage.newBuilder(); - builder.setD(diversifierMessage2); - builder.setIvk(ivk); - addressMessage = blockingStubFull.getZenPaymentAddress(builder.build()); - System.out.println("pkd2: " + ByteArray.toHexString(addressMessage.getPkD().toByteArray())); - System.out.println("address2: " + addressMessage.getPaymentAddress()); - addressInfo2.setSk(sk.getValue().toByteArray()); - addressInfo2.setD(new DiversifierT(diversifierMessage2.getD().toByteArray())); - addressInfo2.setIvk(ivk.getIvk().toByteArray()); - addressInfo2.setOvk(expandedSpendingKeyMessage.getOvk().toByteArray()); - addressInfo2.setPkD(addressMessage.getPkD().toByteArray()); - receiverAddressInfo2 = Optional.of(addressInfo2); - - builder.clear(); - builder = IncomingViewingKeyDiversifierMessage.newBuilder(); - builder.setD(diversifierMessage3); - builder.setIvk(ivk); - addressMessage = blockingStubFull.getZenPaymentAddress(builder.build()); - System.out.println("pkd3: " + ByteArray.toHexString(addressMessage.getPkD().toByteArray())); - System.out.println("address3: " + addressMessage.getPaymentAddress()); - addressInfo3.setSk(sk.getValue().toByteArray()); - addressInfo3.setD(new DiversifierT(diversifierMessage3.getD().toByteArray())); - addressInfo3.setIvk(ivk.getIvk().toByteArray()); - addressInfo3.setOvk(expandedSpendingKeyMessage.getOvk().toByteArray()); - addressInfo3.setPkD(addressMessage.getPkD().toByteArray()); - receiverAddressInfo3 = Optional.of(addressInfo3); - - - } - - @Test(enabled = true, description = "Shield to shield transaction") - public void test08Shield2ShieldTransaction() { - //S to S address1 - receiverShieldAddress1 = receiverAddressInfo1.get().getAddress(); - shieldOutList.clear();; - memo1 = "Send shield to receiver1 shield memo in" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,receiverShieldAddress1, - "" + (sendNote1.getValue() - zenTokenFee),memo1); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo1,blockingStubFull); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null,0, - sendShieldAddressInfo1.get(), notes.getNoteTxs(0), - shieldOutList, - null,0, - zenTokenOwnerKey1,blockingStubFull)); - - //S to S address2 - receiverShieldAddress2 = receiverAddressInfo2.get().getAddress(); - shieldOutList.clear();; - memo2 = "Send shield2 to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,receiverShieldAddress2, - "" + (sendNote2.getValue() - zenTokenFee),memo2); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo2,blockingStubFull); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null,0, - sendShieldAddressInfo2.get(), notes.getNoteTxs(0), - shieldOutList, - null,0, - zenTokenOwnerKey2,blockingStubFull)); - - //S to S address3 - receiverShieldAddress3 = receiverAddressInfo3.get().getAddress(); - shieldOutList.clear();; - memo3 = "Send shield3 to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,receiverShieldAddress3, - "" + (sendNote3.getValue() - zenTokenFee),memo3); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo3,blockingStubFull); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null,0, - sendShieldAddressInfo3.get(), notes.getNoteTxs(0), - shieldOutList, - null,0, - zenTokenOwnerKey3,blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Same sk and different d can produce different - // shield address,the notes can scan out by same ivk. - notes = PublicMethed.getShieldNotesByIvk(receiverAddressInfo1,blockingStubFull); - Assert.assertTrue(notes.getNoteTxsCount() == 3); - - receiverNote1 = notes.getNoteTxs(0).getNote(); - logger.info("Receiver note1:" + receiverNote1.toString()); - Assert.assertTrue(receiverNote1.getValue() == sendNote1.getValue() - zenTokenFee); - receiverNote2 = notes.getNoteTxs(1).getNote(); - logger.info("Receiver note2:" + receiverNote2.toString()); - Assert.assertTrue(receiverNote2.getValue() == sendNote2.getValue() - zenTokenFee); - receiverNote3 = notes.getNoteTxs(2).getNote(); - logger.info("Receiver note3:" + receiverNote3.toString()); - Assert.assertTrue(receiverNote3.getValue() == sendNote3.getValue() - zenTokenFee); - } - - @Test(enabled = true, description = "Shield to shield transaction without ask") - public void test09Shield2ShieldTransactionWithoutAsk() { - //Same sk and different d can produce different shield address, - // the notes can use by scan from same ovk. - sendShieldAddressInfo1 = PublicMethed.generateShieldAddress(); - sendShieldAddress1 = sendShieldAddressInfo1.get().getAddress(); - sendShieldAddressInfo2 = PublicMethed.generateShieldAddress(); - sendShieldAddress2 = sendShieldAddressInfo2.get().getAddress(); - sendShieldAddressInfo3 = PublicMethed.generateShieldAddress(); - sendShieldAddress3 = sendShieldAddressInfo3.get().getAddress(); - - notes = PublicMethed.getShieldNotesByIvk(receiverAddressInfo3,blockingStubFull); - receiverNote1 = notes.getNoteTxs(0).getNote(); - receiverNote2 = notes.getNoteTxs(1).getNote(); - receiverNote3 = notes.getNoteTxs(2).getNote(); - shieldOutList.clear();; - memo1 = "Send shield address 1 without ask" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress1, - "" + (receiverNote1.getValue() - zenTokenFee),memo1); - - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - null,0, - receiverAddressInfo1.get(), notes.getNoteTxs(0), - shieldOutList, - null,0, - zenTokenOwnerKey1,blockingStubFull)); - - shieldOutList.clear();; - memo2 = "Send shield address 2 without ask" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress2, - "" + (receiverNote2.getValue() - zenTokenFee),memo2); - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - null,0, - receiverAddressInfo2.get(), notes.getNoteTxs(1), - shieldOutList, - null,0, - zenTokenOwnerKey2,blockingStubFull)); - - shieldOutList.clear();; - memo3 = "Send shield address 3 without ask" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress3, - "" + (receiverNote3.getValue() - zenTokenFee),memo3); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null,0, - receiverAddressInfo3.get(), notes.getNoteTxs(2), - shieldOutList, - null,0, - zenTokenOwnerKey3,blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - - notes = PublicMethed.getShieldNotesByOvk(receiverAddressInfo3,blockingStubFull); - logger.info("notes count:" + notes.getNoteTxsCount()); - Assert.assertTrue(notes.getNoteTxsCount() == 3); - sendNote1 = notes.getNoteTxs(0).getNote(); - logger.info("Receiver1 note:" + sendNote1.toString()); - Assert.assertTrue(sendNote1.getValue() == receiverNote1.getValue() - zenTokenFee); - Assert.assertEquals(memo1,PublicMethed.getMemo(sendNote1)); - - sendNote2 = notes.getNoteTxs(1).getNote(); - logger.info("Receiver2 note:" + sendNote2.toString()); - Assert.assertTrue(sendNote2.getValue() == receiverNote2.getValue() - zenTokenFee); - Assert.assertEquals(memo2,PublicMethed.getMemo(sendNote2)); - - sendNote3 = notes.getNoteTxs(2).getNote(); - logger.info("Receiver3 note:" + sendNote3.toString()); - Assert.assertTrue(sendNote3.getValue() == receiverNote3.getValue() - zenTokenFee); - Assert.assertEquals(memo3,PublicMethed.getMemo(sendNote3)); - } - - @Test(enabled = true, description = "Get shield Nulltifier") - public void test10GetShieldNulltifier() { - notes = PublicMethed.listShieldNote(sendShieldAddressInfo1,blockingStubFull); - Assert.assertEquals(PublicMethed.getShieldNullifier(sendShieldAddressInfo1.get(), - notes.getNoteTxs(0),blockingStubFull).length(),64); - notes = PublicMethed.listShieldNote(receiverAddressInfo1,blockingStubFull); - Assert.assertEquals(PublicMethed.getShieldNullifier(receiverAddressInfo1.get(), - notes.getNoteTxs(0),blockingStubFull).length(),64); - - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo1.get(), - notes.getNoteTxs(0),blockingStubFull).getResult()); - } - - @Test(enabled = true, description = "Same sk transfer shield address note is spent") - public void test11SameSkTransferShieldAddressNoteCanSpent() { - notes = PublicMethed.getShieldNotesByIvk(receiverAddressInfo2,blockingStubFull); - - receiverNote1 = notes.getNoteTxs(0).getNote(); - shieldOutList.clear(); - memo1 = "Send shield address 1 without ask" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress1, - "" + (receiverNote1.getValue() - zenTokenFee),memo1); - Assert.assertFalse(PublicMethed.sendShieldCoinWithoutAsk( - null,0, - receiverAddressInfo1.get(), notes.getNoteTxs(0), - shieldOutList, - null,0, - zenTokenOwnerKey1,blockingStubFull)); - - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo1.get(), - notes.getNoteTxs(0),blockingStubFull).getResult()); - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo2.get(), - notes.getNoteTxs(1),blockingStubFull).getResult()); - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo3.get(), - notes.getNoteTxs(2),blockingStubFull).getResult()); - } - - @Test(enabled = true, description = "Same sk transfer two shield address," - + "in one transaction send to these shield transaction") - public void test12SameSkTransferTwoShieldAddressInOneTransaction() { - shieldOutList.clear(); - memo1 = "Send to first shield address " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,receiverShieldAddress1, - "" + zenTokenFee,memo1); - memo2 = "Send to second shield address " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,receiverShieldAddress2, - "" + (costTokenAmount - 2 * zenTokenFee),memo2); - logger.info("address1 receiver amount:" + zenTokenFee); - logger.info("address2 receiver amount:" + (costTokenAmount - 2 * zenTokenFee)); - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - zenTokenOwnerAddress4,costTokenAmount, - null, null, - shieldOutList, - null,0, - zenTokenOwnerKey4,blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.getShieldNotesByIvk(receiverAddressInfo2,blockingStubFull); - Assert.assertTrue(notes.getNoteTxsCount() == 5); - Assert.assertTrue(notes.getNoteTxs(3).getNote().getValue() == zenTokenFee); - Assert.assertTrue(notes.getNoteTxs(4).getNote().getValue() - == (costTokenAmount - 2 * zenTokenFee)); - Assert.assertEquals(PublicMethed.getMemo(notes.getNoteTxs(3).getNote()),memo1); - Assert.assertEquals(PublicMethed.getMemo(notes.getNoteTxs(4).getNote()),memo2); - - - - - shieldOutList.clear();; - receiverNote1 = notes.getNoteTxs(3).getNote(); - receiverNote2 = notes.getNoteTxs(4).getNote(); - memo1 = "Send shield address 1 without ask" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress1, - "" + (receiverNote1.getValue() - zenTokenFee),memo1); - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - null,0, - receiverAddressInfo1.get(), notes.getNoteTxs(3), - shieldOutList, - null,0, - zenTokenOwnerKey1,blockingStubFull)); - - shieldOutList.clear();; - memo2 = "Send shield address 2 without ask" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress2, - "" + (receiverNote2.getValue() - zenTokenFee),memo2); - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - null,0, - receiverAddressInfo2.get(), notes.getNoteTxs(4), - shieldOutList, - null,0, - zenTokenOwnerKey2,blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - - - notes = PublicMethed.getShieldNotesByIvk(sendShieldAddressInfo1,blockingStubFull); - sendNote1 = notes.getNoteTxs(0).getNote(); - shieldOutList.clear(); - memo2 = "Send receiver a note and spend it" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList,sendShieldAddress2, - "" + (sendNote1.getValue() - zenTokenFee),memo2); - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - null,0, - sendShieldAddressInfo1.get(), notes.getNoteTxs(0), - shieldOutList, - null,0, - zenTokenOwnerKey2,blockingStubFull)); - - notes = PublicMethed.getShieldNotesByIvk(receiverAddressInfo2,blockingStubFull); - - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo1.get(), - notes.getNoteTxs(3),blockingStubFull).getResult()); - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo2.get(), - notes.getNoteTxs(4),blockingStubFull).getResult()); - - notes = PublicMethed.getShieldNotesByOvk(receiverAddressInfo1,blockingStubFull); - Assert.assertTrue(PublicMethed.getSpendResult(sendShieldAddressInfo1.get(), - notes.getNoteTxs(0),blockingStubFull).getResult()); - Assert.assertFalse(PublicMethed.getSpendResult(receiverAddressInfo2.get(), - notes.getNoteTxs(1),blockingStubFull).getResult()); - Assert.assertFalse(PublicMethed.getSpendResult(receiverAddressInfo3.get(), - notes.getNoteTxs(2),blockingStubFull).getResult()); - Assert.assertFalse(PublicMethed.getSpendResult(receiverAddressInfo1.get(), - notes.getNoteTxs(3),blockingStubFull).getResult()); - Assert.assertFalse(PublicMethed.getSpendResult(receiverAddressInfo2.get(), - notes.getNoteTxs(4),blockingStubFull).getResult()); - - //Send shield coin without ask when there is no output shield address - shieldOutList.clear(); - memo2 = "Send receiver a note and spend it" + System.currentTimeMillis(); - - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - null, 0, - sendShieldAddressInfo2.get(), notes.getNoteTxs(1), - shieldOutList, - zenTokenOwnerAddress1, notes.getNoteTxs(1).getNote().getValue() - zenTokenFee, - zenTokenOwnerKey2, blockingStubFull)); - - shieldOutList.clear(); - memo2 = "Send receiver a note and spend it" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress2, - "0", memo2); - Assert.assertTrue(PublicMethed.sendShieldCoinWithoutAsk( - null, 0, - sendShieldAddressInfo3.get(), notes.getNoteTxs(2), - shieldOutList, - zenTokenOwnerAddress1, notes.getNoteTxs(2).getNote().getValue() - zenTokenFee, - zenTokenOwnerKey2, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.getShieldNotesByIvk(receiverAddressInfo2, blockingStubFull); - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo2.get(), - notes.getNoteTxs(1), blockingStubFull).getResult()); - Assert.assertTrue(PublicMethed.getSpendResult(receiverAddressInfo3.get(), - notes.getNoteTxs(2), blockingStubFull).getResult()); - - - - - } - - - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress1, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress1, zenTokenOwnerKey1, blockingStubFull); - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress2, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress2, zenTokenOwnerKey2, blockingStubFull); - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress3, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress3, zenTokenOwnerKey3, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity1 != null) { - channelSolidity1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken008.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken008.java deleted file mode 100644 index 5cc0b2a834a..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken008.java +++ /dev/null @@ -1,219 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - - -@Slf4j -public class WalletTestZenToken008 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional sendShieldAddressInfo; - Optional receiverShieldAddressInfo; - String sendShieldAddress; - String receiverShieldAddress; - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - String memo; - Note sendNote; - Note receiverNote; - private static ByteString assetAccountId = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private ManagedChannel channelSolidity1 = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity1 = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - private String soliditynode1 = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 1 * zenTokenFee + 1; - private Long sendTokenAmount = 1 * zenTokenFee; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode).usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - channelSolidity1 = ManagedChannelBuilder.forTarget(soliditynode1) - .usePlaintext(true) - .build(); - blockingStubSolidity1 = WalletSolidityGrpc.newBlockingStub(channelSolidity1); - - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - - - } - - @Test(enabled = true, description = "Public send 1 token to shield transaction") - public void test1Shield2ShieldTransaction() { - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddressInfo:" + sendShieldAddressInfo); - memo = "Shield 1 token memo in " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "1", memo); - Assert.assertFalse(PublicMethed.sendShieldCoin(zenTokenOwnerAddress, sendTokenAmount, null, - null, shieldOutList, null, 0, zenTokenOwnerKey, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress, costTokenAmount, null, - null, shieldOutList, null, 0, zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - sendNote = notes.getNoteTxs(0).getNote(); - Assert.assertTrue(sendNote.getValue() == 1); - - } - - @Test(enabled = true, description = "Shield send 0 token to shield transaction") - public void test2Shield2ShieldTransaction() { - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - zenTokenFee * 2, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - - logger.info("token balance is " + afterAssetBalance); - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddressInfo:" + sendShieldAddressInfo); - memo = "Shield costFee token memo in " + System.currentTimeMillis(); - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + zenTokenFee, memo); - //logger.info(); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress, zenTokenFee * 2, null, - null, shieldOutList, null, 0, zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - receiverShieldAddressInfo = PublicMethed.generateShieldAddress(); - receiverShieldAddress = receiverShieldAddressInfo.get().getAddress(); - - shieldOutList.clear(); - memo = "Send shield to receiver shield memo in" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, receiverShieldAddress, - "0", memo); - - //Wrong proof - Assert.assertFalse(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - //Amount is -1 - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, receiverShieldAddress, - "-1", memo); - Assert.assertFalse(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, receiverShieldAddress, - "0", memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(receiverShieldAddressInfo, blockingStubFull); - receiverNote = notes.getNoteTxs(0).getNote(); - logger.info("Receiver note:" + receiverNote.toString()); - Assert.assertTrue(receiverNote.getValue() == 0); - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity1 != null) { - channelSolidity1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken009.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken009.java deleted file mode 100644 index 72757b49d26..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken009.java +++ /dev/null @@ -1,238 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - -@Slf4j -public class WalletTestZenToken009 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional shieldAddressInfo; - String shieldAddress; - Optional receiverAddressInfo; - String receiverAddress; - List shieldOutList = new ArrayList<>(); - List shieldInputList = new ArrayList<>(); - DecryptNotes notes; - String memo; - Note note; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 5 * zenTokenFee; - private Long sendTokenAmount = 3 * zenTokenFee; - - - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey4.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 3; - Assert.assertTrue( - PublicMethed.sendcoin(zenTokenOwnerAddress, needCoin + 2048000000L, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = zenTokenOwnerKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(zenTokenOwnerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - Assert.assertTrue(PublicMethedForMutiSign - .accountPermissionUpdate(accountPermissionJson, zenTokenOwnerAddress, zenTokenOwnerKey, - blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - } - - @Test(enabled = true, description = "Public to shield transaction with mutisign") - public void test1Public2ShieldTransaction() { - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - shieldAddressInfo = PublicMethed.generateShieldAddress(); - shieldAddress = shieldAddressInfo.get().getAddress(); - logger.info("shieldAddress:" + shieldAddress); - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - final Long beforeBalance = PublicMethed - .queryAccount(zenTokenOwnerAddress,blockingStubFull).getBalance(); - final Long beforeNetUsed = PublicMethed - .getAccountResource(zenTokenOwnerAddress, blockingStubFull).getFreeNetUsed(); - - memo = "aaaaaaa"; - - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, shieldAddress, - "" + (sendTokenAmount - zenTokenFee), memo); - - Assert.assertTrue(PublicMethedForMutiSign.sendShieldCoin( - zenTokenOwnerAddress, sendTokenAmount, - null, null, - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull,ownerKeyString)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull); - Long afterNetUsed = PublicMethed.getAccountResource(zenTokenOwnerAddress, blockingStubFull) - .getFreeNetUsed(); - Assert.assertTrue(beforeAssetBalance - afterAssetBalance == sendTokenAmount); - logger.info("Before net:" + beforeNetUsed); - logger.info("After net:" + afterNetUsed); - Assert.assertEquals(beforeNetUsed,afterNetUsed); - final Long afterBalance = PublicMethed - .queryAccount(zenTokenOwnerAddress,blockingStubFull).getBalance(); - Assert.assertTrue(beforeBalance - afterBalance == multiSignFee); - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - Long receiverShieldTokenAmount = note.getValue(); - Assert.assertTrue(receiverShieldTokenAmount == sendTokenAmount - zenTokenFee); - Assert.assertEquals(memo, PublicMethed.getMemo(note)); - } - - @Test(enabled = true, description = "When from is shield,sign this transaction is forbidden") - public void test2ShieldFromShouldNotSign() { - receiverAddressInfo = PublicMethed.generateShieldAddress(); - receiverAddress = shieldAddressInfo.get().getAddress(); - logger.info("receiver address:" + shieldAddress); - - notes = PublicMethed.listShieldNote(shieldAddressInfo, blockingStubFull); - note = notes.getNoteTxs(0).getNote(); - - - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, receiverAddress, - "" + (note.getValue() - zenTokenFee), memo); - - Assert.assertFalse(PublicMethedForMutiSign.sendShieldCoin( - null, 321321, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull, ownerKeyString)); - - - Assert.assertFalse(PublicMethed.sendShieldCoin( - null, 321321, - shieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - Assert.assertFalse(PublicMethed.getSpendResult(shieldAddressInfo.get(), - notes.getNoteTxs(0),blockingStubFull).getResult()); - - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethedForMutiSign.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, - zenTokenOwnerKey, blockingStubFull,ownerKeyString); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken010.java b/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken010.java deleted file mode 100644 index 27d0fe4b06b..00000000000 --- a/src/test/java/stest/tron/wallet/dailybuild/zentoken/WalletTestZenToken010.java +++ /dev/null @@ -1,267 +0,0 @@ -package stest.tron.wallet.dailybuild.zentoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - - -@Slf4j -public class WalletTestZenToken010 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional sendShieldAddressInfo; - Optional receiverShieldAddressInfo; - String sendShieldAddress; - String receiverShieldAddress; - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - String memo; - Note sendNote; - Note receiverNote; - private static ByteString assetAccountId = null; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private ManagedChannel channelSolidity1 = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity1 = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - private String soliditynode1 = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 10 * zenTokenFee; - private Long sendTokenAmount = 8 * zenTokenFee; - - private String txid; - private Optional infoById; - private Optional byId; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode).usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - channelSolidity1 = ManagedChannelBuilder.forTarget(soliditynode1) - .usePlaintext(true) - .build(); - blockingStubSolidity1 = WalletSolidityGrpc.newBlockingStub(channelSolidity1); - - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddressInfo:" + sendShieldAddressInfo); - memo = "Shield memo in" + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + (sendTokenAmount - zenTokenFee), memo); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress, sendTokenAmount, null, - null, shieldOutList, null, 0, zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - sendNote = notes.getNoteTxs(0).getNote(); - - } - - @Test(enabled = true, description = "Shield to itself transaction") - public void test1Shield2ShieldTransaction() { - shieldOutList.clear(); - memo = "Send shield to itself memo1 in " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + zenTokenFee, memo); - - memo = "Send shield to itself memo2 in " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + (sendNote.getValue() - 2 * zenTokenFee), memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.getShieldNotesByIvk(sendShieldAddressInfo, blockingStubFull); - Assert.assertTrue(notes.getNoteTxsCount() == 3); - Assert.assertTrue(notes.getNoteTxs(1).getNote().getValue() == zenTokenFee); - Assert.assertTrue(notes.getNoteTxs(2).getNote().getValue() - == sendNote.getValue() - 2 * zenTokenFee); - Assert.assertEquals(notes.getNoteTxs(1).getNote().getPaymentAddress(), - notes.getNoteTxs(2).getNote().getPaymentAddress()); - Assert.assertEquals(notes.getNoteTxs(1).getTxid(),notes.getNoteTxs(2).getTxid()); - Assert.assertTrue(PublicMethed.getSpendResult(sendShieldAddressInfo.get(), - notes.getNoteTxs(0),blockingStubFull).getResult()); - - notes = PublicMethed.getShieldNotesByOvk(sendShieldAddressInfo, blockingStubFull); - Assert.assertTrue(notes.getNoteTxsCount() == 2); - } - - @Test(enabled = true, description = "From shield only have one zenToken fee") - public void test2Shield2ShieldTransaction() { - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - logger.info("sendShieldAddressInfo:" + sendShieldAddressInfo); - memo = "Shield memo in" + System.currentTimeMillis(); - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + zenTokenFee, memo); - Assert.assertTrue(PublicMethed.sendShieldCoin(zenTokenOwnerAddress, 2 * zenTokenFee, null, - null, shieldOutList, null, 0, zenTokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - notes = PublicMethed.listShieldNote(sendShieldAddressInfo, blockingStubFull); - sendNote = notes.getNoteTxs(0).getNote(); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - shieldOutList.clear(); - memo = "Send shield to itself memo1 in " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "0", memo); - - memo = "Send shield to itself memo2 in " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "0", memo); - Assert.assertTrue(PublicMethed.sendShieldCoin( - null, 0, - sendShieldAddressInfo.get(), notes.getNoteTxs(0), - shieldOutList, - null, 0, - zenTokenOwnerKey, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - notes = PublicMethed.getShieldNotesByIvk(sendShieldAddressInfo, blockingStubFull); - Assert.assertTrue(notes.getNoteTxsCount() == 3); - logger.info("index 0:" + notes.getNoteTxs(0).getNote().getValue()); - logger.info("index 1:" + notes.getNoteTxs(1).getNote().getValue()); - logger.info("index 2:" + notes.getNoteTxs(2).getNote().getValue()); - Assert.assertTrue(notes.getNoteTxs(1).getNote().getValue() == 0); - Assert.assertTrue(notes.getNoteTxs(2).getNote().getValue() == 0); - Assert.assertEquals(notes.getNoteTxs(1).getNote().getPaymentAddress(), - notes.getNoteTxs(2).getNote().getPaymentAddress()); - Assert.assertEquals(notes.getNoteTxs(1).getTxid(), notes.getNoteTxs(2).getTxid()); - } - - @Test(enabled = true, description = "From public and to public is same one") - public void test3Public2ShieldAndPublicItselfTransaction() { - sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - - ecKey1 = new ECKey(Utils.getRandom()); - zenTokenOwnerAddress = ecKey1.getAddress(); - zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - final Long beforeAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenAddress, blockingStubFull).getAccountId(), - blockingStubFull); - final Long beforeBalance = PublicMethed.queryAccount(zenTokenOwnerAddress, blockingStubFull) - .getBalance(); - shieldOutList.clear(); - memo = "From public and to public is same one memo in " + System.currentTimeMillis(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + 2 * zenTokenFee, memo); - - Assert.assertFalse(PublicMethed - .sendShieldCoin(zenTokenOwnerAddress, costTokenAmount, null, null, shieldOutList, - zenTokenOwnerAddress, 7 * zenTokenFee, zenTokenOwnerKey, blockingStubFull)); - - Long afterAssetBalance = PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenAddress, blockingStubFull).getAccountId(), - blockingStubFull); - Long afterBalance = PublicMethed.queryAccount(zenTokenOwnerAddress, blockingStubFull) - .getBalance(); - - Assert.assertEquals(beforeAssetBalance, afterAssetBalance); - Assert.assertEquals(beforeBalance, afterBalance); - - notes = PublicMethed.getShieldNotesByIvk(sendShieldAddressInfo, blockingStubFull); - Assert.assertTrue(notes.getNoteTxsCount() == 0); - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity1 != null) { - channelSolidity1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletExchange001.java b/src/test/java/stest/tron/wallet/exchangeandtoken/WalletExchange001.java deleted file mode 100644 index 5bdb6689b47..00000000000 --- a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletExchange001.java +++ /dev/null @@ -1,369 +0,0 @@ -package stest.tron.wallet.exchangeandtoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ExchangeList; -import org.tron.api.GrpcAPI.PaginatedMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Exchange; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletExchange001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - - private static final long now = System.currentTimeMillis(); - private static String name1 = "exchange001_1_" + Long.toString(now); - private static String name2 = "exchange001_2_" + Long.toString(now); - private static final long totalSupply = 1000000001L; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] exchange001Address = ecKey1.getAddress(); - String exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] secondExchange001Address = ecKey2.getAddress(); - String secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - Long secondTransferAssetToFirstAccountNum = 100000000L; - Account firstAccount; - ByteString assetAccountId1; - ByteString assetAccountId2; - - Optional listExchange; - Optional exchangeIdInfo; - Integer exchangeId = 0; - Integer exchangeRate = 10; - Long firstTokenInitialBalance = 10000L; - Long secondTokenInitialBalance = firstTokenInitialBalance * exchangeRate; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void test1CreateUsedAsset() { - ecKey1 = new ECKey(Utils.getRandom()); - exchange001Address = ecKey1.getAddress(); - exchange001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - secondExchange001Address = ecKey2.getAddress(); - secondExchange001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(exchange001Key); - PublicMethed.printAddress(secondExchange001Key); - - Assert.assertTrue(PublicMethed.sendcoin(exchange001Address, 10240000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(secondExchange001Address, 10240000000L, toAddress, - testKey003, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long start = System.currentTimeMillis() + 5000L; - Long end = System.currentTimeMillis() + 5000000L; - Assert.assertTrue(PublicMethed.createAssetIssue(exchange001Address, name1, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, exchange001Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.createAssetIssue(secondExchange001Address, name2, totalSupply, 1, - 1, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, secondExchange001Key, blockingStubFull)); - } - - @Test(enabled = true) - public void test2CreateExchange() { - listExchange = PublicMethed.getExchangeList(blockingStubFull); - final Integer beforeCreateExchangeNum = listExchange.get().getExchangesCount(); - exchangeId = listExchange.get().getExchangesCount(); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - assetAccountId1 = getAssetIdFromThisAccount.getAssetIssuedID(); - - getAssetIdFromThisAccount = PublicMethed - .queryAccount(secondExchange001Address, blockingStubFull); - assetAccountId2 = getAssetIdFromThisAccount.getAssetIssuedID(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long token1BeforeBalance = 0L; - for (String name : firstAccount.getAssetMap().keySet()) { - token1BeforeBalance = firstAccount.getAssetMap().get(name); - } - Assert.assertTrue(PublicMethed.transferAsset(exchange001Address, assetAccountId2.toByteArray(), - secondTransferAssetToFirstAccountNum, secondExchange001Address, - secondExchange001Key, blockingStubFull)); - Long token2BeforeBalance = secondTransferAssetToFirstAccountNum; - - //logger.info("name1 is " + name1); - //logger.info("name2 is " + name2); - //logger.info("first balance is " + Long.toString(token1BeforeBalance)); - //logger.info("second balance is " + token2BeforeBalance.toString()); - //CreateExchange - Assert.assertTrue( - PublicMethed.exchangeCreate(assetAccountId1.toByteArray(), firstTokenInitialBalance, - assetAccountId2.toByteArray(), secondTokenInitialBalance, exchange001Address, - exchange001Key, - blockingStubFull)); - listExchange = PublicMethed.getExchangeList(blockingStubFull); - Integer afterCreateExchangeNum = listExchange.get().getExchangesCount(); - Assert.assertTrue(afterCreateExchangeNum - beforeCreateExchangeNum == 1); - exchangeId = listExchange.get().getExchangesCount(); - - } - - @Test(enabled = true) - public void test3ListExchange() { - listExchange = PublicMethed.getExchangeList(blockingStubFull); - for (Integer i = 0; i < listExchange.get().getExchangesCount(); i++) { - Assert.assertFalse(ByteArray.toHexString(listExchange.get().getExchanges(i) - .getCreatorAddress().toByteArray()).isEmpty()); - Assert.assertTrue(listExchange.get().getExchanges(i).getExchangeId() > 0); - Assert.assertFalse(ByteArray.toStr(listExchange.get().getExchanges(i).getFirstTokenId() - .toByteArray()).isEmpty()); - Assert.assertTrue(listExchange.get().getExchanges(i).getFirstTokenBalance() > 0); - } - } - - @Test(enabled = true) - public void test4InjectExchange() { - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer injectBalance = 100; - Assert.assertTrue( - PublicMethed.injectExchange(exchangeId, assetAccountId1.toByteArray(), injectBalance, - exchange001Address, exchange001Key, blockingStubFull)); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(beforeToken1Balance - afterToken1Balance == injectBalance); - Assert.assertTrue(beforeToken2Balance - afterToken2Balance == injectBalance - * exchangeRate); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == injectBalance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == injectBalance * exchangeRate); - } - - @Test(enabled = true) - public void test5WithdrawExchange() { - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer withdrawNum = 200; - Assert.assertTrue( - PublicMethed.exchangeWithdraw(exchangeId, assetAccountId1.toByteArray(), withdrawNum, - exchange001Address, exchange001Key, blockingStubFull)); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - Assert.assertTrue(afterToken1Balance - beforeToken1Balance == withdrawNum); - Assert.assertTrue(afterToken2Balance - beforeToken2Balance == withdrawNum - * exchangeRate); - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == -withdrawNum); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == -withdrawNum * exchangeRate); - - - } - - @Test(enabled = true) - public void test6TransactionExchange() { - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - final Long beforeExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - final Long beforeExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("beforeExchangeToken1Balance" + beforeExchangeToken1Balance); - logger.info("beforeExchangeToken2Balance" + beforeExchangeToken2Balance); - - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long beforeToken1Balance = 0L; - Long beforeToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - beforeToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - - logger.info("before token 1 balance is " + Long.toString(beforeToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(beforeToken2Balance)); - Integer transactionNum = 50; - Assert.assertTrue( - PublicMethed - .exchangeTransaction(exchangeId, assetAccountId1.toByteArray(), transactionNum, 1, - exchange001Address, exchange001Key, blockingStubFull)); - firstAccount = PublicMethed.queryAccount(exchange001Address, blockingStubFull); - Long afterToken1Balance = 0L; - Long afterToken2Balance = 0L; - for (String id : firstAccount.getAssetV2Map().keySet()) { - if (assetAccountId1.toStringUtf8().equalsIgnoreCase(id)) { - afterToken1Balance = firstAccount.getAssetV2Map().get(id); - } - if (assetAccountId2.toStringUtf8().equalsIgnoreCase(id)) { - afterToken2Balance = firstAccount.getAssetV2Map().get(id); - } - } - logger.info("before token 1 balance is " + Long.toString(afterToken1Balance)); - logger.info("before token 2 balance is " + Long.toString(afterToken2Balance)); - - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubFull); - Long afterExchangeToken1Balance = exchangeIdInfo.get().getFirstTokenBalance(); - Long afterExchangeToken2Balance = exchangeIdInfo.get().getSecondTokenBalance(); - logger.info("afterExchangeToken1Balance" + afterExchangeToken1Balance); - logger.info("afterExchangeToken2Balance" + afterExchangeToken2Balance); - Assert.assertTrue(afterExchangeToken1Balance - beforeExchangeToken1Balance - == beforeToken1Balance - afterToken1Balance); - Assert.assertTrue(afterExchangeToken2Balance - beforeExchangeToken2Balance - == beforeToken2Balance - afterToken2Balance); - } - - @Test(enabled = true) - public void test7GetExchangeListPaginated() { - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(0); - pageMessageBuilder.setLimit(100); - ExchangeList exchangeList = blockingStubFull - .getPaginatedExchangeList(pageMessageBuilder.build()); - Assert.assertTrue(exchangeList.getExchangesCount() >= 1); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity); - //Solidity support getExchangeId - exchangeIdInfo = PublicMethed.getExchange(exchangeId.toString(), blockingStubSolidity); - logger.info("createtime is" + exchangeIdInfo.get().getCreateTime()); - Assert.assertTrue(exchangeIdInfo.get().getCreateTime() > 0); - - //Solidity support listexchange - listExchange = PublicMethed.getExchangeList(blockingStubSolidity); - Assert.assertTrue(listExchange.get().getExchangesCount() > 0); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue017.java b/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue017.java deleted file mode 100644 index abe6997685a..00000000000 --- a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue017.java +++ /dev/null @@ -1,357 +0,0 @@ -package stest.tron.wallet.exchangeandtoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.GrpcAPI.PaginatedMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.db.Manager; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestAssetIssue017 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static long start; - private static long end; - private static long now = System.currentTimeMillis(); - private static String name = "AssetIssue017_" + Long.toString(now); - private static long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 30000L; - Long publicFreeAssetNetLimit = 30000L; - String description = "for case assetissue017"; - String url = "https://stest.assetissue016.url"; - - private Manager dbManager; - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset017Address = ecKey1.getAddress(); - String testKeyForAssetIssue017 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(testKeyForAssetIssue017); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void atestGetPaginatedAssetIssueList() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - asset017Address = ecKey1.getAddress(); - testKeyForAssetIssue017 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed - .sendcoin(asset017Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - now = System.currentTimeMillis(); - name = "AssetIssue017_" + Long.toString(now); - totalSupply = now; - Assert.assertTrue(createAssetIssue(asset017Address, name, totalSupply, 1, 1, - start, end, 1, description, url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, - 1L, testKeyForAssetIssue017, blockingStubFull)); - - Integer offset = 0; - Integer limit = 100; - - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - - AssetIssueList assetIssueList = blockingStubFull - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - Optional assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() >= 1); - for (Integer i = 0; i < assetIssueListPaginated.get().getAssetIssueCount(); i++) { - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssue(i).getTotalSupply() > 0); - } - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity); - } - - @Test(enabled = true) - public void btestGetPaginatedAssetIssueListException() { - //offset is 0, limit is 0. - Integer offset = 0; - Integer limit = 0; - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - AssetIssueList assetIssueList = blockingStubFull - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - Optional assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() == 0); - - //offset is -1, limit is 100. - offset = -1; - limit = 100; - pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - assetIssueList = blockingStubFull - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() == 0); - - //offset is 0, limit is -1. - offset = 0; - limit = -1; - pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - assetIssueList = blockingStubFull - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() == 0); - - //offset is 0, limit is 50. - offset = 0; - limit = 50; - pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - assetIssueList = blockingStubFull - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() >= 1); - } - - @Test(enabled = true) - public void ctestGetPaginatedAssetIssueListOnSolidityNode() { - - Integer offset = 0; - Integer limit = 100; - - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - Assert.assertTrue(PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, - blockingStubSolidity)); - AssetIssueList assetIssueList = blockingStubSolidity - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - Optional assetIssueListPaginated = Optional.ofNullable(assetIssueList); - - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() >= 1); - for (Integer i = 0; i < assetIssueListPaginated.get().getAssetIssueCount(); i++) { - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssue(i).getTotalSupply() > 0); - } - } - - @Test(enabled = true) - public void dtestGetPaginatedAssetIssueListExceptionOnSolidityNode() { - //offset is 0, limit is 0. - Integer offset = 0; - Integer limit = 0; - PaginatedMessage.Builder pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - AssetIssueList assetIssueList = blockingStubSolidity - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - Optional assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() == 0); - - //offset is 0, limit is -1. - offset = 0; - limit = -1; - pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - assetIssueList = blockingStubSolidity - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() == 0); - - //offset is 0, limit is 50. - offset = 0; - limit = 50; - pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - assetIssueList = blockingStubSolidity - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() >= 1); - - //offset is 0, limit is 1000. - offset = 0; - limit = 1000; - pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - assetIssueList = blockingStubSolidity - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() >= 1); - - //offset is -1, limit is 100. - offset = -1; - limit = 100; - pageMessageBuilder = PaginatedMessage.newBuilder(); - pageMessageBuilder.setOffset(offset); - pageMessageBuilder.setLimit(limit); - assetIssueList = blockingStubSolidity - .getPaginatedAssetIssueList(pageMessageBuilder.build()); - assetIssueListPaginated = Optional.ofNullable(assetIssueList); - logger.info(Long.toString(assetIssueListPaginated.get().getAssetIssueCount())); - Assert.assertTrue(assetIssueListPaginated.get().getAssetIssueCount() == 0); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public static Boolean createAssetIssue(byte[] address, String name, Long totalSupply, - Integer trxNum, Integer icoNum, Long startTime, Long endTime, Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(ecKey, blockingStubFull); - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Protocol.Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info("failed reason is " + ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public static Protocol.Transaction signTransaction(ECKey ecKey, - Protocol.Transaction transaction) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - if (ecKey == null || ecKey.getPrivKey() == null) { - //logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue018.java b/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue018.java deleted file mode 100644 index fe543b48409..00000000000 --- a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue018.java +++ /dev/null @@ -1,251 +0,0 @@ -package stest.tron.wallet.exchangeandtoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract.AssetIssueContract; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue018 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private static final long now = System.currentTimeMillis(); - private static final String name = "Asset008_" + Long.toString(now); - private static final String char32Name = "To_long_asset_name_" + Long.toString(now); - private static final String char33Name = "To_long_asset_name_a" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(1); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] assetAccount1Address = ecKey1.getAddress(); - String assetAccount1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] assetAccount2Address = ecKey2.getAddress(); - String assetAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] assetAccount3Address = ecKey3.getAddress(); - String assetAccount3Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] assetAccount4Address = ecKey4.getAddress(); - String assetAccount4Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - - ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] assetAccount5Address = ecKey5.getAddress(); - String assetAccount5Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - - ECKey ecKey6 = new ECKey(Utils.getRandom()); - byte[] assetAccount6Address = ecKey6.getAddress(); - String assetAccount6Key = ByteArray.toHexString(ecKey6.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.printAddress(assetAccount1Key); - PublicMethed.printAddress(assetAccount2Key); - PublicMethed.printAddress(assetAccount3Key); - PublicMethed.printAddress(assetAccount4Key); - PublicMethed.printAddress(assetAccount5Key); - PublicMethed.printAddress(assetAccount6Key); - } - - @Test(enabled = true) - public void test1AssetIssueNameBelow32Char() { - - ecKey4 = new ECKey(Utils.getRandom()); - assetAccount4Address = ecKey4.getAddress(); - assetAccount4Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - ecKey5 = new ECKey(Utils.getRandom()); - assetAccount5Address = ecKey5.getAddress(); - assetAccount5Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - - ecKey6 = new ECKey(Utils.getRandom()); - assetAccount6Address = ecKey6.getAddress(); - assetAccount6Key = ByteArray.toHexString(ecKey6.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(assetAccount4Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(assetAccount5Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(assetAccount6Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - - //Can create 32 char token name. - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(assetAccount4Address, - char32Name, totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, assetAccount4Key, blockingStubFull)); - - //Can't create 33 char token name. - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - Assert.assertFalse(PublicMethed.createAssetIssue(assetAccount5Address, - char33Name, totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, assetAccount5Key, blockingStubFull)); - - // - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(assetAccount6Address, - char32Name, totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, assetAccount6Key, blockingStubFull)); - - } - - @Test(enabled = true) - public void test2SameAssetissueName() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - assetAccount1Address = ecKey1.getAddress(); - assetAccount1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - assetAccount2Address = ecKey2.getAddress(); - assetAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - assetAccount3Address = ecKey3.getAddress(); - assetAccount3Key = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - logger.info(name); - logger.info("total supply is " + Long.toString(totalSupply)); - //send coin to the new account - Assert.assertTrue(PublicMethed.sendcoin(assetAccount1Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(assetAccount2Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(assetAccount3Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Create 3 the same name token. - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(assetAccount1Address, - name, totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, assetAccount1Key, blockingStubFull)); - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(assetAccount2Address, - name, totalSupply, 2, 2, start, end, 2, description, url, - 3000L, 3000L, 2L, 2L, assetAccount2Key, blockingStubFull)); - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(assetAccount3Address, - name, totalSupply, 3, 3, start, end, 3, description, url, - 4000L, 4000L, 3L, 3L, assetAccount3Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Get asset issue by name - String asset1Name = name; - ByteString assetNameBs = ByteString.copyFrom(asset1Name.getBytes()); - - BytesMessage request = BytesMessage.newBuilder().setValue(assetNameBs).build(); - - AssetIssueList assetIssueList = blockingStubFull.getAssetIssueListByName(request); - Assert.assertTrue(assetIssueList.getAssetIssueCount() == 3); - for (AssetIssueContract assetIssue : assetIssueList.getAssetIssueList()) { - Assert.assertTrue(assetIssue.getTotalSupply() == totalSupply); - - } - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(assetAccount1Key, blockingStubFull); - final ByteString assetAccount1Id = getAssetIdFromThisAccount.getAssetIssuedID(); - - getAssetIdFromThisAccount = PublicMethed.queryAccount(assetAccount2Key, blockingStubFull); - final ByteString assetAccount2Id = getAssetIdFromThisAccount.getAssetIssuedID(); - - getAssetIdFromThisAccount = PublicMethed.queryAccount(assetAccount3Key, blockingStubFull); - final ByteString assetAccount3Id = getAssetIdFromThisAccount.getAssetIssuedID(); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Transfer asset issue. - Assert.assertTrue(PublicMethed.transferAsset(assetAccount2Address, assetAccount1Id - .toByteArray(), 1L, assetAccount1Address, assetAccount1Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(assetAccount3Address, assetAccount2Id - .toByteArray(), 2L, assetAccount2Address, assetAccount2Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.transferAsset(assetAccount1Address, assetAccount3Id - .toByteArray(), 3L, assetAccount3Address, assetAccount3Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.transferAsset(assetAccount1Address, assetAccount2Id - .toByteArray(), 3L, assetAccount3Address, assetAccount3Key, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Participate asset issue. - Assert.assertTrue(PublicMethed.participateAssetIssue(assetAccount3Address, assetAccount3Id - .toByteArray(), 1L, assetAccount2Address, assetAccount2Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.participateAssetIssue(assetAccount1Address, assetAccount1Id - .toByteArray(), 2L, assetAccount3Address, assetAccount3Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.participateAssetIssue(assetAccount2Address, assetAccount2Id - .toByteArray(), 3L, assetAccount1Address, assetAccount1Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.participateAssetIssue(assetAccount2Address, assetAccount3Id - .toByteArray(), 3L, assetAccount1Address, assetAccount1Key, blockingStubFull)); - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue019.java b/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue019.java deleted file mode 100644 index 1a82b69e9c8..00000000000 --- a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue019.java +++ /dev/null @@ -1,176 +0,0 @@ -package stest.tron.wallet.exchangeandtoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue019 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static final long now = System.currentTimeMillis(); - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset019Address = ecKey1.getAddress(); - String asset019Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] asset019SecondAddress = ecKey2.getAddress(); - String asset019SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void testCanNotCreateTokenNameByTrx() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - asset019Address = ecKey1.getAddress(); - asset019Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(asset019Key); - - ecKey2 = new ECKey(Utils.getRandom()); - asset019SecondAddress = ecKey2.getAddress(); - asset019SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - PublicMethed.printAddress(asset019SecondKey); - - Assert.assertTrue(PublicMethed.sendcoin(asset019Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(asset019SecondAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - - //Can create 32 char token name. - Long start = System.currentTimeMillis() + 20000000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "trx", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "TRX", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "Trx", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "tRx", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "trX", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "TRx", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "TrX", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertFalse(PublicMethed.createAssetIssue(asset019Address, - "tRX", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.createAssetIssue(asset019Address, - "trxtrx", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.createAssetIssue(asset019SecondAddress, - "_", totalSupply, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset019SecondKey, blockingStubFull)); - } - - @Test(enabled = true) - public void testGetAssetLastOperationTimeAndAssetIssueFreeNetUsed() { - Assert.assertTrue(PublicMethed.freezeBalance(asset019Address, 100000000L, 3, - asset019Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalance(asset019SecondAddress, 100000000L, 3, - asset019SecondKey, blockingStubFull)); - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset019Address, blockingStubFull); - ByteString asset019AccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset019SecondAddress, blockingStubFull); - ByteString asset019SecondAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - PublicMethed.transferAsset(asset019SecondAddress, asset019AccountId.toByteArray(), 100L, - asset019Address, asset019Key, blockingStubFull); - PublicMethed.transferAsset(asset019Address, asset019SecondAccountId.toByteArray(), 100L, - asset019SecondAddress, asset019SecondKey, blockingStubFull); - - PublicMethed.transferAsset(asset019Address, asset019AccountId.toByteArray(), 10L, - asset019SecondAddress, asset019SecondKey, blockingStubFull); - PublicMethed.transferAsset(asset019SecondAddress, asset019SecondAccountId.toByteArray(), - 10L, asset019Address, asset019Key, blockingStubFull); - - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset019Address, blockingStubFull); - for (String id : getAssetIdFromThisAccount.getFreeAssetNetUsageV2Map().keySet()) { - if (asset019SecondAccountId.toStringUtf8().equalsIgnoreCase(id)) { - Assert.assertTrue(getAssetIdFromThisAccount.getFreeAssetNetUsageV2Map().get(id) > 0); - } - } - - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset019SecondAddress, blockingStubFull); - for (String id : getAssetIdFromThisAccount.getLatestAssetOperationTimeV2Map().keySet()) { - if (asset019AccountId.toStringUtf8().equalsIgnoreCase(id)) { - Assert.assertTrue(getAssetIdFromThisAccount.getLatestAssetOperationTimeV2Map().get(id) > 0); - } - } - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue020.java b/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue020.java deleted file mode 100644 index 2ef3ae8a088..00000000000 --- a/src/test/java/stest/tron/wallet/exchangeandtoken/WalletTestAssetIssue020.java +++ /dev/null @@ -1,165 +0,0 @@ -package stest.tron.wallet.exchangeandtoken; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestAssetIssue020 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private static final long now = System.currentTimeMillis(); - private static final String name = "Assetissue020_" + Long.toString(now); - private static final String char33Name = "To_long_asset_name_a" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - Account assetIssue020Account; - ByteString assetAccountId; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset020Address = ecKey1.getAddress(); - String asset020Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] asset020SecondAddress = ecKey2.getAddress(); - String asset020SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void testAssetIssueSupportPrecision() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - asset020Address = ecKey1.getAddress(); - asset020Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(asset020Key); - - ecKey2 = new ECKey(Utils.getRandom()); - asset020SecondAddress = ecKey2.getAddress(); - asset020SecondKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - PublicMethed.printAddress(asset020SecondKey); - logger.info(name); - - Assert.assertTrue(PublicMethed.sendcoin(asset020Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(asset020SecondAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Can create 32 char token name. - Long start = System.currentTimeMillis() + 2000000; - Long end = System.currentTimeMillis() + 1000000000; - - //When precision is -1, can not create asset issue - Assert.assertFalse(PublicMethed.createAssetIssue(asset020Address, - name, totalSupply, 1, 1, -1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset020Key, blockingStubFull)); - - //When precision is 7, can not create asset issue - Assert.assertFalse(PublicMethed.createAssetIssue(asset020Address, - name, totalSupply, 1, 1, 7, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset020Key, blockingStubFull)); - - //When precision is 6, is equal to default. - Assert.assertTrue(PublicMethed.createAssetIssue(asset020Address, - name, totalSupply, 1, 1, 6, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset020Key, blockingStubFull)); - - Account getAssetIdFromThisAccount; - getAssetIdFromThisAccount = PublicMethed.queryAccount(asset020Address, blockingStubFull); - assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - - Contract.AssetIssueContract assetIssueInfo = PublicMethed - .getAssetIssueByName(name, blockingStubFull); - final Integer preCisionByName = assetIssueInfo.getPrecision(); - final Long TotalSupplyByName = assetIssueInfo.getTotalSupply(); - - assetIssueInfo = PublicMethed.getAssetIssueById(ByteArray.toStr(assetAccountId - .toByteArray()), blockingStubFull); - final Integer preCisionById = assetIssueInfo.getPrecision(); - final Long TotalSupplyById = assetIssueInfo.getTotalSupply(); - - assetIssueInfo = PublicMethed.getAssetIssueListByName(name, blockingStubFull) - .get().getAssetIssue(0); - final Integer preCisionByListName = assetIssueInfo.getPrecision(); - final Long TotalSupplyByListName = assetIssueInfo.getTotalSupply(); - - logger.info("precision is " + preCisionByName); - logger.info("precision is " + preCisionById); - logger.info("precision is " + preCisionByListName); - logger.info("totalsupply is " + TotalSupplyByName); - logger.info("totalsupply is " + TotalSupplyById); - logger.info("totalsupply is " + TotalSupplyByListName); - Assert.assertEquals(preCisionById, preCisionByListName); - Assert.assertEquals(preCisionById, preCisionByName); - Assert.assertEquals(TotalSupplyById, TotalSupplyByListName); - Assert.assertEquals(TotalSupplyById, TotalSupplyByName); - - //When precision is 6, is equal to default. - Assert.assertTrue(PublicMethed.createAssetIssue(asset020SecondAddress, - name, totalSupply, 1, 1, 1, start, end, 1, description, url, - 2000L, 2000L, 1L, 1L, asset020SecondKey, blockingStubFull)); - - assetIssueInfo = PublicMethed.getAssetIssueByName(name, blockingStubFull); - Assert.assertTrue(assetIssueInfo.getName().isEmpty()); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/fulltest/AttackSendcoin.java b/src/test/java/stest/tron/wallet/fulltest/AttackSendcoin.java deleted file mode 100644 index 84b42f8d9c5..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/AttackSendcoin.java +++ /dev/null @@ -1,450 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Random; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.slf4j.Logger; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.TransferContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class AttackSendcoin { - - //testng001、testng002、testng003、testng004 - //Devaccount - private final String testKey001 = - "8CB4480194192F30907E14B52498F594BD046E21D7C4D8FE866563A6760AC891"; - //Zion - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - //Sun - private final String testKey003 = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - //Normal1 - private final String normalKey001 = - "36c0710378a34634e6baba0d3a79d7439a81183030147e7f4a0dd43bfed1a32f"; - //Normal2 - private final String normalKey002 = - "a6bfbcf98bbe07770bf79bc6b2970bae0992771c1dcbf24cc063a3f033f17fbf"; - //Normal3 - private final String normalKey003 = - "8273f6b26202526cbffb77569b830c1ba8a920040e77f6f26062a67315580ed7"; - //Normal4 - private final String normalKey004 = - "271c824fcb55f04a9f86f768424a80edeb26ab79cf12aa56643b595f689c008a"; - - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final byte[] attackAddress = PublicMethed.getFinalAddress(testKey001); - private final byte[] normal1Address = PublicMethed.getFinalAddress(normalKey001); - private final byte[] normal2Address = PublicMethed.getFinalAddress(normalKey002); - private final byte[] normal3Address = PublicMethed.getFinalAddress(normalKey003); - private final byte[] normal4Address = PublicMethed.getFinalAddress(normalKey004); - - - private static final long now = System.currentTimeMillis(); - private static long start; - private static long end; - private static long beforeFromBalance; - private static long beforeNormal1Balance; - private static long beforeNormal2Balance; - private static long beforeNormal3Balance; - private static long beforeNormal4Balance; - private static long beforeAttackBalance; - private static long afterFromBalance; - private static long afterNormal1Balance; - private static long afterNormal2Balance; - private static long afterNormal3Balance; - private static long afterNormal4Balance; - private static long afterAttackBalance; - private final Long sendNromal1Amount = 1L; - private final Long sendNromal2Amount = 2L; - private final Long sendNromal3Amount = 3L; - private final Long sendNromal4Amount = 4L; - private final Long attackAmount = 5L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - final Account fromInfo = PublicMethed.queryAccount(testKey002, blockingStubFull); - final Account attackInfo = PublicMethed.queryAccount(testKey001, blockingStubFull); - final Account normal1Info = PublicMethed.queryAccount(normalKey001, blockingStubFull); - final Account normal2Info = PublicMethed.queryAccount(normalKey002, blockingStubFull); - final Account normal3Info = PublicMethed.queryAccount(normalKey003, blockingStubFull); - final Account normal4Info = PublicMethed.queryAccount(normalKey004, blockingStubFull); - beforeFromBalance = fromInfo.getBalance(); - beforeNormal1Balance = normal1Info.getBalance(); - beforeNormal2Balance = normal2Info.getBalance(); - beforeNormal3Balance = normal3Info.getBalance(); - beforeNormal4Balance = normal4Info.getBalance(); - beforeAttackBalance = attackInfo.getBalance(); - start = System.currentTimeMillis(); - } - - //@Test(enabled = true) - @Test(enabled = false, threadPoolSize = 200, invocationCount = 200) - public void freezeAndSendcoin() throws InterruptedException { - - Integer i = 0; - Random rand = new Random(); - Integer randNum = 0; - Integer n = 0; - - while (i < 20) { - randNum = i % 4; - i++; - fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(randNum); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - if (randNum == 3) { - PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull); - /* PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(attackAddress, attackAmount, fromAddress, testKey002, - blockingStubFull);*/ - } - - if (randNum == 0) { - PublicMethed.sendcoin(normal1Address, sendNromal1Amount, fromAddress, - testKey002, blockingStubFull); - continue; - } - if (randNum == 1) { - PublicMethed.sendcoin(normal2Address, sendNromal2Amount, fromAddress, - testKey002, blockingStubFull); - continue; - } - if (randNum == 2) { - PublicMethed.sendcoin(normal3Address, sendNromal3Amount, fromAddress, - testKey002, blockingStubFull); - continue; - } - if (randNum == 3) { - PublicMethed.sendcoin(normal4Address, sendNromal4Amount, fromAddress, - testKey002, blockingStubFull); - continue; - } - } - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - //Print the duration. - end = System.currentTimeMillis(); - logger.info("The time is " + Long.toString(end - start)); - - //Print 6 account balance information. - final Account fromInfo = PublicMethed.queryAccount(testKey002, blockingStubFull); - final Account attackInfo = PublicMethed.queryAccount(testKey001, blockingStubFull); - final Account normal1Info = PublicMethed.queryAccount(normalKey001, blockingStubFull); - final Account normal2Info = PublicMethed.queryAccount(normalKey002, blockingStubFull); - final Account normal3Info = PublicMethed.queryAccount(normalKey003, blockingStubFull); - final Account normal4Info = PublicMethed.queryAccount(normalKey004, blockingStubFull); - - afterFromBalance = fromInfo.getBalance(); - afterNormal1Balance = normal1Info.getBalance(); - afterNormal2Balance = normal2Info.getBalance(); - afterNormal3Balance = normal3Info.getBalance(); - afterNormal4Balance = normal4Info.getBalance(); - afterAttackBalance = attackInfo.getBalance(); - - logger.info("attack transaction success num is " - + (afterAttackBalance - beforeAttackBalance) / attackAmount); - logger.info("Normal 1 transaction success num is " - + (afterNormal1Balance - beforeNormal1Balance) / sendNromal1Amount); - logger.info("Normal 2 transaction success num is " - + (afterNormal2Balance - beforeNormal2Balance) / sendNromal2Amount); - logger.info("Normal 3 transaction success num is " - + (afterNormal3Balance - beforeNormal3Balance) / sendNromal3Amount); - logger.info("Normal 4 transaction success num is " - + (afterNormal4Balance - beforeNormal4Balance) / sendNromal4Amount); - - Long totalSuccessNum = (afterAttackBalance - beforeAttackBalance) / attackAmount - + (afterNormal1Balance - beforeNormal1Balance) / sendNromal1Amount - + (afterNormal3Balance - beforeNormal3Balance) / sendNromal3Amount - + (afterNormal4Balance - beforeNormal4Balance) / sendNromal4Amount - + (afterNormal2Balance - beforeNormal2Balance) / sendNromal2Amount; - logger.info("Total success transaction is " + Long.toString(totalSuccessNum)); - - Long normaltotalSuccessNum = (afterNormal1Balance - beforeNormal1Balance) / sendNromal1Amount - + (afterNormal3Balance - beforeNormal3Balance) / sendNromal3Amount - + (afterNormal4Balance - beforeNormal4Balance) / sendNromal4Amount - + (afterNormal2Balance - beforeNormal2Balance) / sendNromal2Amount; - logger.info("Total normal success transaction is " + Long.toString(normaltotalSuccessNum)); - - Integer blockTimes = 0; - Integer blockTransNum = 0; - - while (blockTimes < 5) { - blockTimes++; - //Print the current block transaction num. - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentNum = currentBlock.getBlockHeader().getRawData().getNumber(); - logger.info("The block num " + Long.toString(currentNum) - + "total transaction is " + Long.toString(currentBlock.getTransactionsCount())); - //logger.info(Integer.toString(currentBlock.getTransactionsList() - // .get(0).getRawData().getContract(0).getTypeValue())); - - Integer normal1Num = 0; - Integer normal2Num = 0; - Integer normal3Num = 0; - Integer normal4Num = 0; - Integer attackNum = 0; - Long temp = 0L; - for (Integer m = 0; m < currentBlock.getTransactionsCount(); m++) { - try { - temp = currentBlock.getTransactions(m).getRawData().getContract(0).getParameter() - .unpack(TransferContract.class).getAmount(); - } catch (InvalidProtocolBufferException e) { - e.printStackTrace(); - } - if (temp == sendNromal1Amount) { - normal1Num++; - } - if (temp == sendNromal2Amount) { - normal2Num++; - } - if (temp == sendNromal3Amount) { - normal3Num++; - } - if (temp == sendNromal4Amount) { - normal4Num++; - } - if (temp == attackAmount) { - attackNum++; - } - } - logger.info("Block num " + Long.toString(currentNum) + ", Attack num is " - + Integer.toString(attackNum)); - logger.info("Block num " + Long.toString(currentNum) + ", normal 1 num is " - + Integer.toString(normal1Num)); - logger.info("Block num " + Long.toString(currentNum) + ", normal 2 num is " - + Integer.toString(normal2Num)); - logger.info("Block num " + Long.toString(currentNum) + ", normal 3 num is " - + Integer.toString(normal3Num)); - logger.info("Block num " + Long.toString(currentNum) + ", normal 4 num is " - + Integer.toString(normal4Num)); - blockTransNum = blockTransNum + currentBlock.getTransactionsCount(); - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - logger.info("Total block record num is " + Integer.toString(blockTransNum)); - - - } - - /** - * constructor. - */ - - public static Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Protocol.Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - - Long afterBlockNum = 0L; - - while (afterBlockNum < beforeBlockNum) { - Protocol.Block currentBlock1 = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - } - return true; - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - // Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public boolean withdrawBalance(byte[] address, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.WithdrawBalanceContract.Builder builder = Contract.WithdrawBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - Contract.WithdrawBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.withdrawBalance(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } - logger.info("test withdraw" + priKey); - return true; - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/ContinueVote.java b/src/test/java/stest/tron/wallet/fulltest/ContinueVote.java deleted file mode 100644 index a2baab488bf..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/ContinueVote.java +++ /dev/null @@ -1,413 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class ContinueVote { - - //testng001、testng002、testng003、testng004 - - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - - - /* //testng001、testng002、testng003、testng004 - private static final byte[] fromAddress = Base58 - .decodeFromBase58Check("THph9K2M2nLvkianrMGswRhz5hjSA9fuH7");*/ - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - logger.info("Pre fix byte ===== " + WalletClient.getAddressPreFixByte()); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - } - - @Test(enabled = false, threadPoolSize = 30, invocationCount = 30) - public void testVoteWitness() { - ByteString addressBs = ByteString.copyFrom(fromAddress); - Account request = Account.newBuilder().setAddress(addressBs).build(); - AccountNetMessage accountNetMessage = blockingStubFull.getAccountNet(request); - Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - Base58.encode58Check(fromAddress); - logger.info(Base58.encode58Check(fromAddress)); - String voteStr = "TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes"; - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - Account fromInfo = PublicMethed.queryAccount(testKey002, blockingStubFull); - - Boolean ret = false; - Integer i = 0; - while (fromInfo.getBalance() > 100000000) { - randNum = rand.nextInt(30) + 1; - voteStr = "TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes"; - smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, Integer.toString(randNum)); - if (fromInfo.getFrozen(0).getFrozenBalance() < 10000000) { - PublicMethed.freezeBalance(fromAddress, 10000000000L, 3, testKey002, blockingStubFull); - } - ret = voteWitness(smallVoteMap, fromAddress, testKey002); - if (ret) { - logger.info("This vote num is " + Integer.toString(randNum)); - logger.info("Now the fromaddress vote is " + Long.toString(fromInfo - .getVotes(0).getVoteCount())); - logger.info(Integer.toString(i++)); - } - fromInfo = PublicMethed.queryAccount(testKey002, blockingStubFull); - accountNetMessage = blockingStubFull.getAccountNet(request); - logger.info("Now the from net used is " + Long.toString(accountNetMessage.getNetUsed())); - - } - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] addRess, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - final long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - logger.info("address ====== " + ByteArray.toHexString(address)); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Account afterVote = queryAccount(ecKey, searchBlockingStubFull); - //Long afterVoteNum = afterVote.getVotes(0).getVoteCount(); - for (String key : witness.keySet()) { - for (int j = 0; j < afterVote.getVotesCount(); j++) { - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - logger.info(key); - if (key.equals("TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes")) { - logger.info("catch it"); - logger.info(Long.toString(afterVote.getVotes(j).getVoteCount())); - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - //Assert.assertTrue(afterVote.getVotes(j).getVoteCount() == Long - // .parseLong(witness.get(key))); - } - - } - } - return true; - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Block searchCurrentBlock = searchBlockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - Integer wait = 0; - while (searchCurrentBlock.getBlockHeader().getRawData().getNumber() - < currentBlock.getBlockHeader().getRawData().getNumber() + 1 && wait < 30) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("Another fullnode didn't syn the first fullnode data"); - searchCurrentBlock = searchBlockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - wait++; - if (wait == 9) { - logger.info("Didn't syn,skip to next case."); - } - } - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - //logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "afterfrozenbalance =" + Long.toString(afterFrozenBalance) + "beforefrozenbalance = " - + beforeFrozenBalance + "freezebalance = " + Long.toString(freezeBalance)); - //logger.info("afterbandwidth = " + Long.toString(afterBandwidth) + " beforebandwidth = - // " + Long.toString(beforeBandwidth)); - //if ((afterFrozenBalance - beforeFrozenBalance != freezeBalance) || - // (freezeBalance * frozen_duration -(afterBandwidth - beforeBandwidth) !=0)){ - // logger.info("After 20 second, two node still not synchronous"); - // } - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(freezeBalance * frozen_duration - (afterBandwidth - - // beforeBandwidth) <= 1000000); - return true; - - - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/Creatasset.java b/src/test/java/stest/tron/wallet/fulltest/Creatasset.java deleted file mode 100644 index 969a24ac0bb..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/Creatasset.java +++ /dev/null @@ -1,204 +0,0 @@ -package stest.tron.wallet.fulltest; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class Creatasset { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final String testKey003 = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final String tooLongDescription = - "1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqa" - + "zxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvq" - + "azxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcxswedcv"; - private static final String tooLongUrl = - "qaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqasw1qazxswedcvqazxswedcv" - + "qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedc" - + "vqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqaz" - + "xswedcvqazxswedcvqazxswedcwedcv"; - - - private static final long now = System.currentTimeMillis(); - private static String name = "c_" + Long.toString(now); - long totalSupply = now; - private static final long sendAmount = 1025000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 30000L; - Long publicFreeAssetNetLimit = 30000L; - String description = "f"; - String url = "h"; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset016Address = ecKey1.getAddress(); - String testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - logger.info(testKeyForAssetIssue016); - logger.info(transferAssetCreateKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - //@Test(enabled = false) - @Test(enabled = false, threadPoolSize = 20, invocationCount = 20) - public void createAssetissue() throws InterruptedException { - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset016Address = ecKey1.getAddress(); - String testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Account fromAccountInfo = PublicMethed.queryAccount(testKey002, blockingStubFull); - //Assert.assertTrue(PublicMethed.freezeBalance(fromAddress,100000000, 3, testKey002, - // blockingStubFull)); - - Integer i = 0; - //GrpcAPI.AssetIssueList assetIssueList = blockingStubFull - // .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - //logger.info(Integer.toString(assetIssueList.getAssetIssueCount())); - Boolean ret = false; - Boolean transRet = false; - Boolean updateRet = false; - Boolean participateRet = false; - Random rand = new Random(); - Integer randNum; - - while (fromAccountInfo.getBalance() > 1025000000) { - randNum = rand.nextInt(4); - ManagedChannel channelFull = null; - WalletGrpc.WalletBlockingStub blockingStubFull = null; - fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(randNum); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed - .sendcoin(asset016Address, sendAmount, fromAddress, testKey002, blockingStubFull); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - name = "c_" + Long.toString(System.currentTimeMillis()); - totalSupply = now; - - ret = PublicMethed - .createAssetIssue(asset016Address, name, totalSupply, 1, 1, start, end, 1, description, - url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, 1L, testKeyForAssetIssue016, - blockingStubFull); - - if (ret) { - updateRet = PublicMethed - .updateAsset(asset016Address, tooLongDescription.getBytes(), tooLongUrl.getBytes(), - 4000L, 4000L, - testKeyForAssetIssue016, blockingStubFull); - if (updateRet) { - logger.info("update succesfully"); - } - logger.info(Integer.toString(i++)); - //assetIssueList = blockingStubFull - // .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - //logger.info("assetissue num is " + Integer.toString(assetIssueList.getAssetIssueCount())); - try { - randNum = rand.nextInt(10000) + 3000; - Thread.sleep(randNum); - } catch (InterruptedException e) { - e.printStackTrace(); - } - transRet = PublicMethed.transferAsset(toAddress, name.getBytes(), - 1L, asset016Address, testKeyForAssetIssue016, blockingStubFull); - participateRet = PublicMethed - .participateAssetIssue(asset016Address, name.getBytes(), 1L, toAddress, testKey003, - blockingStubFull); - if (participateRet) { - logger.info("participate success"); - } - logger.info(testKeyForAssetIssue016); - if (transRet) { - logger.info("transfer success"); - } - - } - ecKey1 = new ECKey(Utils.getRandom()); - asset016Address = ecKey1.getAddress(); - testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - fromAccountInfo = PublicMethed.queryAccount(testKey002, blockingStubFull); - ret = false; - updateRet = false; - participateRet = false; - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - try { - //randNum = rand.nextInt(10000) + 3000; - Thread.sleep(6000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - - - } - } - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - /* if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - }*/ - } -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/CreateAddressAndKey.java b/src/test/java/stest/tron/wallet/fulltest/CreateAddressAndKey.java deleted file mode 100644 index c6e9ddde5ee..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/CreateAddressAndKey.java +++ /dev/null @@ -1,244 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import lombok.extern.slf4j.Slf4j; -import org.spongycastle.util.encoders.Base64; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class CreateAddressAndKey { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final String testKey003 = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static String path = "/Users/wangzihe/Documents/"; - private static String filename = "/Users/wangzihe/Sites/postmanUsedKeyandAddress"; - private static String filenameTemp; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = false) - public void beforeClass() { - - } - - @Test(enabled = false) - public void createAddressesAndKeys() { - Integer i = 0; - String accountIndex; - String keyIndex; - JsonObject jsonobject = new JsonObject(); - JsonArray jsonarray = new JsonArray(); - HashMap addressAndKey = new HashMap(); - while (i++ < 600) { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] address = ecKey1.getAddress(); - String addressString = ByteArray.toHexString(address); - byte[] key = ecKey1.getPrivKeyBytes(); - final String keyString = ByteArray.toHexString(key); - - logger.info(ByteArray.toStr(Base64.encode(key))); - logger.info(ByteArray.toStr(Base64.encode(address))); - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", addressString); - userBaseObj2.addProperty("key", keyString); - //userBaseObj2.addProperty("address",ByteArray.toStr(Base64.encode(address))); - //userBaseObj2.addProperty("key", ByteArray.toStr(Base64.encode(key))); - jsonarray.add(userBaseObj2); - } - Gson gson = new Gson(); - String jsonMap = gson.toJson(addressAndKey); - //createFile(filename,jsonobject.toString()); - createFile(filename, jsonarray.toString()); - - } - - @Test(enabled = true) - public void create() { - Integer i = 0; - String accountIndex; - String keyIndex; - JsonObject jsonobject = new JsonObject(); - JsonArray jsonarray = new JsonArray(); - HashMap addressAndKey = new HashMap(); - while (i++ < 600) { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] address = ecKey1.getAddress(); - String key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ArrayList accountList = new ArrayList(); - accountList = PublicMethed.getAddressInfo(key); - JsonObject userBaseObj2 = new JsonObject(); - userBaseObj2.addProperty("address", accountList.get(1)); - userBaseObj2.addProperty("key", accountList.get(0)); - jsonarray.add(userBaseObj2); - } - Gson gson = new Gson(); - String jsonMap = gson.toJson(addressAndKey); - //createFile(filename,jsonobject.toString()); - createFile(filename, jsonarray.toString()); - - } - - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - } - - - /** - * constructor. - */ - public static boolean createFile(String fileName, String filecontent) { - Boolean bool = false; - filenameTemp = fileName;//文件路径+名称+文件类型 - File file = new File(filenameTemp); - try { - //如果文件不存在,则创建新的文件 - if (!file.exists()) { - file.createNewFile(); - bool = true; - System.out.println("success create file,the file is " + filenameTemp); - //创建文件成功后,写入内容到文件里 - writeFileContent(filenameTemp, filecontent); - } else { - clearInfoForFile(filenameTemp); - writeFileContent(filenameTemp, filecontent); - - } - } catch (Exception e) { - e.printStackTrace(); - - } - - return bool; - } - - - /** - * constructor. - */ - public static void clearInfoForFile(String fileName) { - File file = new File(fileName); - try { - if (!file.exists()) { - file.createNewFile(); - } - FileWriter fileWriter = new FileWriter(file); - fileWriter.write(""); - fileWriter.flush(); - fileWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * constructor. - */ - public static boolean writeFileContent(String filepath, String newstr) throws IOException { - Boolean bool = false; - String filein = newstr + "\r\n"; - String temp = ""; - - FileInputStream fis = null; - InputStreamReader isr = null; - BufferedReader br = null; - FileOutputStream fos = null; - PrintWriter pw = null; - try { - File file = new File(filepath); - fis = new FileInputStream(file); - isr = new InputStreamReader(fis); - br = new BufferedReader(isr); - StringBuffer buffer = new StringBuffer(); - - for (int i = 0; (temp = br.readLine()) != null; i++) { - buffer.append(temp); - buffer = buffer.append(System.getProperty("line.separator")); - } - buffer.append(filein); - - fos = new FileOutputStream(file); - pw = new PrintWriter(fos); - pw.write(buffer.toString().toCharArray()); - pw.flush(); - bool = true; - } catch (Exception e) { - // TODO: handle exception - e.printStackTrace(); - } finally { - if (pw != null) { - pw.close(); - } - if (fos != null) { - fos.close(); - } - if (br != null) { - br.close(); - } - if (isr != null) { - isr.close(); - } - if (fis != null) { - fis.close(); - } - } - return bool; - } - - /** - * constructor. - */ - - public static boolean delFile(String fileName) { - Boolean bool = false; - filenameTemp = path + fileName + ".txt"; - File file = new File(filenameTemp); - try { - if (file.exists()) { - file.delete(); - bool = true; - } - } catch (Exception e) { - // TODO: handle exception - } - return bool; - } -} - diff --git a/src/test/java/stest/tron/wallet/fulltest/FreezeAndSendcoin.java b/src/test/java/stest/tron/wallet/fulltest/FreezeAndSendcoin.java deleted file mode 100644 index 298c1a0b941..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/FreezeAndSendcoin.java +++ /dev/null @@ -1,330 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class FreezeAndSendcoin { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final String testKey003 = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private final Long sendAmount = 10000000L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] freezeAddress = ecKey1.getAddress(); - String testKeyForFreeze = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] transferAssetAddress = ecKey2.getAddress(); - String transferAssetCreateKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - /* Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - randNum = rand.nextInt(4); - try { - randNum = rand.nextInt(20000); - Thread.sleep(randNum); - } catch (InterruptedException e) { - e.printStackTrace(); - }*/ - - logger.info(testKeyForFreeze); - logger.info(transferAssetCreateKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - //@Test(enabled = false) - - @Test(enabled = false, threadPoolSize = 500, invocationCount = 1000) - public void freezeAndSendcoin() throws InterruptedException { - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] freezeAddress = ecKey1.getAddress(); - String testKeyForFreeze = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - Account toAccountInfo = PublicMethed.queryAccount(testKey003, blockingStubFull); - Account freezeAccountInfo = PublicMethed.queryAccount(testKeyForFreeze, blockingStubFull); - - Integer i = 0; - Boolean ret = false; - Boolean sendRet = false; - Boolean updateRet = false; - Boolean participateRet = false; - Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - - while (toAccountInfo.getBalance() > 10000009L) { - randNum = rand.nextInt(3); - ManagedChannel channelFull = null; - WalletGrpc.WalletBlockingStub blockingStubFull = null; - fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(randNum); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - freezeBalance(freezeAddress, 3000000L, 3L, testKeyForFreeze, blockingStubFull); - PublicMethed - .sendcoin(freezeAddress, sendAmount, toAddress, testKey003, blockingStubFull); - - ret = freezeBalance(freezeAddress, 1000000L, 3L, testKeyForFreeze, blockingStubFull); - freezeBalance(freezeAddress, 1000000L, 3L, testKeyForFreeze, blockingStubFull); - freezeBalance(freezeAddress, 1000000L, 3L, testKeyForFreeze, blockingStubFull); - - if (ret) { - logger.info("New account freeze success " + Integer.toString(i)); - sendRet = PublicMethed.sendcoin(toAddress, 6000000L, freezeAddress, - testKeyForFreeze, blockingStubFull); - if (sendRet) { - logger.info("This account transfer coin back. " + Integer.toString(i)); - freezeAccountInfo = PublicMethed.queryAccount(testKeyForFreeze, blockingStubFull); - logger.info("This account now has balance is " + Long - .toString(freezeAccountInfo.getBalance())); - - } - - } - - unFreezeBalance(freezeAddress, testKeyForFreeze); - withdrawBalance(freezeAddress, testKeyForFreeze); - - ecKey1 = new ECKey(Utils.getRandom()); - freezeAddress = ecKey1.getAddress(); - testKeyForFreeze = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - toAccountInfo = PublicMethed.queryAccount(testKey003, blockingStubFull); - logger.info("Now the toaddress balance is " + Long.toString(toAccountInfo.getBalance())); - NumberMessage beforeGetTotalTransaction = blockingStubFull - .totalTransaction(GrpcAPI.EmptyMessage.newBuilder().build()); - logger.info("Now total transation is " + Long.toString(beforeGetTotalTransaction.getNum())); - ret = false; - sendRet = false; - i++; - - /* if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - try { - //randNum = rand.nextInt(10000) + 3000; - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - }*/ - - } - } - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public static Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Protocol.Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - - Long afterBlockNum = 0L; - - while (afterBlockNum < beforeBlockNum) { - Protocol.Block currentBlock1 = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - } - return true; - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - // Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public boolean withdrawBalance(byte[] address, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.WithdrawBalanceContract.Builder builder = Contract.WithdrawBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - Contract.WithdrawBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.withdrawBalance(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } - logger.info("test withdraw" + priKey); - return true; - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/Fuzzytest.java b/src/test/java/stest/tron/wallet/fulltest/Fuzzytest.java deleted file mode 100644 index 6a81878535c..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/Fuzzytest.java +++ /dev/null @@ -1,242 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountPaginated; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.PaginatedMessage; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.db.Manager; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class Fuzzytest { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final String testKey003 = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static long start; - private static long end; - private static long now = System.currentTimeMillis(); - private static String name = "AssetIssue016_" + Long.toString(now); - private static long totalSupply = now; - private static final long sendAmount = 10000000000L; - private static final long netCostMeasure = 200L; - - Long freeAssetNetLimit = 30000L; - Long publicFreeAssetNetLimit = 30000L; - String description = "for case assetissue016"; - String url = "https://stest.assetissue016.url"; - - private Manager dbManager; - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset017Address = ecKey1.getAddress(); - String testKeyForAssetIssue017 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - - AssetIssueList assetIssueList = blockingStubFull - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(PublicMethed.freezeBalance(fromAddress, 10000000, 3, testKey002, - blockingStubFull)); - while (assetIssueList.getAssetIssueCount() <= 1) { - //Sendcoin to this account - Assert.assertTrue(PublicMethed - .sendcoin(asset017Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - now = System.currentTimeMillis(); - name = "AssetIssue017_" + Long.toString(now); - totalSupply = now; - Assert.assertTrue(createAssetIssue(asset017Address, name, totalSupply, 1, 1, - start, end, 1, description, url, freeAssetNetLimit, publicFreeAssetNetLimit, 1L, - 1L, testKeyForAssetIssue017, blockingStubFull)); - - assetIssueList = blockingStubFull - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - - ecKey1 = new ECKey(Utils.getRandom()); - asset017Address = ecKey1.getAddress(); - testKeyForAssetIssue017 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - } - } - - @Test(enabled = false, threadPoolSize = 5, invocationCount = 5) - public void tooManyChannelFull() { - Integer i = 0; - while (i++ < 20000) { - ManagedChannel channelFull = null; - WalletGrpc.WalletBlockingStub blockingStubFull = null; - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - GrpcAPI.NodeList nodeList = blockingStubFull - .listNodes(GrpcAPI.EmptyMessage.newBuilder().build()); - if (i % 100 == 0) { - logger.info(Integer.toString(i)); - } - - } - - - } - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - /* if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - }*/ - } - - /** - * constructor. - */ - - public static Boolean createAssetIssue(byte[] address, String name, Long totalSupply, - Integer trxNum, Integer icoNum, Long startTime, Long endTime, Integer voteScore, - String description, String url, Long freeAssetNetLimit, Long publicFreeAssetNetLimit, - Long fronzenAmount, Long frozenDay, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(ecKey, blockingStubFull); - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(freeAssetNetLimit); - builder.setPublicFreeAssetNetLimit(publicFreeAssetNetLimit); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Protocol.Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info("failed reason is " + ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public static Protocol.Transaction signTransaction(ECKey ecKey, - Protocol.Transaction transaction) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - if (ecKey == null || ecKey.getPrivKey() == null) { - //logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/ParticipateAssetIssue.java b/src/test/java/stest/tron/wallet/fulltest/ParticipateAssetIssue.java deleted file mode 100644 index 05a45dcf08d..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/ParticipateAssetIssue.java +++ /dev/null @@ -1,356 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.TransferContract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class ParticipateAssetIssue { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final String testKey003 = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "PartAssetIssue_" + Long.toString(now); - long totalSupply = now; - private static final long sendAmount = 10250000000L; - - Long freeAssetNetLimit = 300000000L; - Long publicFreeAssetNetLimit = 300000000L; - String description = "f"; - String url = "h"; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] createAddress = ecKey1.getAddress(); - String testKeyForCreate = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] participateAssetAddress = ecKey2.getAddress(); - String testKeyForParticipate = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private static long beforeCreateAssetIssueBalance; - private static long afterCreateAssetIssueBalance; - private static long afterParticipateAssetIssueBalance; - - private static long start1; - private static long end1; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - logger.info(testKeyForCreate); - logger.info(testKeyForParticipate); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - //Send coin to 2 account. - Assert.assertTrue(PublicMethed.sendcoin(createAddress, sendAmount, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(participateAssetAddress, sendAmount, - fromAddress, testKey002, blockingStubFull)); - //Participate account freeze balance to get bandwidth. - Assert.assertTrue(PublicMethed.freezeBalance(participateAssetAddress, - 10000000L, 3, testKeyForParticipate, blockingStubFull)); - //Create an asset issue. - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(createAddress, name, totalSupply, 1, 1, - start, end, 1, description, url, freeAssetNetLimit, publicFreeAssetNetLimit, - 10L, 10L, testKeyForCreate, blockingStubFull)); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - final Account createInfo = PublicMethed.queryAccount(testKeyForCreate, blockingStubFull); - final Account participateInfo = PublicMethed.queryAccount(testKeyForParticipate, - blockingStubFull); - - Map assetIssueMap = new HashMap(); - - Long temp = 0L; - assetIssueMap = createInfo.getAssetMap(); - for (String key : assetIssueMap.keySet()) { - - logger.info("Name is " + key); - } - for (Long key : assetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - beforeCreateAssetIssueBalance = temp; - start1 = System.currentTimeMillis(); - } - - //@Test(enabled = false) - @Test(enabled = false, threadPoolSize = 250, invocationCount = 250) - public void testParticipateAssetIssue() throws InterruptedException { - Integer i = 0; - Integer randNum; - - while (i < 20) { - randNum = i % 4; - i++; - fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(randNum); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - participateAssetIssue(createAddress, name.getBytes(), - 1, participateAssetAddress, testKeyForParticipate, blockingStubFull); - } - } - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - //Print the duration. - end1 = System.currentTimeMillis(); - logger.info("The time is " + Long.toString(end1 - start1)); - - Account createInfo = PublicMethed.queryAccount(testKeyForCreate, blockingStubFull); - - Map createAssetIssueMap = new HashMap(); - - Long temp = 0L; - createAssetIssueMap = createInfo.getAssetMap(); - for (String key : createAssetIssueMap.keySet()) { - - logger.info("Name is " + key); - } - for (Long key : createAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterCreateAssetIssueBalance = temp; - - temp = 0L; - Account participateInfo = PublicMethed.queryAccount(testKeyForParticipate, blockingStubFull); - Map participateAssetIssueMap = new HashMap(); - participateAssetIssueMap = participateInfo.getAssetMap(); - for (Long key : participateAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterParticipateAssetIssueBalance = temp; - - logger.info("Create account has balance " + Long.toString(beforeCreateAssetIssueBalance) - + " at the beginning"); - logger.info("Create account has balance " + Long.toString(afterCreateAssetIssueBalance) - + " at the end"); - logger.info("Create account reduce balance " + Long.toString(beforeCreateAssetIssueBalance - - afterCreateAssetIssueBalance)); - logger.info("Participate account total success transaction is " - + Long.toString(afterParticipateAssetIssueBalance)); - - Integer blockTimes = 0; - Integer blockTransParticipateNum = 0; - - while (blockTimes < 5) { - blockTimes++; - //Print the current block transaction num. - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentNum = currentBlock.getBlockHeader().getRawData().getNumber(); - logger.info("The block num " + Long.toString(currentNum) - + " total transaction is " + Long.toString(currentBlock.getTransactionsCount())); - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - createInfo = PublicMethed.queryAccount(testKeyForCreate, blockingStubFull); - participateInfo = PublicMethed.queryAccount(testKeyForParticipate, blockingStubFull); - createAssetIssueMap = new HashMap(); - participateAssetIssueMap = new HashMap(); - - temp = 0L; - createAssetIssueMap = createInfo.getAssetMap(); - for (String key : createAssetIssueMap.keySet()) { - - logger.info("Name is " + key); - } - for (Long key : createAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterCreateAssetIssueBalance = temp; - - temp = 0L; - participateAssetIssueMap = participateInfo.getAssetMap(); - for (Long key : participateAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterParticipateAssetIssueBalance = temp; - - logger.info("Create account has balance " + Long.toString(beforeCreateAssetIssueBalance) - + "at the beginning"); - logger.info("Create account has balance " + Long.toString(afterCreateAssetIssueBalance) - + "at the end"); - logger.info("Participate account total success transaction is " - + Long.toString(afterParticipateAssetIssueBalance)); - - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public static boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, - byte[] from, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public static Protocol.Transaction signTransaction(ECKey ecKey, - Protocol.Transaction transaction) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - if (ecKey == null || ecKey.getPrivKey() == null) { - //logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public static boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - //logger.info("transaction == null"); - } else { - //logger.info("transaction.getRawData().getContractCount() == 0"); - } - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - //logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - //Protocol.Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/SuperWitnessAllowance.java b/src/test/java/stest/tron/wallet/fulltest/SuperWitnessAllowance.java deleted file mode 100644 index 35fa0826f53..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/SuperWitnessAllowance.java +++ /dev/null @@ -1,405 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.WitnessList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class SuperWitnessAllowance { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - - - /* //testng001、testng002、testng003、testng004 - private static final byte[] fromAddress = Base58 - .decodeFromBase58Check("THph9K2M2nLvkianrMGswRhz5hjSA9fuH7");*/ - private static final byte[] INVAILD_ADDRESS = Base58 - .decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - - private static final Long costForCreateWitness = 10009000000L; - String createWitnessUrl = "http://www.createwitnessurl.com"; - String updateWitnessUrl = "http://www.updatewitnessurl.com"; - String nullUrl = ""; - String spaceUrl = " ##################~!@#$%^&*()_+}{|:'/.,<>?|]=-"; - byte[] createUrl = createWitnessUrl.getBytes(); - byte[] updateUrl = updateWitnessUrl.getBytes(); - byte[] wrongUrl = nullUrl.getBytes(); - byte[] updateSpaceUrl = spaceUrl.getBytes(); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - logger.info(lowBalTest); - logger.info(ByteArray.toHexString(PublicMethed.getFinalAddress(lowBalTest))); - logger.info(Base58.encode58Check(PublicMethed.getFinalAddress(lowBalTest))); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test - public void testInvaildToApplyBecomeWitness() { - Assert.assertFalse(createWitness(INVAILD_ADDRESS, createUrl, testKey002)); - } - - //@Test(enabled = true,threadPoolSize = 10, invocationCount = 10) - @Test(enabled = false) - public void testCreate130Witness() { - WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - WitnessList witnessList = result.get(); - while (witnessList.getWitnessesCount() < 130) { - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - logger.info(lowBalTest); - Assert.assertTrue(sendcoin(lowBalAddress, costForCreateWitness, fromAddress, testKey002)); - Assert.assertTrue(PublicMethed.freezeBalance(lowBalAddress, 1000000, - 3, lowBalTest, blockingStubFull)); - Assert.assertTrue(createWitness(lowBalAddress, createUrl, lowBalTest)); - String voteStr = Base58.encode58Check(PublicMethed.getFinalAddress(lowBalTest)); - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - Assert.assertTrue(voteWitness(smallVoteMap, lowBalAddress, lowBalTest)); - witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - result = Optional.ofNullable(witnesslist); - witnessList = result.get(); - - } - - } - - //@Test(enabled = true,threadPoolSize = 10, invocationCount = 10) - @Test(enabled = false) - public void testQueryAllowance() { - WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - WitnessList witnessList = result.get(); - Integer allowanceNum = 0; - for (Integer i = 0; i < witnessList.getWitnessesCount(); i++) { - /* witnessList.getWitnesses(i).getAddress(); - witnessList.getWitnesses(i).getAddress(); - witnessList.getWitnesses(i).getAddress(); - witnessList.getWitnesses(i).getAddress();*/ - ByteString addressBs = witnessList.getWitnesses(i).getAddress(); - Account request = Account.newBuilder().setAddress(addressBs).build(); - request = blockingStubFull.getAccount(request); - if (request.getAllowance() > 0) { - allowanceNum++; - } - logger.info("Account " + Integer.toString(i) + " allowance is " + Long.toString(request - .getAllowance())); - - } - logger.info("Allowance num is " + Integer.toString(allowanceNum)); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - - public Boolean createWitness(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - - } - - /** - * constructor. - */ - - public Boolean updateWitness(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessUpdateContract.Builder builder = Contract.WitnessUpdateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUpdateUrl(ByteString.copyFrom(url)); - Contract.WitnessUpdateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - logger.info("response.getRestult() == false"); - return false; - } else { - return true; - } - - } - - /** - * constructor. - */ - - public Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey) { - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Protocol.Transaction signTransaction(ECKey ecKey, Protocol.Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] addRess, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Account beforeVote = PublicMethed.queryAccount(priKey, blockingStubFull); - //Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - final long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - logger.info("address ====== " + ByteArray.toHexString(address)); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //Long afterVoteNum = afterVote.getVotes(0).getVoteCount(); - return true; - } -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/TransferAssetIssue.java b/src/test/java/stest/tron/wallet/fulltest/TransferAssetIssue.java deleted file mode 100644 index f163baf6ca6..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/TransferAssetIssue.java +++ /dev/null @@ -1,381 +0,0 @@ -package stest.tron.wallet.fulltest; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; -import stest.tron.wallet.common.client.utils.TransactionUtils; - - -@Slf4j -public class TransferAssetIssue { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final String testKey003 = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "PartAssetIssue_" + Long.toString(now); - long totalSupply = now; - private static final long sendAmount = 10250000000L; - - Long freeAssetNetLimit = 300000000L; - Long publicFreeAssetNetLimit = 300000000L; - String description = "f"; - String url = "h"; - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] createAddress = ecKey1.getAddress(); - String testKeyForCreate = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] participateAssetAddress = ecKey2.getAddress(); - String testKeyForParticipate = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private static long beforeCreateAssetIssueBalance; - private static long afterCreateAssetIssueBalance; - private static long afterParticipateAssetIssueBalance; - - private static long start1; - private static long end1; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - logger.info(testKeyForCreate); - logger.info(testKeyForParticipate); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - //Send coin to 2 account. - Assert.assertTrue(PublicMethed.sendcoin(createAddress, sendAmount, - fromAddress, testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(participateAssetAddress, - sendAmount, fromAddress, testKey002, blockingStubFull)); - //Participate account freeze balance to get bandwidth. - Assert.assertTrue(PublicMethed.freezeBalance(participateAssetAddress, 10000000L, 3, - testKeyForParticipate, blockingStubFull)); - //Create an asset issue. - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(createAddress, name, totalSupply, 1, 1, - start, end, 1, description, url, freeAssetNetLimit, publicFreeAssetNetLimit, - 10L, 10L, testKeyForCreate, blockingStubFull)); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - final Account createInfo = PublicMethed.queryAccount(testKeyForCreate, blockingStubFull); - final Account participateInfo = PublicMethed.queryAccount(testKeyForParticipate, - blockingStubFull); - - Map assetIssueMap = new HashMap(); - - Long temp = 0L; - assetIssueMap = createInfo.getAssetMap(); - for (String key : assetIssueMap.keySet()) { - - logger.info("Name is " + key); - } - for (Long key : assetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - beforeCreateAssetIssueBalance = temp; - start1 = System.currentTimeMillis(); - } - - //@Test(enabled = false) - @Test(enabled = false, threadPoolSize = 200, invocationCount = 200) - public void transferAssetIssue() throws InterruptedException { - Integer i = 0; - Integer randNum; - - while (i < 20) { - randNum = i % 4; - i++; - fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(randNum); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - transferAsset(participateAssetAddress, name.getBytes(), 1, - createAddress, testKeyForCreate, blockingStubFull); - } - } - - /** - * constructor. - */ - - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - //Print the duration. - end1 = System.currentTimeMillis(); - logger.info("The time is " + Long.toString(end1 - start1)); - - Map createAssetIssueMap = new HashMap(); - - Long temp = 0L; - Account createInfo = PublicMethed.queryAccount(testKeyForCreate, blockingStubFull); - createAssetIssueMap = createInfo.getAssetMap(); - for (String key : createAssetIssueMap.keySet()) { - - logger.info("Name is " + key); - } - for (Long key : createAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterCreateAssetIssueBalance = temp; - - temp = 0L; - Account participateInfo = PublicMethed.queryAccount(testKeyForParticipate, blockingStubFull); - Map participateAssetIssueMap = new HashMap(); - participateAssetIssueMap = participateInfo.getAssetMap(); - for (Long key : participateAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterParticipateAssetIssueBalance = temp; - - logger.info("Create account has balance " + Long.toString(beforeCreateAssetIssueBalance) - + " at the beginning"); - logger.info("Create account has balance " + Long.toString(afterCreateAssetIssueBalance) - + " at the end"); - logger.info("Create account reduce balance " + Long.toString(beforeCreateAssetIssueBalance - - afterCreateAssetIssueBalance)); - logger.info("Transfer account total success transaction is " - + Long.toString(afterParticipateAssetIssueBalance)); - - Integer blockTimes = 0; - Integer blockTransParticipateNum = 0; - Integer useNet = 0; - Integer useFee = 0; - - while (blockTimes < 5) { - blockTimes++; - //Print the current block transaction num. - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentNum = currentBlock.getBlockHeader().getRawData().getNumber(); - for (Integer m = 0; m < currentBlock.getTransactionsCount(); m++) { - logger.info(currentBlock.getTransactions(m).getRetList().toString()); - String txId = ByteArray.toHexString(Sha256Hash.hash(currentBlock.getTransactions(m) - .getRawData().toByteArray())); - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - Transaction transaction = blockingStubFull.getTransactionById(request); - Optional getTransactionById = Optional.ofNullable(transaction); - if (getTransactionById.get().getRet(0).getFee() > 0) { - logger.info(Long.toString(getTransactionById.get().getRet(0).getFee())); - useFee++; - } else { - logger.info("No use fee"); - useNet++; - } - } - - logger.info("The block num " + Long.toString(currentNum) - + " total transaction is " + Long.toString(currentBlock.getTransactionsCount())); - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - logger.info("Use Net num is " + Integer.toString(useNet)); - logger.info("Use Fee num is " + Integer.toString(useFee)); - - createInfo = PublicMethed.queryAccount(testKeyForCreate, blockingStubFull); - participateInfo = PublicMethed.queryAccount(testKeyForParticipate, blockingStubFull); - createAssetIssueMap = new HashMap(); - participateAssetIssueMap = new HashMap(); - - temp = 0L; - createAssetIssueMap = createInfo.getAssetMap(); - for (String key : createAssetIssueMap.keySet()) { - - logger.info("Name is " + key); - } - for (Long key : createAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterCreateAssetIssueBalance = temp; - - temp = 0L; - participateAssetIssueMap = participateInfo.getAssetMap(); - for (Long key : participateAssetIssueMap.values()) { - logger.info("Balance are " + Long.toString(key)); - temp = key; - } - afterParticipateAssetIssueBalance = temp; - - logger.info("Create account has balance " + Long.toString(beforeCreateAssetIssueBalance) - + "at the beginning"); - logger.info("Create account has balance " + Long.toString(afterCreateAssetIssueBalance) - + "at the end"); - logger.info("Participate account total success transaction is " - + Long.toString(afterParticipateAssetIssueBalance)); - - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - - public static boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, - byte[] from, String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public static Protocol.Transaction signTransaction(ECKey ecKey, - Protocol.Transaction transaction) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - if (ecKey == null || ecKey.getPrivKey() == null) { - //logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public static boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - if (transaction == null) { - //logger.info("transaction == null"); - } else { - //logger.info("transaction.getRawData().getContractCount() == 0"); - } - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - //logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - //Protocol.Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/TronDice.java b/src/test/java/stest/tron/wallet/fulltest/TronDice.java deleted file mode 100644 index 3791021ba6a..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/TronDice.java +++ /dev/null @@ -1,150 +0,0 @@ -package stest.tron.wallet.fulltest; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TronDice { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - byte[] contractAddress; - Long maxFeeLimit = 1000000000L; - Optional infoById = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract008Address = ecKey1.getAddress(); - String contract008Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ArrayList txidList = new ArrayList(); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(contract008Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - PublicMethed.printAddress(testKey002); - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract008Address, - blockingStubFull); - - - } - - @Test(enabled = true, threadPoolSize = 30, invocationCount = 30) - public void tronDice() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] tronDiceAddress = ecKey1.getAddress(); - String tronDiceKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed - .sendcoin(tronDiceAddress, 100000000000L, fromAddress, testKey002, blockingStubFull); - String contractName = "TronDice"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TronDice_tronDice"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TronDice_tronDice"); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", - maxFeeLimit, 1000000000L, 100, null, tronDiceKey, tronDiceAddress, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - Assert.assertTrue(smartContract.getAbi() != null); - - String txid; - - for (Integer i = 0; i < 100; i++) { - String initParmes = "\"" + "10" + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "rollDice(uint256)", initParmes, false, - 1000000, maxFeeLimit, tronDiceAddress, tronDiceKey, blockingStubFull); - logger.info(txid); - txidList.add(txid); - - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - try { - Thread.sleep(20000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Integer successTimes = 0; - Integer failedTimes = 0; - Integer totalTimes = 0; - for (String txid1 : txidList) { - totalTimes++; - infoById = PublicMethed.getTransactionInfoById(txid1, blockingStubFull); - if (infoById.get().getBlockNumber() > 3523732) { - logger.info("blocknum is " + infoById.get().getBlockNumber()); - successTimes++; - } else { - failedTimes++; - } - } - logger.info("Total times is " + totalTimes.toString()); - logger.info("success times is " + successTimes.toString()); - logger.info("failed times is " + failedTimes.toString()); - logger.info("success percent is " + successTimes / totalTimes); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/fulltest/TvmContract.java b/src/test/java/stest/tron/wallet/fulltest/TvmContract.java deleted file mode 100644 index 290604a26e2..00000000000 --- a/src/test/java/stest/tron/wallet/fulltest/TvmContract.java +++ /dev/null @@ -1,156 +0,0 @@ -package stest.tron.wallet.fulltest; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TvmContract { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] contract008Address = ecKey1.getAddress(); - String contract008Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - PublicMethed.printAddress(contract008Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.sendcoin(contract008Address, 500000000L, fromAddress, - testKey002, blockingStubFull)); - logger.info(Long.toString(PublicMethed.queryAccount(contract008Key, blockingStubFull) - .getBalance())); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(contract008Address, 1000000L, - 3, 1, contract008Key, blockingStubFull)); - Assert.assertTrue(PublicMethed.buyStorage(50000000L, contract008Address, contract008Key, - blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalance(contract008Address, 5000000L, - 3, contract008Key, blockingStubFull)); - - } - - @Test(enabled = false) - public void deployErc721CryptoKitties() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(contract008Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long storageLimit = accountResource.getStorageLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Long storageUsage = accountResource.getStorageUsed(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - logger.info("before storage limit is " + Long.toString(storageLimit)); - logger.info("before storage usaged is " + Long.toString(storageUsage)); - Long maxFeeLimit = 50000000L; - String contractName = "ERC721"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TvmContract_deployErc721CryptoKitties"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TvmContract_deployErc721CryptoKitties"); - Long m = 0L; - Long freeNet; - accountResource = PublicMethed.getAccountResource(contract008Address, blockingStubFull); - Long net = accountResource.getFreeNetUsed(); - Account account = PublicMethed.queryAccount(contract008Key, blockingStubFull); - Long netUsed = account.getNetUsage(); - logger.info("before net used is " + Long.toString(netUsed)); - logger.info("before balance is " + account.getBalance()); - - for (Integer i = 0; i < 1; i++) { - byte[] contractAddress = PublicMethed.deployContract("1", abi, code, "", - 30000000L, 0L, 1, null, contract008Key, contract008Address, blockingStubFull); - accountResource = PublicMethed.getAccountResource(contract008Address, blockingStubFull); - freeNet = accountResource.getFreeNetUsed(); - energyUsage = accountResource.getEnergyUsed(); - logger.info( - "Time " + Integer.toString(i) + ": energy usage is " + Long.toString(energyUsage - m)); - logger.info("Time " + Integer.toString(i) + ": free net used is " + Long - .toString(freeNet - net)); - account = PublicMethed.queryAccount(contract008Key, blockingStubFull); - logger.info("after balance is " + account.getBalance()); - netUsed = account.getNetUsage(); - logger.info("after net used is " + Long.toString(netUsed)); - net = freeNet; - m = energyUsage; - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - //SmartContract smartContract = PublicMethed.getContract(contractAddress,blockingStubFull); - - //Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - //Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - //Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - //logger.info(smartContract.getName()); - //logger.info(smartContract.getAbi().toString()); - accountResource = PublicMethed.getAccountResource(contract008Address, blockingStubFull); - energyLimit = accountResource.getEnergyLimit(); - storageLimit = accountResource.getStorageLimit(); - energyUsage = accountResource.getEnergyUsed(); - storageUsage = accountResource.getStorageUsed(); - //Assert.assertTrue(storageUsage > 0); - //Assert.assertTrue(storageLimit > 0); - //Assert.assertTrue(energyLimit > 0); - //Assert.assertTrue(energyUsage > 0); - - logger.info("after energy limit is " + Long.toString(energyLimit)); - logger.info("after energy usage is " + Long.toString(energyUsage)); - logger.info("after storage limit is " + Long.toString(storageLimit)); - logger.info("after storage usaged is " + Long.toString(storageUsage)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign001.java b/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign001.java deleted file mode 100644 index e15ad7155e3..00000000000 --- a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign001.java +++ /dev/null @@ -1,353 +0,0 @@ -package stest.tron.wallet.mutisign; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private static final long now = System.currentTimeMillis(); - private static String name = "MutiSign001_" + Long.toString(now); - private static final long totalSupply = now; - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] participateAddress = ecKey4.getAddress(); - String participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void testMutiSign1CreateAssetissue() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 3; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin + 2048000000L, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - - Long start = System.currentTimeMillis() + 5000; - Long end = System.currentTimeMillis() + 1000000000; - logger.info("try create asset issue"); - - txid = PublicMethedForMutiSign - .createAssetIssueForTransactionId(ownerAddress, name, totalSupply, 1, - 1, start, end, 1, description, url, 2000L, 2000L, - 1L, 1L, ownerKey, blockingStubFull, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee + 1024_000000L); - - logger.info(" create asset end"); - } - - /** - * constructor. - */ - - @Test(enabled = true) - public void testMutiSign2TransferAssetissue() { - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.printAddress(manager1Key); - Account getAssetIdFromOwnerAccount; - getAssetIdFromOwnerAccount = PublicMethed.queryAccount(ownerAddress, blockingStubFull); - assetAccountId1 = getAssetIdFromOwnerAccount.getAssetIssuedID(); - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - String txid = PublicMethedForMutiSign.transferAssetForTransactionId(manager1Address, - assetAccountId1.toByteArray(), 10, ownerAddress, ownerKey, blockingStubFull, - ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - /** - * constructor. - */ - - @Test(enabled = true) - public void testMutiSign3ParticipateAssetissue() { - ecKey4 = new ECKey(Utils.getRandom()); - participateAddress = ecKey4.getAddress(); - participateKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 2; - - Assert.assertTrue( - PublicMethed.sendcoin(participateAddress, needCoin + 2048000000L, fromAddress, testKey002, - blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Long balanceBefore = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - ownerKeyString[0] = participateKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(participateKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, participateAddress, - participateKey, blockingStubFull, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - - txid = PublicMethedForMutiSign.participateAssetIssueForTransactionId(ownerAddress, - assetAccountId1.toByteArray(), 10, participateAddress, participateKey, 0, - blockingStubFull, ownerKeyString); - - Assert.assertNotNull(txid); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - balanceAfter = PublicMethed.queryAccount(participateAddress, blockingStubFull) - .getBalance(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netFee = infoById.get().getReceipt().getNetFee(); - fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee + 10); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - /** - * constructor. - */ - - @Test(enabled = true) - public void testMutiSign4updateAssetissue() { - url = "MutiSign001_update_url" + Long.toString(now); - ownerKeyString[0] = ownerKey; - description = "MutiSign001_update_description" + Long.toString(now); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - String txid = PublicMethedForMutiSign - .updateAssetForTransactionId(ownerAddress, description.getBytes(), url.getBytes(), 100L, - 100L, ownerKey, 2, blockingStubFull, permissionKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + multiSignFee); - } - - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign003.java b/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign003.java deleted file mode 100644 index 275aa1e6d1b..00000000000 --- a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign003.java +++ /dev/null @@ -1,210 +0,0 @@ -package stest.tron.wallet.mutisign; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[3]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] newAddress = ecKey4.getAddress(); - String newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void testMutiSignForAccount() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - ecKey4 = new ECKey(Utils.getRandom()); - newAddress = ecKey4.getAddress(); - newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - long needCoin = updateAccountPermissionFee * 1 + multiSignFee * 9; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needCoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - ownerKeyString[2] = manager2Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":3,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - String txid = PublicMethedForMutiSign - .accountPermissionUpdateForTransactionId(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - final String updateName = Long.toString(System.currentTimeMillis()); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertNotNull(txid); - - Optional infoById = PublicMethed - .getTransactionInfoById(txid, blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - long energyFee = infoById.get().getReceipt().getEnergyFee(); - long netFee = infoById.get().getReceipt().getNetFee(); - long fee = infoById.get().getFee(); - - logger.info("balanceAfter: " + balanceAfter); - logger.info("energyFee: " + energyFee); - logger.info("netFee: " + netFee); - logger.info("fee: " + fee); - - Assert.assertEquals(balanceBefore - balanceAfter, fee); - Assert.assertEquals(fee, energyFee + netFee + updateAccountPermissionFee); - - balanceBefore = balanceAfter; - - Assert.assertTrue(PublicMethedForMutiSign.createAccount( - ownerAddress, newAddress, ownerKey, blockingStubFull, ownerKeyString)); - - Assert.assertTrue(PublicMethedForMutiSign.sendcoinWithPermissionId( - newAddress, 100L, ownerAddress, 2, ownerKey, blockingStubFull, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceWithPermissionId( - ownerAddress, 1000000L, 0, 0, ownerKey, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceGetEnergy( - ownerAddress, 1000000L, 0, 1, ownerKey, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.freezeBalanceForReceiver( - ownerAddress, 1000000L, 0, 0, ByteString.copyFrom(newAddress), - ownerKey, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.unFreezeBalance( - ownerAddress, ownerKey, 0, null, blockingStubFull, ownerKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.unFreezeBalanceWithPermissionId( - ownerAddress, ownerKey, 0, newAddress, 2, blockingStubFull, permissionKeyString)); - Assert.assertTrue(PublicMethedForMutiSign.updateAccount( - ownerAddress, updateName.getBytes(), ownerKey, blockingStubFull, ownerKeyString)); - - String voteStr = Base58.encode58Check(witnessAddress); - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - Assert.assertTrue(PublicMethedForMutiSign.voteWitness( - smallVoteMap, ownerAddress, ownerKey, blockingStubFull, ownerKeyString)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceAfter: " + balanceAfter); - Assert.assertEquals(balanceBefore - balanceAfter, multiSignFee * 9 + 1000000 + 100); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign004.java b/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign004.java deleted file mode 100644 index 594bd164881..00000000000 --- a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign004.java +++ /dev/null @@ -1,208 +0,0 @@ -package stest.tron.wallet.mutisign; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class WalletTestMutiSign004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - ArrayList txidList = new ArrayList(); - - Optional infoById = null; - Long beforeTime; - Long afterTime; - Long beforeBlockNum; - Long afterBlockNum; - Block currentBlock; - Long currentBlockNum; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[2]; - String accountPermissionJson = ""; - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true, threadPoolSize = 1, invocationCount = 1) - public void testMutiSignForSmartContract() { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - long needcoin = updateAccountPermissionFee + multiSignFee * 3; - - Assert.assertTrue( - PublicMethed.sendcoin(ownerAddress, needcoin + 100000000L, fromAddress, testKey002, - blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 0, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalanceForReceiver(fromAddress, 1000000000, 0, 1, ByteString.copyFrom(ownerAddress), - testKey002, blockingStubFull)); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(ownerAddress, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = ownerKey; - ownerKeyString[1] = manager1Key; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - randNum = rand.nextInt(4000); - - Long maxFeeLimit = 1000000000L; - //String contractName = "StorageAndCpu" + Integer.toString(randNum); - String filePath = "./src/test/resources/soliditycode/walletTestMutiSign004.sol"; - String contractName = "timeoutTest"; - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - byte[] contractAddress = PublicMethedForMutiSign.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, ownerKey, ownerAddress, blockingStubFull, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi().toString() != null); - String txid; - String initParmes = "\"" + "930" + "\""; - txid = PublicMethedForMutiSign.triggerContract(contractAddress, - "testUseCpu(uint256)", initParmes, false, - 0, maxFeeLimit, ownerAddress, ownerKey, blockingStubFull, ownerKeyString); - PublicMethed.waitProduceNextBlock(blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - logger.info("Txid is " + txid); - logger.info("Trigger energytotal is " + infoById.get().getReceipt().getEnergyUsageTotal()); - - Assert.assertTrue(infoById.get().getBlockNumber() > 0); - PublicMethedForMutiSign.updateSettingWithPermissionId(contractAddress, 50, ownerKey, - ownerAddress, 0, blockingStubFull, ownerKeyString); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - long balanceAfter = PublicMethed.queryAccount(ownerAddress, blockingStubFull).getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertEquals(balanceBefore - balanceAfter, needcoin); - - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, ownerAddress, blockingStubFull)); - Assert.assertTrue( - PublicMethed.unFreezeBalance(fromAddress, testKey002, 1, ownerAddress, blockingStubFull)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign005.java b/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign005.java deleted file mode 100644 index 0928aa92217..00000000000 --- a/src/test/java/stest/tron/wallet/mutisign/WalletTestMutiSign005.java +++ /dev/null @@ -1,180 +0,0 @@ -package stest.tron.wallet.mutisign; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - - -@Slf4j -public class WalletTestMutiSign005 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - - private long multiSignFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.multiSignFee"); - private long updateAccountPermissionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.updateAccountPermissionFee"); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[1]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void testMutiSignForProposal() { - long needcoin = updateAccountPermissionFee + multiSignFee * 3; - Assert.assertTrue(PublicMethed.sendcoin(witness001Address, needcoin + 10000000L, - fromAddress, testKey002, blockingStubFull)); - - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceBefore = PublicMethed.queryAccount(witness001Address, blockingStubFull) - .getBalance(); - logger.info("balanceBefore: " + balanceBefore); - - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - ownerKeyString[0] = witnessKey001; - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":2,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":2}]}," - + "\"witness_permission\":{\"type\":1,\"permission_name\":\"owner\",\"threshold\":1,\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(witnessKey001) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate( - accountPermissionJson, witness001Address, witnessKey001, - blockingStubFull, ownerKeyString); - - //Create a proposal - - PublicMethed.waitProduceNextBlock(blockingStubFull); - HashMap proposalMap = new HashMap(); - proposalMap.put(0L, 81000L); - Assert.assertTrue( - PublicMethedForMutiSign.createProposalWithPermissionId(witness001Address, witnessKey001, - proposalMap, 2, blockingStubFull, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Get proposal list - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer proposalId = listProposals.get().getProposalsCount(); - logger.info(Integer.toString(proposalId)); - - Assert.assertTrue(PublicMethedForMutiSign.approveProposalWithPermission( - witness001Address, witnessKey001, proposalId, - true, 2, blockingStubFull, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Delete proposal list after approve - Assert.assertTrue(PublicMethedForMutiSign.deleteProposalWithPermissionId( - witness001Address, witnessKey001, proposalId, 2, blockingStubFull, permissionKeyString)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Long balanceAfter = PublicMethed.queryAccount(witness001Address, blockingStubFull) - .getBalance(); - logger.info("balanceAfter: " + balanceAfter); - - Assert.assertTrue(balanceBefore - balanceAfter >= needcoin); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/CreateAccount2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/CreateAccount2Test.java deleted file mode 100644 index 2d6d59941f2..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/CreateAccount2Test.java +++ /dev/null @@ -1,125 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountNetMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class CreateAccount2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static final long now = System.currentTimeMillis(); - private static String name = "AssetIssue012_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - private static final long FREENETLIMIT = 5000L; - private static final long BASELINE = 4800L; - //owner account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] account007Address = ecKey1.getAddress(); - String account007Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - //Wait to be create account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] newAccountAddress = ecKey2.getAddress(); - String newAccountKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(account007Key); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.sendcoin(account007Address, 10000000, - fromAddress, testKey002, blockingStubFull)); - } - - @Test(enabled = true) - public void testCreateAccount2() { - Account accountInfo = PublicMethed.queryAccount(account007Key, blockingStubFull); - final Long beforeBalance = accountInfo.getBalance(); - AccountNetMessage accountNetInfo = PublicMethed.getAccountNet(account007Address, - blockingStubFull); - final Long beforeFreeNet = accountNetInfo.getFreeNetUsed(); - GrpcAPI.Return ret1 = PublicMethed.createAccount2(account007Address, newAccountAddress, - account007Key, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - accountInfo = PublicMethed.queryAccount(account007Key, blockingStubFull); - Long afterBalance = accountInfo.getBalance(); - accountNetInfo = PublicMethed.getAccountNet(account007Address, - blockingStubFull); - Long afterFreeNet = accountNetInfo.getFreeNetUsed(); - logger.info(Long.toString(beforeBalance)); - logger.info(Long.toString(afterBalance)); - //When creator has no bandwidth, he can't use the free net. - Assert.assertTrue(afterFreeNet == beforeFreeNet); - //When the creator has no bandwidth, create a new account should spend 0.1TRX. - Assert.assertTrue(beforeBalance - afterBalance == 100000); - } - - @Test(enabled = true) - public void testExceptionCreateAccount2() { - //Try to create an exist account - GrpcAPI.Return ret1 = PublicMethed - .createAccount2(account007Address, account007Address, account007Key, - blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Account has existed"); - //Try to create an invalid account - byte[] wrongAddress = "wrongAddress".getBytes(); - ret1 = PublicMethed.createAccount2(account007Address, wrongAddress, account007Key, - blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid account address"); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/CreateAssetIssue2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/CreateAssetIssue2Test.java deleted file mode 100644 index ebd6d7cc074..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/CreateAssetIssue2Test.java +++ /dev/null @@ -1,402 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class CreateAssetIssue2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private static final byte[] INVAILD_ADDRESS = Base58 - .decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue001_" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test-assetissue-001"; - String url = "https://github.com/tronprotocol/wallet-cli/assetissue001"; - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] noBandwitchAddress = ecKey.getAddress(); - String noBandwitch = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(ByteArray.toHexString(ecKey.getPrivKeyBytes())); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test() - public void testTransferAssetBandwitchDecreaseWithin10Second2() { - ByteString addressBS1 = ByteString.copyFrom(noBandwitchAddress); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Assert.assertTrue(PublicMethed.sendcoin(noBandwitchAddress, 2048000000, - fromAddress, testKey002, blockingStubFull)); - Long start = System.currentTimeMillis() + 2000000; - Long end = System.currentTimeMillis() + 1000000000; - GrpcAPI.Return ret1 = PublicMethed.createAssetIssue2(noBandwitchAddress, name, totalSupply, 1, - 100, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, noBandwitch, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - } else { - logger.info("This account already create an assetisue"); - Optional queryAssetByAccount1 = Optional.ofNullable(assetIssueList1); - name = ByteArray.toStr(queryAssetByAccount1.get().getAssetIssue(0).getName().toByteArray()); - } - - Assert.assertTrue( - transferAsset(toAddress, name.getBytes(), 100L, noBandwitchAddress, noBandwitch)); - //Transfer Asset failed when transfer to yourself - //Assert.assertFalse(transferAsset2(toAddress, name.getBytes(), 100L, toAddress, testKey003)); - Return ret1 = transferAsset2(toAddress, name.getBytes(), 100L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Cannot transfer asset to yourself."); - //Transfer Asset failed when the transfer amount is large than the asset balance you have. - ret1 = - transferAsset2(fromAddress, name.getBytes(), 9100000000000000000L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : assetBalance is not sufficient."); - //Transfer Asset failed when the transfer amount is 0 - ret1 = transferAsset2(fromAddress, name.getBytes(), 0L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0."); - //Transfer Asset failed when the transfer amount is -1 - ret1 = transferAsset2(fromAddress, name.getBytes(), -1L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0."); - //Transfer failed when you want to transfer to an invalid address - ret1 = transferAsset2(INVAILD_ADDRESS, name.getBytes(), - 1L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid toAddress"); - //Transfer failed when the asset issue name is not correct. - ret1 = - transferAsset2(fromAddress, (name + "wrong").getBytes(), 1L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : No asset !"); - //Transfer success. - ret1 = transferAsset2(fromAddress, name.getBytes(), 1L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - //No freeze asset, try to unfreeze asset failed. - Assert.assertFalse(unFreezeAsset(noBandwitchAddress, noBandwitch)); - logger.info("Test no asset frozen balance, try to unfreeze asset, no exception. Test OK!!!"); - - //Not create asset, try to unfreeze asset failed.No exception. - Assert.assertFalse(unFreezeAsset(toAddress, testKey003)); - logger.info("Test not create asset issue, try to unfreeze asset, no exception. Test OK!!!"); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(20000); - builder.setPublicFreeAssetNetLimit(20000); - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null || transaction.getRawData().getContractCount() == 0"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public Return transferAsset2(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.TransferAssetContract contract = builder.build(); - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.transferAsset2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - //return true; - } - return ret; - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - Contract.UnfreezeAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/CreateTransaction2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/CreateTransaction2Test.java deleted file mode 100644 index 3e9df73731d..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/CreateTransaction2Test.java +++ /dev/null @@ -1,358 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class CreateTransaction2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - - /* //testng001、testng002、testng003、testng004 - private static final byte[] fromAddress = Base58 - .decodeFromBase58Check("THph9K2M2nLvkianrMGswRhz5hjSA9fuH7"); - private static final byte[] toAddress = Base58 - .decodeFromBase58Check("TV75jZpdmP2juMe1dRwGrwpV6AMU6mr1EU");*/ - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] sendAccountAddress = ecKey1.getAddress(); - String sendAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - //receipt account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] receiptAccountAddress = ecKey2.getAddress(); - String receiptAccountKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - - } - - @Test - public void testSendCoin2() { - Assert.assertTrue(PublicMethed.sendcoin(sendAccountAddress, 90000000000L, - fromAddress, testKey002, blockingStubFull)); - - logger.info(receiptAccountKey); - Account sendAccount = PublicMethed.queryAccount(sendAccountKey, blockingStubFull); - Long sendAccountBeforeBalance = sendAccount.getBalance(); - Assert.assertTrue(sendAccountBeforeBalance == 90000000000L); - Account receiptAccount = PublicMethed.queryAccount(receiptAccountKey, blockingStubFull); - Long receiptAccountBeforeBalance = receiptAccount.getBalance(); - Assert.assertTrue(receiptAccountBeforeBalance == 0); - //normal sendcoin2 - Return ret1 = PublicMethed.sendcoin2(receiptAccountAddress, 49880000000L, - sendAccountAddress, sendAccountKey, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - sendAccount = PublicMethed.queryAccount(sendAccountKey, blockingStubFull); - Long sendAccountAfterBalance = sendAccount.getBalance(); - logger.info(Long.toString(sendAccountAfterBalance)); - Assert.assertTrue(sendAccountAfterBalance == 90000000000L - 49880000000L - 100000L); - - receiptAccount = PublicMethed.queryAccount(receiptAccountKey, blockingStubFull); - Long receiptAccountAfterBalance = receiptAccount.getBalance(); - Assert.assertTrue(receiptAccountAfterBalance == 49880000000L); - //Send coin failed due to no enough balance. - ret1 = PublicMethed - .sendcoin2(receiptAccountAddress, 9199999999999999999L, sendAccountAddress, sendAccountKey, - blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Validate TransferContract error, balance is not sufficient."); - //Send coin failed due to the amount is 0. - ret1 = PublicMethed - .sendcoin2(receiptAccountAddress, 0L, sendAccountAddress, sendAccountKey, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0."); - //Send coin failed due to the amount is -1Trx. - ret1 = PublicMethed - .sendcoin2(receiptAccountAddress, -1000000L, sendAccountAddress, sendAccountKey, - blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0."); - - //Send coin to yourself - ret1 = PublicMethed.sendcoin2(sendAccountAddress, 1000000L, sendAccountAddress, sendAccountKey, - blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Cannot transfer trx to yourself."); - //transfer all balance - ret1 = PublicMethed.sendcoin2(receiptAccountAddress, 40119900000L, - sendAccountAddress, sendAccountKey, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - sendAccount = PublicMethed.queryAccount(sendAccountKey, blockingStubFull); - Long sendAccountAfterBalance1 = sendAccount.getBalance(); - logger.info(Long.toString(sendAccountAfterBalance1)); - Assert.assertTrue( - sendAccountAfterBalance1 == 90000000000L - 49880000000L - 100000 - 40119900000L); - - receiptAccount = PublicMethed.queryAccount(receiptAccountKey, blockingStubFull); - Long receiptAccountAfterBalance1 = receiptAccount.getBalance(); - logger.info(Long.toString(receiptAccountAfterBalance1)); - Assert.assertTrue(receiptAccountAfterBalance1 == 49880000000L + 40119900000L); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - - Long afterBlockNum = 0L; - Integer wait = 0; - while (afterBlockNum < beforeBlockNum + 1 && wait < 10) { - Block currentBlock1 = searchBlockingStubFull - .getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - wait++; - try { - Thread.sleep(2000); - logger.info("wait 2 second"); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "beforefronen" + beforeFrozenBalance.toString() + " afterfronzen" + afterFrozenBalance - .toString()); - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(afterBandwidth - beforeBandwidth == freezeBalance * frozen_duration); - return true; - - - } - - /** - * constructor. - */ - - public Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey) { - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/CreateaAndUpdateWitness2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/CreateaAndUpdateWitness2Test.java deleted file mode 100644 index 4ef0b4694f1..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/CreateaAndUpdateWitness2Test.java +++ /dev/null @@ -1,434 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.WitnessList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class CreateaAndUpdateWitness2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - - private static final byte[] INVAILD_ADDRESS = Base58 - .decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private static final Long costForCreateWitness = 9999000000L; - String createWitnessUrl = "http://www.createwitnessurl.com"; - String updateWitnessUrl = "http://www.updatewitnessurl.com"; - String nullUrl = ""; - String spaceUrl = " ##################~!@#$%^&*()_+}{|:'/.,<>?|]=-"; - byte[] createUrl = createWitnessUrl.getBytes(); - byte[] updateUrl = updateWitnessUrl.getBytes(); - byte[] wrongUrl = nullUrl.getBytes(); - byte[] updateSpaceUrl = spaceUrl.getBytes(); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - logger.info(lowBalTest); - logger.info(ByteArray.toHexString(PublicMethed.getFinalAddress(lowBalTest))); - logger.info(Base58.encode58Check(PublicMethed.getFinalAddress(lowBalTest))); - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test - public void testInvaildToApplyBecomeWitness2() { - GrpcAPI.Return ret1 = createWitness2(INVAILD_ADDRESS, createUrl, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid address"); - } - - @Test(enabled = true) - public void testCreateWitness2() { - //If you are already is witness, apply failed - createWitness(fromAddress, createUrl, testKey002); - GrpcAPI.Return ret1 = createWitness2(fromAddress, createUrl, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Witness[415624c12e308b03a1a6b21d9b86e3942fac1ab92b] " - + "has existed"); - //balance is not enouhg,try to create witness. - Assert.assertTrue(sendcoin(lowBalAddress, 1000000L, fromAddress, testKey002)); - ret1 = createWitness2(lowBalAddress, createUrl, lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : balance < AccountUpgradeCost"); - //Send enough coin to the apply account to make that account - // has ability to apply become witness. - WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - WitnessList witnessList = result.get(); - if (result.get().getWitnessesCount() < 6) { - Assert.assertTrue(sendcoin(lowBalAddress, costForCreateWitness, fromAddress, testKey002)); - ret1 = createWitness2(lowBalAddress, createUrl, lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - } - } - - @Test(enabled = true) - public void testUpdateWitness2() { - WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - WitnessList witnessList = result.get(); - if (result.get().getWitnessesCount() < 6) { - //null url, update failed - GrpcAPI.Return ret1 = updateWitness2(lowBalAddress, wrongUrl, lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid url"); - //Content space and special char, update success - ret1 = updateWitness2(lowBalAddress, updateSpaceUrl, lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //update success - ret1 = updateWitness2(lowBalAddress, updateUrl, lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - } else { - logger.info("Update witness case had been test.This time skip it."); - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createWitness(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - - Protocol.Transaction transaction = blockingStubFull.createWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - - } - - /** - * constructor. - */ - - public GrpcAPI.Return createWitness2(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.createWitness2(contract); - - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return response; - } - return ret; - - } - - /** - * constructor. - */ - - public Boolean updateWitness(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessUpdateContract.Builder builder = Contract.WitnessUpdateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUpdateUrl(ByteString.copyFrom(url)); - Contract.WitnessUpdateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - logger.info("response.getRestult() == false"); - return false; - } else { - return true; - } - - } - - /** - * constructor. - */ - - public GrpcAPI.Return updateWitness2(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessUpdateContract.Builder builder = Contract.WitnessUpdateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUpdateUrl(ByteString.copyFrom(url)); - Contract.WitnessUpdateContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.updateWitness2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - logger.info("response.getRestult() == false"); - return response; - } - return ret; - } - - /** - * constructor. - */ - - public Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey) { - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Protocol.Transaction signTransaction(ECKey ecKey, Protocol.Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/FreezeBalance2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/FreezeBalance2Test.java deleted file mode 100644 index 5d3d94a7aee..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/FreezeBalance2Test.java +++ /dev/null @@ -1,482 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class FreezeBalance2Test { - - private final String noFrozenBalanceTestKey = - "8CB4480194192F30907E14B52498F594BD046E21D7C4D8FE866563A6760AC891"; - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] noFrozenAddress = PublicMethed.getFinalAddress(noFrozenBalanceTestKey); - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - } - - @Test(enabled = true) - public void testFreezeBalance2() { - //Freeze failed when freeze amount is large than currently balance. - Return ret1 = freezeBalance2(fromAddress, 9000000000000000000L, 3L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : frozenBalance must be less than accountBalance"); - //Freeze failed when freeze amount less than 1Trx - ret1 = freezeBalance2(fromAddress, 999999L, 3L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : frozenBalance must be more than 1TRX"); - //Freeze failed when freeze duration isn't 3 days. - ret1 = freezeBalance2(fromAddress, 1000000L, 2L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : frozenDuration must be less than 3 days and more than 3 days"); - //Unfreeze balance failed when 3 days hasn't come. - ret1 = unFreezeBalance2(fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : It's not time to unfreeze."); - //Freeze failed when freeze amount is 0. - ret1 = freezeBalance2(fromAddress, 0L, 3L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : frozenBalance must be positive"); - //Freeze failed when freeze amount is -1. - ret1 = freezeBalance2(fromAddress, -1L, 3L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : frozenBalance must be positive"); - //Freeze failed when freeze duration is -1. - ret1 = freezeBalance2(fromAddress, 1000000L, -1L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : frozenDuration must be less than 3 days and more than 3 days"); - //Freeze failed when freeze duration is 0. - ret1 = freezeBalance2(fromAddress, 1000000L, 0L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : frozenDuration must be less than 3 days and more than 3 days"); - - try { - Thread.sleep(16000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //Freeze balance success. - ret1 = PublicMethed.freezeBalance2(fromAddress, 1000000L, 3L, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - } - - @Test(enabled = true) - public void testUnFreezeBalance2() { - //Unfreeze failed when there is no freeze balance. - Return ret1 = unFreezeBalance2(noFrozenAddress, noFrozenBalanceTestKey); - logger.info("Test unfreezebalance"); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : no frozenBalance"); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Block currentBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - - Long afterBlockNum = 0L; - Integer wait = 0; - while (afterBlockNum < beforeBlockNum + 1 && wait < 10) { - Block currentBlock1 = searchBlockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - wait++; - try { - Thread.sleep(2000); - logger.info("wait 2 second"); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "beforefronen" + beforeFrozenBalance.toString() + " afterfronzen" + afterFrozenBalance - .toString()); - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(afterBandwidth - beforeBandwidth == freezeBalance * frozen_duration); - return true; - - - } - - /** - * constructor. - */ - - public Return freezeBalance2(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Block currentBlock = blockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.freezeBalance2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return response; - } - - Long afterBlockNum = 0L; - Integer wait = 0; - while (afterBlockNum < beforeBlockNum + 1 && wait < 10) { - Block currentBlock1 = searchBlockingStubFull.getNowBlock(EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - wait++; - try { - Thread.sleep(2000); - logger.info("wait 2 second"); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "beforefronen" + beforeFrozenBalance.toString() + " afterfronzen" + afterFrozenBalance - .toString()); - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(afterBandwidth - beforeBandwidth == freezeBalance * frozen_duration); - return ret; - - - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Return unFreezeBalance2(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.unfreezeBalance2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return response; - } - return ret; - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByLatestNum2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByLatestNum2Test.java deleted file mode 100644 index 703656fcefc..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByLatestNum2Test.java +++ /dev/null @@ -1,183 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; - -@Slf4j -public class GetBlockByLatestNum2Test { - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void testGetBlockByLatestNum2() { - // - GrpcAPI.BlockExtention currentBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now the block num is " + Long.toString(currentBlockNum) + " Please wait"); - currentBlock = blockingStubFull.getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - NumberMessage numberMessage = NumberMessage.newBuilder().setNum(3).build(); - GrpcAPI.BlockListExtention blockList = blockingStubFull.getBlockByLatestNum2(numberMessage); - Optional getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.isPresent()); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 3); - Assert.assertTrue(getBlockByLatestNum.get().getBlock(0).hasBlockHeader()); - Assert.assertTrue( - getBlockByLatestNum.get().getBlock(1).getBlockHeader().getRawData().getNumber() > 0); - Assert.assertFalse( - getBlockByLatestNum.get().getBlock(2).getBlockHeader().getRawData().getParentHash() - .isEmpty()); - logger.info("TestGetBlockByLatestNum ok!!!"); - Assert.assertFalse(getBlockByLatestNum.get().getBlock(0).getBlockid().isEmpty()); - Assert.assertFalse(getBlockByLatestNum.get().getBlock(1).getBlockid().isEmpty()); - Assert.assertFalse(getBlockByLatestNum.get().getBlock(2).getBlockid().isEmpty()); - } - - @Test(enabled = true) - public void testGetBlockByExceptionNum2() { - GrpcAPI.BlockExtention currentBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now the block num is " + Long.toString(currentBlockNum) + " Please wait"); - currentBlock = blockingStubFull.getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - NumberMessage numberMessage = NumberMessage.newBuilder().setNum(-1).build(); - GrpcAPI.BlockListExtention blockList = blockingStubFull.getBlockByLatestNum2(numberMessage); - Optional getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 0); - //Assert.assertTrue(getBlockByLatestNum.get().getBlock(1).getBlockid().isEmpty()); - - numberMessage = NumberMessage.newBuilder().setNum(0).build(); - blockList = blockingStubFull.getBlockByLatestNum2(numberMessage); - getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 0); - //Assert.assertTrue(getBlockByLatestNum.get().getBlock(1).getBlockid().isEmpty()); - - numberMessage = NumberMessage.newBuilder().setNum(100).build(); - blockList = blockingStubFull.getBlockByLatestNum2(numberMessage); - getBlockByLatestNum = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLatestNum.get().getBlockCount() == 0); - //Assert.assertTrue(getBlockByLatestNum.get().getBlock(10).getBlockid().isEmpty()); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByLimitNext2.java b/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByLimitNext2.java deleted file mode 100644 index a2d960f222c..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByLimitNext2.java +++ /dev/null @@ -1,209 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; - -@Slf4j -public class GetBlockByLimitNext2 { - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true) - public void testGetBlockByLimitNext2() { - // - GrpcAPI.BlockExtention currentBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now has very little block, Please wait"); - currentBlock = blockingStubFull.getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - GrpcAPI.BlockLimit.Builder builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(2); - builder.setEndNum(4); - GrpcAPI.BlockListExtention blockList = blockingStubFull.getBlockByLimitNext2(builder.build()); - Optional getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.isPresent()); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 2); - logger.info(Long.toString( - getBlockByLimitNext.get().getBlock(0).getBlockHeader().getRawData().getNumber())); - logger.info(Long.toString( - getBlockByLimitNext.get().getBlock(1).getBlockHeader().getRawData().getNumber())); - Assert.assertTrue( - getBlockByLimitNext.get().getBlock(0).getBlockHeader().getRawData().getNumber() < 4); - Assert.assertTrue( - getBlockByLimitNext.get().getBlock(1).getBlockHeader().getRawData().getNumber() < 4); - Assert.assertTrue(getBlockByLimitNext.get().getBlock(0).hasBlockHeader()); - Assert.assertTrue(getBlockByLimitNext.get().getBlock(1).hasBlockHeader()); - Assert.assertFalse( - getBlockByLimitNext.get().getBlock(0).getBlockHeader().getRawData().getParentHash() - .isEmpty()); - Assert.assertFalse( - getBlockByLimitNext.get().getBlock(1).getBlockHeader().getRawData().getParentHash() - .isEmpty()); - Assert.assertFalse(getBlockByLimitNext.get().getBlock(0).getBlockid().isEmpty()); - Assert.assertFalse(getBlockByLimitNext.get().getBlock(1).getBlockid().isEmpty()); - } - - @Test(enabled = true) - public void testGetBlockByExceptionLimitNext2() { - GrpcAPI.BlockExtention currentBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - while (currentBlockNum <= 5) { - logger.info("Now has very little block, Please wait"); - currentBlock = blockingStubFull.getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - } - - //From -1 to 1 - GrpcAPI.BlockLimit.Builder builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(-1); - builder.setEndNum(1); - GrpcAPI.BlockListExtention blockList = blockingStubFull.getBlockByLimitNext2(builder.build()); - Optional getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - //check o block is empty - //Assert.assertTrue(getBlockByLimitNext.get().getBlock(1).getBlockid().isEmpty()); - //From 3 to 3 - builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(3); - builder.setEndNum(3); - blockList = blockingStubFull.getBlockByLimitNext2(builder.build()); - getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - //check the third block is empty - //Assert.assertTrue(getBlockByLimitNext.get().getBlock(3).getBlockid().isEmpty()); - //From 4 to 2 - builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(4); - builder.setEndNum(2); - blockList = blockingStubFull.getBlockByLimitNext2(builder.build()); - getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - //Assert.assertTrue(getBlockByLimitNext.get().getBlock(4).getBlockid().isEmpty()); - builder = GrpcAPI.BlockLimit.newBuilder(); - builder.setStartNum(999999990); - builder.setEndNum(999999999); - blockList = blockingStubFull.getBlockByLimitNext2(builder.build()); - getBlockByLimitNext = Optional.ofNullable(blockList); - Assert.assertTrue(getBlockByLimitNext.get().getBlockCount() == 0); - //Assert.assertTrue(getBlockByLimitNext.get().getBlock(999999990).getBlockid().isEmpty()); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByNum2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByNum2Test.java deleted file mode 100644 index 3a16f6bf614..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/GetBlockByNum2Test.java +++ /dev/null @@ -1,271 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; - -@Slf4j -public class GetBlockByNum2Test { - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - - @Test(enabled = true) - public void testGetBlockByNum2() { - GrpcAPI.BlockExtention currentBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - if (currentBlockNum == 1) { - logger.info("Now has very little block, Please test this case by manual"); - Assert.assertTrue(currentBlockNum == 1); - } - - //The number is large than the currently number, there is no exception when query this number. - /* Long outOfCurrentBlockNum = currentBlockNum + 10000L; - NumberMessage.Builder builder1 = NumberMessage.newBuilder(); - builder1.setNum(outOfCurrentBlockNum); - Block outOfCurrentBlock = blockingStubFull.getBlockByNum(builder1.build()); - Assert.assertFalse(outOfCurrentBlock.hasBlockHeader());*/ - - //Query the first block - NumberMessage.Builder builder2 = NumberMessage.newBuilder(); - builder2.setNum(1); - GrpcAPI.BlockExtention firstBlock = blockingStubFull.getBlockByNum2(builder2.build()); - Assert.assertTrue(firstBlock.hasBlockHeader()); - Assert.assertFalse(firstBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getNumber() == 1); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - Assert.assertFalse(firstBlock.getBlockid().isEmpty()); - - //Query the zero block - NumberMessage.Builder builder21 = NumberMessage.newBuilder(); - builder2.setNum(0); - GrpcAPI.BlockExtention zeroBlock = blockingStubFull.getBlockByNum2(builder21.build()); - Assert.assertTrue(zeroBlock.hasBlockHeader()); - Assert.assertTrue(zeroBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertFalse(zeroBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(zeroBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertFalse(zeroBlock.getBlockHeader().getRawData().getNumber() == 1); - Assert.assertFalse(zeroBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(zeroBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - Assert.assertFalse(zeroBlock.getBlockid().isEmpty()); - - //Query the -1 block - NumberMessage.Builder builder22 = NumberMessage.newBuilder(); - builder2.setNum(-1); - GrpcAPI.BlockExtention nagtiveBlock = blockingStubFull.getBlockByNum2(builder22.build()); - Assert.assertTrue(nagtiveBlock.hasBlockHeader()); - Assert.assertTrue(nagtiveBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertFalse(nagtiveBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(nagtiveBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertFalse(nagtiveBlock.getBlockHeader().getRawData().getNumber() == 1); - Assert.assertFalse(nagtiveBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(nagtiveBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - Assert.assertFalse(nagtiveBlock.getBlockid().isEmpty()); - - //Query the second latest block. - NumberMessage.Builder builder3 = NumberMessage.newBuilder(); - builder3.setNum(currentBlockNum - 1); - GrpcAPI.BlockExtention lastSecondBlock = blockingStubFull.getBlockByNum2(builder3.build()); - Assert.assertTrue(lastSecondBlock.hasBlockHeader()); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue( - lastSecondBlock.getBlockHeader().getRawData().getNumber() + 1 == currentBlockNum); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - Assert.assertFalse(lastSecondBlock.getBlockid().isEmpty()); - } - - @Test(enabled = true) - public void testGetBlockByNumFromSolidity2() { - GrpcAPI.BlockExtention currentBlock = blockingStubSolidity - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Assert.assertFalse(currentBlockNum < 0); - if (currentBlockNum == 1) { - logger.info("Now has very little block, Please test this case by manual"); - Assert.assertTrue(currentBlockNum == 1); - } - - //Query the first block. - NumberMessage.Builder builder2 = NumberMessage.newBuilder(); - builder2.setNum(1); - GrpcAPI.BlockExtention firstBlock = blockingStubSolidity.getBlockByNum2(builder2.build()); - Assert.assertTrue(firstBlock.hasBlockHeader()); - Assert.assertFalse(firstBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getNumber() == 1); - Assert.assertFalse(firstBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(firstBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("firstblock test from solidity succesfully"); - Assert.assertFalse(firstBlock.getBlockid().isEmpty()); - - //Query the second latest block. - NumberMessage.Builder builder3 = NumberMessage.newBuilder(); - builder3.setNum(currentBlockNum - 1); - GrpcAPI.BlockExtention lastSecondBlock = blockingStubSolidity.getBlockByNum2(builder3.build()); - Assert.assertTrue(lastSecondBlock.hasBlockHeader()); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue( - lastSecondBlock.getBlockHeader().getRawData().getNumber() + 1 == currentBlockNum); - Assert.assertFalse(lastSecondBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(lastSecondBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("Last second test from solidity succesfully"); - Assert.assertFalse(lastSecondBlock.getBlockid().isEmpty()); - } - - @Test(enabled = true) - public void testGetBlockById2() { - GrpcAPI.BlockExtention currentBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - ByteString currentHash = currentBlock.getBlockHeader().getRawData().getParentHash(); - GrpcAPI.BytesMessage request = GrpcAPI.BytesMessage.newBuilder().setValue(currentHash).build(); - Block setIdOfBlock = blockingStubFull.getBlockById(request); - Assert.assertTrue(setIdOfBlock.hasBlockHeader()); - Assert.assertFalse(setIdOfBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(setIdOfBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(setIdOfBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - logger.info(Long.toString(setIdOfBlock.getBlockHeader().getRawData().getNumber())); - logger.info(Long.toString(currentBlock.getBlockHeader().getRawData().getNumber())); - Assert.assertTrue( - setIdOfBlock.getBlockHeader().getRawData().getNumber() + 1 == currentBlock.getBlockHeader() - .getRawData().getNumber()); - Assert.assertFalse(setIdOfBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(setIdOfBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("By ID test succesfully"); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public GrpcAPI.BlockExtention getBlock2(long blockNum, - WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum2(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/GetNowBlock2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/GetNowBlock2Test.java deleted file mode 100644 index 0e34aaf03b6..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/GetNowBlock2Test.java +++ /dev/null @@ -1,182 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class GetNowBlock2Test { - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test - public void testCurrentBlock2() { - //Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - GrpcAPI.BlockExtention currentBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(currentBlock.hasBlockHeader()); - Assert.assertFalse(currentBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getNumber() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("test getcurrentblock is " + Long - .toString(currentBlock.getBlockHeader().getRawData().getNumber())); - Assert.assertFalse(currentBlock.getBlockid().isEmpty()); - - //Improve coverage. - currentBlock.equals(currentBlock); - //Block newBlock = blockingStubFull.getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - GrpcAPI.BlockExtention newBlock = blockingStubFull - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - newBlock.equals(currentBlock); - newBlock.hashCode(); - newBlock.getSerializedSize(); - newBlock.getTransactionsCount(); - newBlock.getTransactionsList(); - Assert.assertFalse(newBlock.getBlockid().isEmpty()); - } - - @Test - public void testCurrentBlockFromSolidity2() { - GrpcAPI.BlockExtention currentBlock = blockingStubSolidity - .getNowBlock2(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(currentBlock.hasBlockHeader()); - Assert.assertFalse(currentBlock.getBlockHeader().getWitnessSignature().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getTimestamp() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getWitnessAddress().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getNumber() > 0); - Assert.assertFalse(currentBlock.getBlockHeader().getRawData().getParentHash().isEmpty()); - Assert.assertTrue(currentBlock.getBlockHeader().getRawData().getWitnessId() >= 0); - logger.info("test getcurrentblock in soliditynode is " + Long - .toString(currentBlock.getBlockHeader().getRawData().getNumber())); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/GetTransactionsFromThis2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/GetTransactionsFromThis2Test.java deleted file mode 100644 index 727e3ee6cde..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/GetTransactionsFromThis2Test.java +++ /dev/null @@ -1,227 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountPaginated; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - - -@Slf4j -public class GetTransactionsFromThis2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final String notexist01 = - "DCB620820121A866E4E25905DC37F5025BFA5420B781C69E1BC6E1D83038C88A"; - - - private static final byte[] INVAILD_ADDRESS = - Base58.decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - - } - - @Test(enabled = true) - public void testgetTransactionsFromThis2() { - //Create a transfer. - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - - ByteString addressBs = ByteString.copyFrom(fromAddress); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionListExtention transactionListExtention = blockingStubExtension - .getTransactionsFromThis2(accountPaginated.build()); - Optional gettransactionsfromthis2 = Optional - .ofNullable(transactionListExtention); - - if (gettransactionsfromthis2.get().getTransactionCount() == 0) { - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000L, fromAddress, - testKey002, blockingStubFull)); - } - - Assert.assertTrue(gettransactionsfromthis2.isPresent()); - Integer beforecount = gettransactionsfromthis2.get().getTransactionCount(); - logger.info(Integer.toString(beforecount)); - for (Integer j = 0; j < beforecount; j++) { - Assert.assertFalse( - gettransactionsfromthis2.get().getTransaction(j).getTransaction().getRawData() - .getContractList().isEmpty()); - } - } - - @Test(enabled = true) - public void testgetTransactionsFromThisByInvaildAddress2() { - //Invaild address. - ByteString addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionListExtention transactionListExtention = blockingStubExtension - .getTransactionsFromThis2(accountPaginated.build()); - Optional gettransactionsfromthisByInvaildAddress = Optional - .ofNullable(transactionListExtention); - Assert.assertTrue(gettransactionsfromthisByInvaildAddress.get().getTransactionCount() == 0); - - //Limit is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(-1); - transactionListExtention = blockingStubExtension - .getTransactionsFromThis2(accountPaginated.build()); - gettransactionsfromthisByInvaildAddress = Optional - .ofNullable(transactionListExtention); - Assert.assertTrue(gettransactionsfromthisByInvaildAddress.get().getTransactionCount() == 0); - - //offset is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(-1); - accountPaginated.setLimit(100); - transactionListExtention = blockingStubExtension - .getTransactionsFromThis2(accountPaginated.build()); - gettransactionsfromthisByInvaildAddress = Optional - .ofNullable(transactionListExtention); - Assert.assertTrue(gettransactionsfromthisByInvaildAddress.get().getTransactionCount() == 0); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/GetTransactionsToThis2.java b/src/test/java/stest/tron/wallet/newaddinterface2/GetTransactionsToThis2.java deleted file mode 100644 index eec84fb58d0..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/GetTransactionsToThis2.java +++ /dev/null @@ -1,240 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AccountPaginated; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - - -@Slf4j -public class GetTransactionsToThis2 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final String notexist01 = - "DCB620820121A866E4E25905DC37F5025BFA5420B781C69E1BC6E1D83038C88A"; - - /* //testng001、testng002、testng003、testng004 - private static final byte[] fromAddress = - Base58.decodeFromBase58Check("THph9K2M2nLvkianrMGswRhz5hjSA9fuH7"); - private static final byte[] toAddress = - Base58.decodeFromBase58Check("TV75jZpdmP2juMe1dRwGrwpV6AMU6mr1EU");*/ - private static final byte[] INVAILD_ADDRESS = - Base58.decodeFromBase58Check("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - - - } - - @Test(enabled = true) - public void testgetTransactionsToThis2() { - //Create a transfer. - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000, fromAddress, - testKey002, blockingStubFull)); - - ByteString addressBs = ByteString.copyFrom(toAddress); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionListExtention transactionListExtention = blockingStubExtension - .getTransactionsToThis2(accountPaginated.build()); - - Optional gettransactionstothis2 = Optional - .ofNullable(transactionListExtention); - - if (gettransactionstothis2.get().getTransactionCount() == 0) { - Assert.assertTrue(PublicMethed.sendcoin(toAddress, 1000000L, fromAddress, testKey002, - blockingStubFull)); - } - - Assert.assertTrue(gettransactionstothis2.isPresent()); - Integer beforecount = gettransactionstothis2.get().getTransactionCount(); - logger.info(Integer.toString(beforecount)); - for (Integer j = 0; j < beforecount; j++) { - Assert.assertFalse( - gettransactionstothis2.get().getTransaction(j).getTransaction().getRawData() - .getContractList().isEmpty()); - } - } - - @Test(enabled = true) - public void testgetTransactionsToThisByInvaildAddress2() { - //Invaild address. - ByteString addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - Account account = Account.newBuilder().setAddress(addressBs).build(); - AccountPaginated.Builder accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(0); - GrpcAPI.TransactionListExtention transactionListExtention = blockingStubExtension - .getTransactionsToThis2(accountPaginated.build()); - Optional gettransactionstothisByInvaildAddress = Optional - .ofNullable(transactionListExtention); - - Assert.assertTrue(gettransactionstothisByInvaildAddress.get().getTransactionCount() == 0); - - //Limit is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(1000); - accountPaginated.setLimit(-1); - transactionListExtention = blockingStubExtension - .getTransactionsToThis2(accountPaginated.build()); - gettransactionstothisByInvaildAddress = Optional - .ofNullable(transactionListExtention); - - Assert.assertTrue(gettransactionstothisByInvaildAddress.get().getTransactionCount() == 0); - - //offset is -1 - addressBs = ByteString.copyFrom(INVAILD_ADDRESS); - account = Account.newBuilder().setAddress(addressBs).build(); - accountPaginated = AccountPaginated.newBuilder().setAccount(account); - accountPaginated.setOffset(-1); - accountPaginated.setLimit(100); - transactionListExtention = blockingStubExtension - .getTransactionsToThis2(accountPaginated.build()); - gettransactionstothisByInvaildAddress = Optional - .ofNullable(transactionListExtention); - - Assert.assertTrue(gettransactionstothisByInvaildAddress.get().getTransactionCount() == 0); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/ParticipateAssetIssue2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/ParticipateAssetIssue2Test.java deleted file mode 100644 index 1dd21eae84f..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/ParticipateAssetIssue2Test.java +++ /dev/null @@ -1,365 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class ParticipateAssetIssue2Test { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue002_" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] participateAccountAddress = ecKey1.getAddress(); - String participateAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] assetIssueAccount002 = ecKey2.getAddress(); - String testKeyForAssetIssueAccount002 = ByteArray.toHexString(ecKey2 - .getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - @Test(enabled = true) - public void testParticipateAssetissue2() { - ByteString addressBS1 = ByteString.copyFrom(participateAccountAddress); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - //send coin to the new account - Assert.assertTrue(PublicMethed.sendcoin(participateAccountAddress, 2048000000, fromAddress, - testKey002, blockingStubFull)); - //Create a new Asset Issue - Assert.assertTrue(PublicMethed.createAssetIssue(participateAccountAddress, - name, totalSupply, 1, 1, System.currentTimeMillis() + 2000, - System.currentTimeMillis() + 1000000000, 1, description, url, - 2000L, 2000L, 1L, 1L, - participateAccountKey, blockingStubFull)); - } else { - logger.info("This account already create an assetisue"); - Optional queryAssetByAccount1 = Optional.ofNullable(assetIssueList1); - name = ByteArray.toStr(queryAssetByAccount1.get().getAssetIssue(0).getName().toByteArray()); - - } - - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //Participate AssetIssue success - logger.info(name); - //Freeze amount to get bandwitch. - Assert.assertTrue(PublicMethed.freezeBalance(toAddress, 10000000, 3, testKey003, - blockingStubFull)); - - //The amount is large than the total supply, participate failed. - Return ret1 = PublicMethed.participateAssetIssue2(participateAccountAddress, - name.getBytes(), 9100000000000000000L, toAddress, testKey003, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : No enough balance !"); - //The asset issue name is not correct, participate failed. - ret1 = PublicMethed.participateAssetIssue2(participateAccountAddress, - (name + "wrong").getBytes(), 100L, toAddress, testKey003, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - //The amount is 0, participate asset issue failed. - ret1 = PublicMethed.participateAssetIssue2(participateAccountAddress, - name.getBytes(), 0L, toAddress, testKey003, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0!"); - - //The amount is -1, participate asset issue failed. - ret1 = PublicMethed.participateAssetIssue2(participateAccountAddress, - name.getBytes(), -1L, toAddress, testKey003, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0!"); - //The asset issue owner address is not correct, participate asset issue failed. - ret1 = PublicMethed.participateAssetIssue2(fromAddress, name.getBytes(), 100L, - toAddress, testKey003, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, byte[] from, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long fronzenAmount, Long frozenDay, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(20000); - builder.setPublicFreeAssetNetLimit(20000); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply.newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null || transaction.getRawData().getContractCount() == 0"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - //Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/TransferAsset2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/TransferAsset2Test.java deleted file mode 100644 index 261457af22d..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/TransferAsset2Test.java +++ /dev/null @@ -1,409 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class TransferAsset2Test { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue001_" + Long.toString(now); - private static final long totalSupply = now; - String description = "just-test-assetissue-001"; - String url = "https://github.com/tronprotocol/wallet-cli/assetissue001"; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] noBandwitchAddress = ecKey.getAddress(); - String noBandwitch = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - logger.info(ByteArray.toHexString(ecKey.getPrivKeyBytes())); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test() - public void testTransferAssetBandwitchDecreaseWithin10Second2() { - ByteString addressBS1 = ByteString.copyFrom(noBandwitchAddress); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Assert.assertTrue(PublicMethed.sendcoin(noBandwitchAddress, 2048000000, - fromAddress, testKey002, blockingStubFull)); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - - Return ret1 = PublicMethed.createAssetIssue2(noBandwitchAddress, name, totalSupply, 1, - 100, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, noBandwitch, blockingStubFull); - } else { - logger.info("This account already create an assetisue"); - Optional queryAssetByAccount1 = Optional.ofNullable(assetIssueList1); - name = ByteArray.toStr(queryAssetByAccount1.get().getAssetIssue(0).getName().toByteArray()); - - } - - Return ret1 = transferAsset2(toAddress, name.getBytes(), 100L, noBandwitchAddress, noBandwitch); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //Transfer Asset failed when transfer to yourself - ret1 = transferAsset2(toAddress, name.getBytes(), 100L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Cannot transfer asset to yourself."); - //Transfer Asset failed when the transfer amount is large than the asset balance you have. - ret1 = - transferAsset2(fromAddress, name.getBytes(), 9100000000000000000L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : assetBalance is not sufficient."); - //Transfer Asset failed when the transfer amount is 0 - ret1 = transferAsset2(fromAddress, name.getBytes(), 0L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0."); - //Transfer Asset failed when the transfer amount is -1 - ret1 = transferAsset2(fromAddress, name.getBytes(), -1L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Amount must greater than 0."); - ret1 = - transferAsset2(fromAddress, (name + "wrong").getBytes(), 1L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : No asset !"); - //Transfer success. - ret1 = transferAsset2(fromAddress, name.getBytes(), 1L, toAddress, testKey003); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - //No freeze asset, try to unfreeze asset failed. - Assert.assertFalse(unFreezeAsset(noBandwitchAddress, noBandwitch)); - logger.info("Test no asset frozen balance, try to unfreeze asset, no exception. Test OK!!!"); - //Not create asset, try to unfreeze asset failed.No exception. - Assert.assertFalse(unFreezeAsset(toAddress, testKey003)); - logger.info("Test not create asset issue, try to unfreeze asset, no exception. Test OK!!!"); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - builder.setFreeAssetNetLimit(20000); - builder.setPublicFreeAssetNetLimit(20000); - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null || transaction.getRawData().getContractCount() == 0"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public Return transferAsset2(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.transferAsset2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - } - return ret; - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/UnfreezeAsset2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/UnfreezeAsset2Test.java deleted file mode 100644 index 1d879cefab5..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/UnfreezeAsset2Test.java +++ /dev/null @@ -1,638 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class UnfreezeAsset2Test { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - - /* //testng001、testng002、testng003、testng004 - private static final byte[] fromAddress = Base58 - .decodeFromBase58Check("THph9K2M2nLvkianrMGswRhz5hjSA9fuH7"); - private static final byte[] toAddress = Base58 - .decodeFromBase58Check("TV75jZpdmP2juMe1dRwGrwpV6AMU6mr1EU");*/ - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - //get account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] lowBalAddress2 = ecKey2.getAddress(); - String lowBalTest2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - private static final long now = System.currentTimeMillis(); - private static final String name = "testAssetIssue003_" + Long.toString(now); - private static final String shortname = "a"; - private static final String tooLongName = "qazxswedcvfrtgbnhyujmkiolpoiuytre"; - private static final String chineseAssetIssuename = "中文都名字"; - private static final String tooLongDescription = - "1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqa" - + "zxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvq" - + "azxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcv"; - private static final String tooLongUrl = - "qaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqasw1qazxswedcvqazxswedcv" - + "qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedc" - + "vqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqaz" - + "xswedcvqazxswedcvqazxswedcvqazxswedcv"; - private static final long totalSupply = now; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test(enabled = true) - public void testGetAllAssetIssue2() { - Return ret1 = PublicMethed.sendcoin2(lowBalAddress, 2124500000L, - fromAddress, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - ret1 = PublicMethed.sendcoin2(lowBalAddress2, 21240500000L, - fromAddress, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - ByteString addressBS1 = ByteString.copyFrom(fromAddress); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull.getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - - //if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Long start = System.currentTimeMillis() + 100000; - Long end = System.currentTimeMillis() + 1000000000; - //Freeze amount is large than total supply, create asset issue failed. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 9000000000000000000L, 1L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Frozen supply cannot exceed total supply"); - //Freeze day is 0, create failed - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 100L, 0L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : " - + "frozenDuration must be less than 3652 days and more than 1 days"); - //Freeze amount is 0, create failed - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 0L, 1L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Frozen supply must be greater than 0!"); - //Freeze day is -1, create failed - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 1000L, 1000L, - 1000L, -1L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : " - + "frozenDuration must be less than 3652 days and more than 1 days"); - //Freeze amount is -1, create failed - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - -1L, 1L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Frozen supply must be greater than 0!"); - //Freeze day is 3653(10 years + 1 day), create failed - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3653L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : " - + "frozenDuration must be less than 3652 days and more than 1 days"); - //Start time is late than end time. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - end, start, 2, description, url, 10000L, 10000L, - 1L, 2L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : End time should be greater than start time"); - //Start time is early than currently time. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start - 1000000L, end, 2, description, url, 10000L, - 10000L, 1L, 2L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Start time should be greater than HeadBlockTime"); - //totalSupply is zero. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, 0L, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : TotalSupply must greater than 0!"); - //Totalsupply is -1. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, -1L, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : TotalSupply must greater than 0!"); - //TrxNum is zero. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 0, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : TrxNum must greater than 0!"); - //TrxNum is -1. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, -1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : TrxNum must greater than 0!"); - //IcoNum is 0. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 0, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Num must greater than 0!"); - //IcoNum is -1. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, -1, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Num must greater than 0!"); - //The asset issue name is null. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, "", totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid assetName"); - //The asset issue name is large than 33 char. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, tooLongName, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid assetName"); - //The asset issue name is chinese name. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, chineseAssetIssuename, totalSupply, 1, - 10, start, end, 2, description, url, 10000L, - 10000L, 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid assetName"); - //The URL is null. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, "", 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : Invalid url"); - //The URL is too long. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, tooLongUrl, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : Invalid url"); - //The description is too long, create failed. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, tooLongDescription, url, 10000L, - 10000L, 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid description"); - - //FreezeBalance - Assert.assertTrue(PublicMethed.freezeBalance(lowBalAddress, 10000000L, 3, lowBalTest, - blockingStubFull)); - //Create success - start = System.currentTimeMillis() + 6000; - end = System.currentTimeMillis() + 1000000000; - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //Test not in the duration time, participate failed. - ret1 = PublicMethed.participateAssetIssue2(lowBalAddress, name.getBytes(), 1L, - toAddress, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : No longer valid period!"); - //Test another address try to create the same name asset issue, create failed. - ret1 = PublicMethed.createAssetIssue2(lowBalAddress2, name, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, lowBalTest2, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : Token exists"); - - try { - Thread.sleep(4000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - GrpcAPI.AssetIssueList assetIssueList = blockingStubFull - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - logger.info(Integer.toString(assetIssueList.getAssetIssue(0).getFrozenSupplyCount())); - Assert.assertTrue(assetIssueList.getAssetIssue(0).getFrozenSupplyCount() == 1); - //Assert.assertTrue(assetIssueList.getAssetIssue(j).getFrozenSupplyCount() > 0); - Assert.assertTrue(assetIssueList.getAssetIssue(0).getFrozenSupply(0).getFrozenAmount() > 0); - Assert.assertTrue(assetIssueList.getAssetIssue(0).getFrozenSupply(0).getFrozenDays() > 0); - - //Test one account only can create one asset issue. - start = System.currentTimeMillis() + 3000; - end = System.currentTimeMillis() + 1000000000; - ret1 = PublicMethed.createAssetIssue2(lowBalAddress, shortname, totalSupply, 1, 10, - start, end, 2, description, url, 10000L, 10000L, - 1L, 3652L, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : An account can only issue one asset"); - logger.info("FROM ADDRESS create asset issue in this case!!!"); - - assetIssueList = blockingStubFull - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - Assert.assertTrue(assetIssueList.getAssetIssueCount() >= 1); - for (Integer j = 0; j < assetIssueList.getAssetIssueCount(); j++) { - Assert.assertFalse(assetIssueList.getAssetIssue(j).getOwnerAddress().isEmpty()); - Assert.assertFalse(assetIssueList.getAssetIssue(j).getName().isEmpty()); - Assert.assertFalse(assetIssueList.getAssetIssue(j).getUrl().isEmpty()); - Assert.assertTrue(assetIssueList.getAssetIssue(j).getTotalSupply() > 0); - logger.info("test get all assetissue"); - } - - //Improve coverage. - assetIssueList.equals(assetIssueList); - assetIssueList.equals(null); - GrpcAPI.AssetIssueList newAssetIssueList = blockingStubFull - .getAssetIssueList(GrpcAPI.EmptyMessage.newBuilder().build()); - assetIssueList.equals(newAssetIssueList); - assetIssueList.hashCode(); - assetIssueList.getSerializedSize(); - - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long fronzenAmount, Long frozenDay, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setFreeAssetNetLimit(10000); - builder.setPublicFreeAssetNetLimit(10000); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply - .newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public boolean unFreezeAsset2(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.unfreezeAsset2(contract); - if (transactionExtention == null) { - return false; - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return false; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return false; - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, byte[] from, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/UpdateAccount2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/UpdateAccount2Test.java deleted file mode 100644 index 2cc5ee4298a..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/UpdateAccount2Test.java +++ /dev/null @@ -1,965 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.WitnessList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -//import stest.tron.wallet.common.client.AccountComparator; - -@Slf4j -public class UpdateAccount2Test { - - //testng001、testng002、testng003、testng004 - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private static final long now = System.currentTimeMillis(); - private static final String name = "testAssetIssue_" + Long.toString(now); - private static final long TotalSupply = now; - String mostLongNamePlusOneChar = "1abcdeabcdefabcdefg1abcdefg10o0og1abcdefg10o0oabcd" - + "efabcdefg1abcdefg10o0og1abcdefg10o0oabcdefabcdefg1abcdefg10o0og1abcdefg10o0oab" - + "cdefabcdefg1abcdefg10o0og1abcdefg10o0ofabcdefg1abcdefg10o0og1abcdefg10o0o"; - String mostLongName = "abcdeabcdefabcdefg1abcdefg10o0og1abcdefg10o0oabcd" - + "efabcdefg1abcdefg10o0og1abcdefg10o0oabcdefabcdefg1abcdefg10o0og1abcdefg10o0oab" - + "cdefabcdefg1abcdefg10o0og1abcdefg10o0ofabcdefg1abcdefg10o0og1abcdefg10o0o"; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - //System.out.println(); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] noBandwitchAddress = ecKey1.getAddress(); - String noBandwitch = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - PublicMethed.printAddress(lowBalTest); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test - public void testCreateAccount2() { - Account noCreateAccount = queryAccount(lowBalTest, blockingStubFull); - if (noCreateAccount.getAccountName().isEmpty()) { - Assert.assertTrue(PublicMethed.freezeBalance(fromAddress, 10000000, 3, testKey002, - blockingStubFull)); - //Assert.assertTrue(sendCoin2(lowBalAddress, 1L, fromAddress, testKey002)); - GrpcAPI.Return ret1 = sendCoin2(lowBalAddress, 1000000L, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - //Assert.assertTrue(Sendcoin(Low_Bal_ADDRESS, 1000000L, fromAddress, testKey002)); - noCreateAccount = queryAccount(lowBalTest, blockingStubFull); - logger.info(Long.toString(noCreateAccount.getBalance())); - //Assert.assertTrue(noCreateAccount.getBalance() == 1); - - //TestVoteToNonWitnessAccount - String voteStr = Base58.encode58Check(lowBalAddress); - - HashMap voteToNonWitnessAccount = new HashMap(); - voteToNonWitnessAccount.put(voteStr, "3"); - - HashMap voteToInvaildAddress = new HashMap(); - voteToInvaildAddress.put("27cu1ozb4mX3m2afY68FSAqn3HmMp815d48SS", "4"); - - //TQkJsN2Q2sZV9H2dQ5x2rSneKNyLQgegVv - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] lowBalAddress2 = ecKey2.getAddress(); - - ret1 = PublicMethed.sendcoin2(lowBalAddress2, 21245000000L, - fromAddress, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - - WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - WitnessList witnessList = result.get(); - if (result.get().getWitnessesCount() < 6) { - String createUrl1 = "adfafds"; - byte[] createUrl = createUrl1.getBytes(); - String lowBalTest2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - ret1 = createWitness2(lowBalAddress2, createUrl, lowBalTest2); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - String voteStr1 = Base58.encode58Check(lowBalAddress2); - HashMap voteToWitAddress = new HashMap(); - voteToWitAddress.put(voteStr1, "1"); - PublicMethed.printAddress(lowBalTest); - ret1 = voteWitness2(voteToWitAddress, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //logger.info("vote to non witness account ok!!!"); - } - - //normal freezeBalance - //Assert.assertTrue(freezeBalance2(fromAddress, 10000000L, 3L, testKey002)) - ret1 = freezeBalance2(fromAddress, 100000000L, 3L, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - //vote To NonWitnessAccount - ret1 = voteWitness2(voteToNonWitnessAccount, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - //vote to InvaildAddress - ret1 = voteWitness2(voteToInvaildAddress, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : VoteNumber must more than 0"); - - } else { - logger.info( - "Please confirm wither the create account test is pass, or you will do it by manual"); - } - } - - - @Test(enabled = true) - public void testUpdateAccount2() { - Account tryToUpdateAccount = queryAccount(lowBalTest, blockingStubFull); - if (tryToUpdateAccount.getAccountName().isEmpty()) { - GrpcAPI.Return ret1 = updateAccount2(lowBalAddress, mostLongNamePlusOneChar.getBytes(), - lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid accountName"); - - ret1 = updateAccount2(lowBalAddress, "".getBytes(), lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : This name has existed"); - - System.out.println("dingwei2:"); - ret1 = updateAccount2(lowBalAddress, mostLongName.getBytes(), lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : This name has existed"); - - ret1 = updateAccount2(lowBalAddress, "secondUpdateName".getBytes(), lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : This name has existed"); - - } - } - - @Test(enabled = true) - public void testNoBalanceCreateAssetIssue2() { - Account lowaccount = queryAccount(lowBalTest, blockingStubFull); - if (lowaccount.getBalance() > 0) { - Assert.assertTrue(sendCoin(toAddress, lowaccount.getBalance(), lowBalAddress, lowBalTest)); - } - - System.out.println("1111112222"); - GrpcAPI.Return ret1 = PublicMethed.createAssetIssue2(lowBalAddress, name, TotalSupply, 1, 1, - now + 100000000L, now + 10000000000L, 2, description, url, 10000L, - 10000L, 1L, 1L, lowBalTest, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : No enough balance for fee!"); - logger.info("nobalancecreateassetissue"); - } - - @Test(enabled = true) - public void testNoBalanceTransferTrx2() { - //Send Coin failed when there is no enough balance. - Assert.assertFalse(sendCoin(toAddress, 100000000000000000L, lowBalAddress, lowBalTest)); - } - - @Test(enabled = true) - public void testNoBalanceCreateWitness2() { - //Apply to be super witness failed when no enough balance. - //Assert.assertFalse(createWitness2(lowBalAddress, fromAddress, lowBalTest)); - System.out.println("1111222333:" + lowBalAddress); - GrpcAPI.Return ret1 = createWitness2(lowBalAddress, fromAddress, lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : balance < AccountUpgradeCost"); - - } - - @Test(enabled = true) - public void testNoFreezeBalanceToUnfreezeBalance2() { - //Unfreeze account failed when no freeze balance - Account noFreezeAccount = queryAccount(lowBalTest, blockingStubFull); - if (noFreezeAccount.getFrozenCount() == 0) { - GrpcAPI.Return ret1 = unFreezeBalance2(lowBalAddress, lowBalTest); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : no frozenBalance"); - } else { - logger.info("This account has freeze balance, please test this case for manual"); - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createWitness(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createWitness(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public GrpcAPI.Return createWitness2(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.createWitness2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return response; - } - return ret; - } - - /** - * constructor. - */ - - public Boolean sendCoin(byte[] to, long amount, byte[] owner, String priKey) { - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public GrpcAPI.Return sendCoin2(byte[] to, long amount, byte[] owner, String priKey) { - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull - .createTransaction2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } - return ret; - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(TotalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - - Protocol.Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info("Please check!!! response.getresult==false"); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - class AccountComparator implements Comparator { - - public int compare(Object o1, Object o2) { - return Long.compare(((Account) o2).getBalance(), ((Account) o1).getBalance()); - } - } - - /** - * constructor. - */ - - public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Protocol.Transaction signTransaction(ECKey ecKey, Protocol.Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean updateAccount(byte[] addressBytes, byte[] accountNameBytes, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(addressBytes); - ByteString bsAccountName = ByteString.copyFrom(accountNameBytes); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - Contract.AccountUpdateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateAccount(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("Please check!!! transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info("Please check!!! response.getresult==false"); - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } - - /** - * constructor. - */ - - public GrpcAPI.Return updateAccount2(byte[] addressBytes, byte[] accountNameBytes, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(addressBytes); - ByteString bsAccountName = ByteString.copyFrom(accountNameBytes); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - Contract.AccountUpdateContract contract = builder.build(); - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.updateAccount2(contract); - - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info("Please check!!! response.getresult==false"); - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } else { - logger.info(name); - return response; - } - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] address, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UnfreezeBalanceContract.Builder builder = Contract.UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeBalanceContract contract = builder.build(); - - Protocol.Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public GrpcAPI.Return unFreezeBalance2(byte[] address, String priKey) { - //byte[] address = address; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.UnfreezeBalanceContract.Builder builder = Contract.UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeBalanceContract contract = builder.build(); - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.unfreezeBalance2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return response; - } - return ret; - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] address, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] addRess = WalletClient.decodeFromBase58Check(addressBase58); - if (addRess == null) { - return false; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(addRess)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Protocol.Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info("response.getresult() == false"); - return false; - } - return true; - } - - /** - * constructor. - */ - - public GrpcAPI.Return voteWitness2(HashMap witness, byte[] address, - String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] addRess = WalletClient.decodeFromBase58Check(addressBase58); - if (addRess == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(addRess)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull - .voteWitnessAccount2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info("response.getresult() == false"); - return response; - } - return ret; - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - return true; - - - } - - /** - * constructor. - */ - - public GrpcAPI.Return freezeBalance2(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.freezeBalance2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return response; - } - return ret; - } - - -} - - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/UpdateAsset2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/UpdateAsset2Test.java deleted file mode 100644 index abe65053c2e..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/UpdateAsset2Test.java +++ /dev/null @@ -1,470 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class UpdateAsset2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue010_" + Long.toString(now); - private static final long totalSupply = now; - private static final long sendAmount = 10000000000L; - String description = "just-test"; - String url = "https://github.com/tronprotocol/wallet-cli/"; - String updateDescription = "This is test for update asset issue, case AssetIssue_010"; - String updateUrl = "www.updateassetissue.010.cn"; - private static final String tooLongDescription = - "1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcv" - + "qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswe" - + "dcvqazxswedcvqazxswedcvqazxswedcvqazxswedcv"; - private static final String tooLongUrl = "qaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqaswqas" - + "wqaswqasw1qazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazx" - + "swedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedcvqazxswedc" - + "vqazxswedcvqazxswedcvqazxswedcvqazxswedcv"; - - Long freeAssetNetLimit = 1000L; - Long publicFreeAssetNetLimit = 1000L; - Long updateFreeAssetNetLimit = 10001L; - Long updatePublicFreeAssetNetLimit = 10001L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] asset010Address = ecKey.getAddress(); - String testKeyForAssetIssue010 = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test(enabled = true) - public void testUpdateAssetIssue2() { - //Sendcoin to this account - ByteString addressBS1 = ByteString.copyFrom(asset010Address); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - //Assert.assertTrue(PublicMethed.freezeBalance(fromAddress,10000000L,3, - // testKey002,blockingStubFull)); - Assert.assertTrue(PublicMethed - .sendcoin(asset010Address, sendAmount, fromAddress, testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed - .freezeBalance(asset010Address, 200000000L, 3, testKeyForAssetIssue010, - blockingStubFull)); - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - Assert.assertTrue(PublicMethed.createAssetIssue(asset010Address, name, totalSupply, 1, 1, - start, end, 1, description, url, freeAssetNetLimit, publicFreeAssetNetLimit, - 1L, 1L, testKeyForAssetIssue010, blockingStubFull)); - } else { - logger.info("This account already create an assetisue"); - Optional queryAssetByAccount1 = Optional.ofNullable(assetIssueList1); - name = ByteArray.toStr(queryAssetByAccount1.get().getAssetIssue(0).getName().toByteArray()); - Assert.assertTrue(PublicMethed - .updateAsset(asset010Address, description.getBytes(), url.getBytes(), freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull)); - } - - //Query the description and url,freeAssetNetLimit and publicFreeAssetNetLimit - ByteString assetNameBs = ByteString.copyFrom(name.getBytes()); - GrpcAPI.BytesMessage request = GrpcAPI.BytesMessage.newBuilder().setValue(assetNameBs).build(); - Contract.AssetIssueContract assetIssueByName = blockingStubFull.getAssetIssueByName(request); - - Assert.assertTrue( - ByteArray.toStr(assetIssueByName.getDescription().toByteArray()).equals(description)); - Assert.assertTrue(ByteArray.toStr(assetIssueByName.getUrl().toByteArray()).equals(url)); - Assert.assertTrue(assetIssueByName.getFreeAssetNetLimit() == freeAssetNetLimit); - Assert.assertTrue(assetIssueByName.getPublicFreeAssetNetLimit() == publicFreeAssetNetLimit); - - //Test update asset issue - Return ret1 = PublicMethed - .updateAsset2(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), - updateFreeAssetNetLimit, - updatePublicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - //After update asset issue ,query the description and url, - // freeAssetNetLimit and publicFreeAssetNetLimit - assetNameBs = ByteString.copyFrom(name.getBytes()); - request = GrpcAPI.BytesMessage.newBuilder().setValue(assetNameBs).build(); - assetIssueByName = blockingStubFull.getAssetIssueByName(request); - - Assert.assertTrue( - ByteArray.toStr(assetIssueByName.getDescription().toByteArray()).equals(updateDescription)); - Assert.assertTrue(ByteArray.toStr(assetIssueByName.getUrl().toByteArray()).equals(updateUrl)); - Assert.assertTrue(assetIssueByName.getFreeAssetNetLimit() == updateFreeAssetNetLimit); - Assert - .assertTrue(assetIssueByName.getPublicFreeAssetNetLimit() == updatePublicFreeAssetNetLimit); - } - - @Test(enabled = true) - public void testUpdateAssetIssueExcption2() { - //Test update asset issue for wrong parameter - //publicFreeAssetNetLimit is -1 - Return ret1 = PublicMethed - .updateAsset2(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), - updateFreeAssetNetLimit, - -1L, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid PublicFreeAssetNetLimit"); - //publicFreeAssetNetLimit is 0 - ret1 = PublicMethed - .updateAsset2(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), - updateFreeAssetNetLimit, - 0, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //FreeAssetNetLimit is -1 - ret1 = PublicMethed - .updateAsset2(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), -1, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid FreeAssetNetLimit"); - //FreeAssetNetLimit is 0 - ret1 = PublicMethed - .updateAsset2(asset010Address, updateDescription.getBytes(), updateUrl.getBytes(), 0, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //Description is null - ret1 = PublicMethed - .updateAsset2(asset010Address, "".getBytes(), updateUrl.getBytes(), freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //Url is null - ret1 = PublicMethed - .updateAsset2(asset010Address, description.getBytes(), "".getBytes(), freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : Invalid url"); - //Too long discription - ret1 = PublicMethed - .updateAsset2(asset010Address, tooLongDescription.getBytes(), url.getBytes(), - freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : Invalid description"); - //Too long URL - ret1 = PublicMethed - .updateAsset2(asset010Address, description.getBytes(), tooLongUrl.getBytes(), - freeAssetNetLimit, - publicFreeAssetNetLimit, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : Invalid url"); - } - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - Return ret1 = PublicMethed - .updateAsset2(asset010Address, description.getBytes(), url.getBytes(), 1999999999, - 199, testKeyForAssetIssue010, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean createAssetIssue(byte[] address, String name, Long totalSupply, Integer trxNum, - Integer icoNum, Long startTime, Long endTime, - Integer voteScore, String description, String url, Long fronzenAmount, Long frozenDay, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = PublicMethed.queryAccount(priKey, blockingStubFull); - - try { - Contract.AssetIssueContract.Builder builder = Contract.AssetIssueContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - builder.setName(ByteString.copyFrom(name.getBytes())); - builder.setTotalSupply(totalSupply); - builder.setTrxNum(trxNum); - builder.setNum(icoNum); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - builder.setVoteScore(voteScore); - builder.setDescription(ByteString.copyFrom(description.getBytes())); - builder.setUrl(ByteString.copyFrom(url.getBytes())); - Contract.AssetIssueContract.FrozenSupply.Builder frozenBuilder = - Contract.AssetIssueContract.FrozenSupply - .newBuilder(); - frozenBuilder.setFrozenAmount(fronzenAmount); - frozenBuilder.setFrozenDays(frozenDay); - builder.addFrozenSupply(0, frozenBuilder); - - Transaction transaction = blockingStubFull.createAssetIssue(builder.build()); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } catch (Exception ex) { - ex.printStackTrace(); - return false; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public boolean transferAsset(byte[] to, byte[] assertName, long amount, byte[] address, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.TransferAssetContract.Builder builder = Contract.TransferAssetContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(address); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferAssetContract contract = builder.build(); - Transaction transaction = blockingStubFull.transferAsset(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - Account search = queryAccount(ecKey, blockingStubFull); - return true; - } - - } - - /** - * constructor. - */ - - public boolean unFreezeAsset(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.UnfreezeAssetContract.Builder builder = Contract.UnfreezeAssetContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - Contract.UnfreezeAssetContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeAsset(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public boolean participateAssetIssue(byte[] to, byte[] assertName, long amount, byte[] from, - String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.ParticipateAssetIssueContract.Builder builder = Contract.ParticipateAssetIssueContract - .newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsName = ByteString.copyFrom(assertName); - ByteString bsOwner = ByteString.copyFrom(from); - builder.setToAddress(bsTo); - builder.setAssetName(bsName); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - Contract.ParticipateAssetIssueContract contract = builder.build(); - - Transaction transaction = blockingStubFull.participateAssetIssue(contract); - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } else { - logger.info(name); - return true; - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/VoteWitnessAccount2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/VoteWitnessAccount2Test.java deleted file mode 100644 index bfec7ff9582..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/VoteWitnessAccount2Test.java +++ /dev/null @@ -1,589 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class VoteWitnessAccount2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - logger.info("Pre fix byte ===== " + WalletClient.getAddressPreFixByte()); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - - } - - @Test(enabled = true) - public void testVoteWitness2() { - //get account - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] lowBalAddress = ecKey.getAddress(); - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] lowBalAddress2 = ecKey2.getAddress(); - String lowBalTest2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - //sendcoin - Return ret1 = PublicMethed.sendcoin2(lowBalAddress, 21245000000L, - fromAddress, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - ret1 = PublicMethed.sendcoin2(lowBalAddress2, 21245000000L, - fromAddress, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - //assetissue - String createUrl1 = "adfafds"; - byte[] createUrl = createUrl1.getBytes(); - String lowBalTest = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - ret1 = createWitness2(lowBalAddress, createUrl, lowBalTest); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - String voteStr1 = Base58.encode58Check(lowBalAddress); - - //Base58.encode58Check(getFinalAddress(key); - //String voteStr = "TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes"; - String voteStr = voteStr1; - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - HashMap wrongVoteMap = new HashMap(); - wrongVoteMap.put(voteStr, "-1"); - HashMap zeroVoteMap = new HashMap(); - zeroVoteMap.put(voteStr, "0"); - - HashMap veryLargeMap = new HashMap(); - veryLargeMap.put(voteStr, "1000000000"); - HashMap wrongDropMap = new HashMap(); - wrongDropMap.put(voteStr, "10000000000000000"); - - //Vote failed due to no freeze balance. - //Assert.assertFalse(VoteWitness(smallVoteMap, NO_FROZEN_ADDRESS, no_frozen_balance_testKey)); - - //Freeze balance to get vote ability. - ret1 = PublicMethed.freezeBalance2(fromAddress, 10000000L, 3L, testKey002, blockingStubFull); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - //Vote failed when the vote is large than the freeze balance. - ret1 = voteWitness2(veryLargeMap, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - - //Vote failed due to 0 vote. - ret1 = voteWitness2(zeroVoteMap, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : vote count must be greater than 0"); - - ret1 = voteWitness2(wrongVoteMap, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : vote count must be greater than 0"); - - ret1 = voteWitness2(wrongDropMap, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : overflow: checkedMultiply(10000000000000000, 1000000)"); - ret1 = voteWitness2(smallVoteMap, fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), Return.response_code.SUCCESS); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), ""); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] addRess, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - logger.info("address ====== " + ByteArray.toHexString(address)); - String value = witness.get(addressBase58); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - long count = Long.parseLong(value); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Account afterVote = queryAccount(ecKey, searchBlockingStubFull); - //Long afterVoteNum = afterVote.getVotes(0).getVoteCount(); - for (String key : witness.keySet()) { - for (int j = 0; j < afterVote.getVotesCount(); j++) { - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - logger.info(key); - if (key.equals("TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes")) { - logger.info("catch it"); - logger.info(Long.toString(afterVote.getVotes(j).getVoteCount())); - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - Assert - .assertTrue(afterVote.getVotes(j).getVoteCount() == Long.parseLong(witness.get(key))); - } - - } - } - return true; - } - - /** - * constructor. - */ - - public GrpcAPI.Return createWitness2(byte[] owner, byte[] url, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.WitnessCreateContract.Builder builder = Contract.WitnessCreateContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(owner)); - builder.setUrl(ByteString.copyFrom(url)); - Contract.WitnessCreateContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.createWitness2(contract); - - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - GrpcAPI.Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Protocol.Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return response; - } - return ret; - - } - - /** - * constructor. - */ - - public Return voteWitness2(HashMap witness, byte[] addRess, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - logger.info("address ====== " + ByteArray.toHexString(address)); - String value = witness.get(addressBase58); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - long count = Long.parseLong(value); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - //Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull - .voteWitnessAccount2(contract); - - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } else { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return response; - } - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Account afterVote = queryAccount(ecKey, searchBlockingStubFull); - //Long afterVoteNum = afterVote.getVotes(0).getVoteCount(); - for (String key : witness.keySet()) { - for (int j = 0; j < afterVote.getVotesCount(); j++) { - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - logger.info(key); - if (key.equals("TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes")) { - logger.info("catch it"); - logger.info(Long.toString(afterVote.getVotes(j).getVoteCount())); - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - Assert - .assertTrue(afterVote.getVotes(j).getVoteCount() == Long.parseLong(witness.get(key))); - } - - } - } - return ret; - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Block searchCurrentBlock = searchBlockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - Integer wait = 0; - while (searchCurrentBlock.getBlockHeader().getRawData().getNumber() - < currentBlock.getBlockHeader().getRawData().getNumber() + 1 && wait < 30) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("Another fullnode didn't syn the first fullnode data"); - searchCurrentBlock = searchBlockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - wait++; - if (wait == 9) { - logger.info("Didn't syn,skip to next case."); - } - } - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - //logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "afterfrozenbalance =" + Long.toString(afterFrozenBalance) + "beforefrozenbalance = " - + beforeFrozenBalance + "freezebalance = " + Long.toString(freezeBalance)); - //logger.info("afterbandwidth = " + Long.toString(afterBandwidth) + " beforebandwidth = - // " + Long.toString(beforeBandwidth)); - //if ((afterFrozenBalance - beforeFrozenBalance != freezeBalance) || - // (freezeBalance * frozen_duration -(afterBandwidth - beforeBandwidth) !=0)){ - // logger.info("After 20 second, two node still not synchronous"); - // } - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(freezeBalance * frozen_duration - (afterBandwidth - - // beforeBandwidth) <= 1000000); - return true; - - - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/newaddinterface2/WithdrawBalance2Test.java b/src/test/java/stest/tron/wallet/newaddinterface2/WithdrawBalance2Test.java deleted file mode 100644 index 63cddb6a998..00000000000 --- a/src/test/java/stest/tron/wallet/newaddinterface2/WithdrawBalance2Test.java +++ /dev/null @@ -1,313 +0,0 @@ -package stest.tron.wallet.newaddinterface2; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WithdrawBalance2Test { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - - private final String notWitnessTestKey = - "8CB4480194192F30907E14B52498F594BD046E21D7C4D8FE866563A6760AC891"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] notWitness = PublicMethed.getFinalAddress(notWitnessTestKey); - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - - } - - @Test - public void testWithdrawBalance2() { - //Withdraw failed when you are not witness - Return ret1 = withdrawBalance2(notWitness, notWitnessTestKey); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), "contract validate error : " - + "Account[41688b08971e740d7cecfa5d768f2787c1bb4c1268] is not a witnessAccount"); - - //Withdraw failed when the latest time to withdraw within 1 day. - ret1 = withdrawBalance2(fromAddress, testKey002); - Assert.assertEquals(ret1.getCode(), GrpcAPI.Return.response_code.CONTRACT_VALIDATE_ERROR); - Assert.assertEquals(ret1.getMessage().toStringUtf8(), - "contract validate error : witnessAccount does not have any allowance"); - } - - /** - * constructor. - */ - - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public boolean withdrawBalance(byte[] address, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - - Contract.WithdrawBalanceContract.Builder builder = Contract.WithdrawBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - Contract.WithdrawBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.withdrawBalance(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } - logger.info("test withdraw" + priKey); - return true; - - } - - /** - * constructor. - */ - - public Return withdrawBalance2(byte[] address, String priKey) { - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - - Contract.WithdrawBalanceContract.Builder builder = Contract.WithdrawBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - builder.setOwnerAddress(byteAddreess); - Contract.WithdrawBalanceContract contract = builder.build(); - - GrpcAPI.TransactionExtention transactionExtention = blockingStubFull.withdrawBalance2(contract); - if (transactionExtention == null) { - return transactionExtention.getResult(); - } - Return ret = transactionExtention.getResult(); - if (!ret.getResult()) { - System.out.println("Code = " + ret.getCode()); - System.out.println("Message = " + ret.getMessage().toStringUtf8()); - return ret; - } - Transaction transaction = transactionExtention.getTransaction(); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - System.out.println("Transaction is empty"); - return transactionExtention.getResult(); - } - System.out.println( - "Receive txid = " + ByteArray.toHexString(transactionExtention.getTxid().toByteArray())); - - ECKey ecKey = temKey; - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return response; - } - logger.info("test withdraw" + priKey); - return ret; - - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] address, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(address)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] addRess = WalletClient.decodeFromBase58Check(addressBase58); - if (addRess == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - Account afterVote = queryAccount(ecKey, searchBlockingStubFull); - //Long afterVoteNum = afterVote.getVotes(0).getVoteCount(); - for (String key : witness.keySet()) { - for (int j = 0; j < afterVote.getVotesCount(); j++) { - if (key.equals(afterVote.getVotes(j).getVoteAddress())) { - Long afterVoteNum = Long.parseLong(witness.get(key)); - Assert.assertTrue(afterVoteNum == afterVote.getVotes(j).getVoteCount()); - logger.info("test equal vote"); - } - } - } - return true; - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/ContractEvent001.java b/src/test/java/stest/tron/wallet/onlinestress/ContractEvent001.java deleted file mode 100644 index f82f4be4809..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/ContractEvent001.java +++ /dev/null @@ -1,304 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.zeromq.ZMQ; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import zmq.ZMQ.Event; - -@Slf4j -public class ContractEvent001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - String txid; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] event001Address = ecKey1.getAddress(); - String event001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] event002Address = ecKey2.getAddress(); - String event002Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - @Test(enabled = true) - public void test1ContractEventAndLog() { - ecKey1 = new ECKey(Utils.getRandom()); - event001Address = ecKey1.getAddress(); - event001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.printAddress(event001Key); - - ecKey2 = new ECKey(Utils.getRandom()); - event002Address = ecKey2.getAddress(); - event002Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - PublicMethed.printAddress(event001Key); - PublicMethed.printAddress(testKey002); - - Assert.assertTrue(PublicMethed.sendcoin(event001Address, maxFeeLimit * 30, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(event002Address, maxFeeLimit * 30, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - - AccountResourceMessage accountResource = PublicMethed.getAccountResource(event001Address, - blockingStubFull); - Long energyLimit = accountResource.getEnergyLimit(); - Long energyUsage = accountResource.getEnergyUsed(); - Long balanceBefore = PublicMethed.queryAccount(event001Key, blockingStubFull).getBalance(); - - logger.info("before energy limit is " + Long.toString(energyLimit)); - logger.info("before energy usage is " + Long.toString(energyUsage)); - logger.info("before balance is " + Long.toString(balanceBefore)); - - String contractName = "addressDemo"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_ContractEventAndLog1"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_ContractEventAndLog1"); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 50, null, event001Key, event001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - - Integer i = 0; - for (i = 0; i < 1; i++) { - txid = PublicMethed.triggerContract(contractAddress, - "depositForEventCycle(uint256)", "100", false, - 1L, 100000000L, event002Address, event002Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForLogCycle(uint256)", "100", false, - 2L, 100000000L, event002Address, event002Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "triggerUintEvent()", "#", false, - 0, maxFeeLimit, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "triggerintEvent()", "#", false, - 0, maxFeeLimit, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForEventAndLog()", "#", false, - 1, maxFeeLimit, event001Address, event001Key, blockingStubFull); - logger.info(txid); - txid = PublicMethed.triggerContract(contractAddress, - "depositForEventNoIndex()", "#", false, - 0L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - txid = PublicMethed.triggerContract(contractAddress, - "depositForLog()", "#", false, - 1L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForEventNoIndex()", "#", false, - 1L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForEventOneIndex()", "#", false, - 1L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForEventTwoIndex()", "#", false, - 2L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForEvent()", "#", false, - 3L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForEventCycle(uint256)", "100", false, - 1L, 100000000L, event002Address, event002Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForLogCycle(uint256)", "100", false, - 2L, 100000000L, event002Address, event002Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForAnonymousHasLog()", "#", false, - 4L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "depositForAnonymousNoLog()", "#", false, - 5L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - String param = "\"" + code + "\"" + "," + "\"" + code + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "triggerStringEvent(string,string)", param, false, - 0L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - param = "\"" + "true1" + "\"" + "," + "\"" + "false1" + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "triggerBoolEvent(bool,bool)", param, false, - 0L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - String filename = "/Users/wangzihe/Documents/modify_fullnode/java-tron/tooLongString.txt"; - try { - FileReader fr = new FileReader( - filename); - InputStreamReader read = new InputStreamReader(new FileInputStream(new File(filename))); - BufferedReader reader = new BufferedReader(read); - String tooLongString = reader.readLine(); - param = "\"" + tooLongString + "\"" + "," + "\"" + tooLongString + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "triggerStringEventAnonymous(string,string)", param, false, - 0L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - txid = PublicMethed.triggerContract(contractAddress, - "triggerStringEvent(string,string)", param, false, - 0L, 100000000L, event001Address, event001Key, blockingStubFull); - logger.info(txid); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - - - } - - contractName = "addressDemo"; - code = Configuration.getByPath("testng.conf") - .getString("code.code_ContractEventAndLog2"); - abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_ContractEventAndLog2"); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 50, null, event001Key, event001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - - txid = PublicMethed.triggerContract(contractAddress, - "triggerEventBytes()", "#", false, - 0, maxFeeLimit, event001Address, event001Key, blockingStubFull); - logger.info(txid); - } - - @Test(enabled = true, description = "Subscribe event client") - public void testEnergyCostDetail() { - ZMQ.Context context = ZMQ.context(1); - ZMQ.Socket req = context.socket(ZMQ.SUB); - - req.subscribe("blockTrigger"); - req.subscribe("transactionTrigger"); - req.subscribe("contractLogTrigger"); - req.subscribe("contractEventTrigger"); - req.monitor("inproc://reqmoniter", ZMQ.EVENT_CONNECTED | ZMQ.EVENT_DISCONNECTED); - final ZMQ.Socket moniter = context.socket(ZMQ.PAIR); - moniter.connect("inproc://reqmoniter"); - new Thread(new Runnable() { - public void run() { - while (true) { - Event event = Event.read(moniter.base()); - System.out.println(event.event + " " + event.addr); - } - } - - }).start(); - req.connect("tcp://47.94.197.215:55555"); - req.setReceiveTimeOut(10000); - - while (true) { - byte[] message = req.recv(); - if (message != null) { - System.out.println("receive : " + new String(message)); - } - } - - - - } - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/CycleMultiSign.java b/src/test/java/stest/tron/wallet/onlinestress/CycleMultiSign.java deleted file mode 100644 index 6da00b39793..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/CycleMultiSign.java +++ /dev/null @@ -1,253 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.List; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Permission; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class CycleMultiSign { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidityInFullnode = null; - - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - private ManagedChannel channelSolidity = null; - private ManagedChannel channelSolidityInFullnode = null; - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - - private ECKey ecKey = new ECKey(Utils.getRandom()); - private byte[] test001Address = ecKey.getAddress(); - private String dev001Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] test002Address = ecKey2.getAddress(); - private String sendAccountKey2 = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - private ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] test003Address = ecKey3.getAddress(); - String sendAccountKey3 = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - private ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] test004Address = ecKey4.getAddress(); - String sendAccountKey4 = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - private ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] test005Address = ecKey5.getAddress(); - String sendAccountKey5 = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - } - - //(use no id) - @Test(enabled = true) - public void testMultiSignActiveAddress() { - Assert.assertTrue(PublicMethed - .sendcoin(test001Address, 10000000000000L, fromAddress, testKey002, - blockingStubFull)); - - Account test001AddressAccount = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList = test001AddressAccount.getActivePermissionList(); - Permission ownerPermission = test001AddressAccount.getOwnerPermission(); - Permission witnessPermission = test001AddressAccount.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission)); - logger.info("wei-----------------------"); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = dev001Key; - - String accountPermissionJson1 = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":1,\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey5) - + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\"," - + "\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}]}]} "; - - Account test001AddressAccount1 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList1 = test001AddressAccount1.getActivePermissionList(); - Permission ownerPermission1 = test001AddressAccount1.getOwnerPermission(); - Permission witnessPermission1 = test001AddressAccount1.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList1); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission1)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission1)); - logger.info("1-----------------------"); - - String accountPermissionJson2 = - "{\"owner_permission\":{\"type\":0,\"permission_name\"" - + ":\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]} "; - String accountPermissionJson3 = "{\"owner_permission\":{\"type\":0,\"permission_name\":" - + "\"owner\",\"threshold\":1,\"keys\":[{\"address\"" - + ":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":" - + "\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations" - + "\":\"0100000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - String accountPermissionJson4 = "{\"owner_permission\":{\"type\":0,\"" - + "permission_name\":\"owner\",\"threshold\":1,\"keys\":" - + "[{\"address\":\"" + PublicMethed.getAddressString(dev001Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1," - + "\"operations\":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\",\"keys\":" - + "[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey4) - + "\",\"weight\":1}]},{\"type\":2," - + "\"permission_name\":\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations\"" - + ":\"0100000000000000000000000000000000000000000000000000000000000000\",\"keys\"" - + ":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations\":" - + "\"0200000000000000000000000000000000000000000000000000000000000000\",\"keys\"" - + ":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey2) - + "\",\"weight\":1}]},{\"type\":2," - + "\"permission_name\":\"active0\",\"threshold\":1,\"operations\":\"" - + "0200000000000000000000000000000000000000000000000000000000000000\",\"keys\":" - + "[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations\"" - + ":\"0200000000000000000000000000000000000000000000000000000000000000\",\"" - + "keys\":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey5) - + "\",\"weight\":1}]}," - + "{\"type\":2,\"permission_name\":\"active0\",\"threshold\":1,\"operations\":" - + "\"0020000000000000000000000000000000000000000000000000000000000000\",\"keys\"" - + ":[{\"address\":\"" + PublicMethed.getAddressString(sendAccountKey3) - + "\",\"weight\":1}]}]}"; - while (true) { - PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson1, test001Address, - dev001Key, - blockingStubFull, 0, - permissionKeyString); - addressPermission(dev001Key, accountPermissionJson2); - addressPermission(dev001Key, accountPermissionJson3); - addressPermission(dev001Key, accountPermissionJson4); - Account test001AddressAccount2 = PublicMethed.queryAccount(test001Address, blockingStubFull); - List permissionsList2 = test001AddressAccount2.getActivePermissionList(); - Permission ownerPermission2 = test001AddressAccount2.getOwnerPermission(); - Permission witnessPermission2 = test001AddressAccount2.getWitnessPermission(); - PublicMethedForMutiSign.printPermissionList(permissionsList2); - logger.info(PublicMethedForMutiSign.printPermission(ownerPermission2)); - logger.info(PublicMethedForMutiSign.printPermission(witnessPermission2)); - } - } - - /** - * constructor. - */ - - public void addressPermission(String addKey, String accountPermissionJson) { - PublicMethed.freezeBalanceForReceiver(test001Address, - 10000000L, 0, 0, - com.google.protobuf.ByteString.copyFrom(fromAddress), testKey002, blockingStubFull); - - String[] permissionKeyString = new String[1]; - permissionKeyString[0] = addKey; - PublicMethedForMutiSign - .accountPermissionUpdateWithPermissionId(accountPermissionJson, test001Address, dev001Key, - blockingStubFull, 0, - permissionKeyString); - PublicMethed.unFreezeBalance(fromAddress, testKey002, 0, - test001Address, blockingStubFull); - } - - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/onlinestress/DelayTransactionStress.java b/src/test/java/stest/tron/wallet/onlinestress/DelayTransactionStress.java deleted file mode 100644 index 69f53a745b7..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/DelayTransactionStress.java +++ /dev/null @@ -1,359 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -//import org.tron.protos.Protocol.DeferredTransaction; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; - -@Slf4j -public class DelayTransactionStress { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private Long delayTransactionFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.delayTransactionFee"); - - - public static final long MAX_DEFERRED_TRANSACTION_DELAY_SECONDS = 45 * 24 * 3_600L; //45 days - Optional infoById = null; - //Optional deferredTransactionById = null; - Optional getTransactionById = null; - - - ECKey ecKey = new ECKey(Utils.getRandom()); - byte[] delayAccount1Address = ecKey.getAddress(); - String delayAccount1Key = ByteArray.toHexString(ecKey.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] receiverAccountAddress = ecKey3.getAddress(); - String receiverAccountKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] delayAccount3Address = ecKey4.getAddress(); - String delayAccount3Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - ECKey ecKey5 = new ECKey(Utils.getRandom()); - byte[] receiverAccount4Address = ecKey5.getAddress(); - String receiverAccount4Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, threadPoolSize = 30, invocationCount = 2000) - public void test1DelaySendcoinStress() { - String txid = ""; - Integer i = 0; - String cancelId = ""; - while (i++ <= 10000000) { - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - txid = PublicMethed.sendcoinDelayedGetTxid(delayAccount2Address, 1L, 20,fromAddress, - testKey002, blockingStubFull); - //PublicMethed.waitProduceNextBlock(blockingStubFull); - if (i % 20 == 0) { - cancelId = txid; - //PublicMethed.sendcoin(delayAccount2Address,1L,fromAddress,testKey002,blockingStubFull); - } - if (i % 39 == 0) { - PublicMethed.cancelDeferredTransactionById(cancelId,fromAddress,testKey002, - blockingStubFull); - PublicMethed.sendcoin(delayAccount2Address,1L,fromAddress,testKey002, - blockingStubFull); - } - - } - - - } - - /* @Test(enabled = true, description = "Get deferred transaction by id") - public void test2getDeferredTransactionByid() { - //get account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] delayAccount2Address = ecKey2.getAddress(); - String delayAccount2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - receiverAccountAddress = ecKey3.getAddress(); - receiverAccountKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount2Key); - PublicMethed.printAddress(receiverAccountKey); - - //Pre sendcoin to the test account - Assert.assertTrue(PublicMethed.sendcoin(delayAccount2Address, 100000000L,fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(receiverAccountAddress, 10L,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Do delay send coin transaction. - Long delaySecond = 10L; - Long sendCoinAmout = 100L; - - //Query balance before send coin. - Long deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Long recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - String txid = PublicMethed.sendcoinDelayedGetTxid(receiverAccountAddress, sendCoinAmout, - delaySecond,delayAccount2Address, - delayAccount2Key, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance when pre-sendcoin stage. - Long deplayAccountInDelayBalance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Long recevierAccountInDelayalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountInDelayBalance " + deplayAccountInDelayBalance); - logger.info("recevierAccountInDelayalance " + recevierAccountInDelayalance); - Assert.assertTrue(recevierAccountBeforeBalance == recevierAccountInDelayalance); - //Assert.assertTrue(); - - - deferredTransactionById = PublicMethed.getDeferredTransactionById(txid,blockingStubFull); - DeferredTransaction transaction = deferredTransactionById.get(); - String finalTxid = ByteArray.toHexString(Sha256Hash.hash(transaction.getTransaction() - .getRawData().toByteArray())); - PublicMethed.getDeferredTransactionById(finalTxid,blockingStubFull); - logger.info(finalTxid); - //logger.info("receiver address is " + Base58.encode58Check(transaction - .getReceiverAddress().toByteArray())); - Assert.assertTrue(Base58.encode58Check(transaction.getReceiverAddress().toByteArray()) - .equalsIgnoreCase(PublicMethed.getAddressString(receiverAccountKey))); - //logger.info("sender address is " + Base58.encode58Check(transaction - .getSenderAddress().toByteArray())); - Assert.assertTrue(Base58.encode58Check(transaction.getSenderAddress().toByteArray()) - .equalsIgnoreCase(PublicMethed.getAddressString(delayAccount2Key))); - // logger.info("delaySeconds is " + transaction.getDelaySeconds()); - Assert.assertTrue(delaySecond == transaction.getDelaySeconds()); - //logger.info("DelayUntil " + transaction.getDelayUntil()); - Assert.assertTrue(transaction.getDelayUntil() > System.currentTimeMillis()); - //logger.info("Expiration " + transaction.getExpiration()); - Assert.assertTrue(transaction.getExpiration() > System.currentTimeMillis()); - //logger.info("PublishTime " + transaction.getPublishTime()); - Assert.assertTrue(transaction.getPublishTime() < System.currentTimeMillis()); - //Assert.assertTrue(transaction.getDelayUntil() + 60000 == transaction.getExpiration()); - getTransactionById = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("transaction stage in txid is " + getTransactionById.get().getRawData() - .getDeferredStage().getStage()); - - Assert.assertTrue(getTransactionById.get().getRawData().getDeferredStage().getStage() == 1); - getTransactionById = PublicMethed.getTransactionById(finalTxid, blockingStubFull); - logger.info("transaction stage in final id is " + getTransactionById - .get().getRawData().getDeferredStage().getStage()); - Assert.assertTrue(getTransactionById.get().getRawData().getDeferredStage().getStage() == 0); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - PublicMethed.getDeferredTransactionById(finalTxid,blockingStubFull); - deferredTransactionById = PublicMethed.getDeferredTransactionById(txid,blockingStubFull); - finalTxid = ByteArray.toHexString(Sha256Hash.hash(transaction.getTransaction() - .getRawData().toByteArray())); - transaction = deferredTransactionById.get(); - logger.info(finalTxid); - //logger.info("receiver address is " + Base58.encode58Check(transaction.getReceiverAddress() - .toByteArray())); - //logger.info("receiver address is " + Base58.encode58Check(transaction.getSenderAddress() - .toByteArray())); - //logger.info("delaySeconds is " + transaction.getDelaySeconds()); - //logger.info("DelayUntil " + transaction.getDelayUntil()); - //logger.info("Expiration " + transaction.getExpiration()); - //logger.info("PublishTime " + transaction.getPublishTime()); - getTransactionById = PublicMethed.getTransactionById(txid, blockingStubFull); - logger.info("transaction stage in txid is " + getTransactionById.get().getRawData() - .getDeferredStage().getStage()); - getTransactionById = PublicMethed.getTransactionById(finalTxid, blockingStubFull); - logger.info("transaction stage in final id is " + getTransactionById.get().getRawData() - .getDeferredStage().getStage()); - - - - //Query balance after delay send coin. - Long deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount2Address, - blockingStubFull).getBalance(); - Long recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccountAddress, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - - Assert.assertTrue(deplayAccountBeforeBalance - deplayAccountAfterBalance == sendCoinAmout - + 100000L); - Assert.assertTrue(recevierAccountAfterDelayalance - recevierAccountBeforeBalance - == sendCoinAmout); - - }*/ - - @Test(enabled = true, description = "Delay send coin") - public void test3DelaySendCoin() { - ecKey4 = new ECKey(Utils.getRandom()); - delayAccount3Address = ecKey4.getAddress(); - delayAccount3Key = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - PublicMethed.printAddress(delayAccount3Key); - - ecKey5 = new ECKey(Utils.getRandom()); - receiverAccount4Address = ecKey5.getAddress(); - receiverAccount4Key = ByteArray.toHexString(ecKey5.getPrivKeyBytes()); - PublicMethed.printAddress(receiverAccount4Key); - - Long sendCoinAmount = 100000000L; - //Pre sendcoin to the test account - Assert.assertTrue(PublicMethed.sendcoin(delayAccount3Address, sendCoinAmount,fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Do delay send coin transaction. - logger.info("----------------No balance to send coin--------------------"); - //Test no balance to send coin. - //Query balance before send coin. - Long deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - Long recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - Long delaySecond = 4L; - Assert.assertFalse(PublicMethed.sendcoinDelayed(receiverAccount4Address, sendCoinAmount, - delaySecond,delayAccount3Address, delayAccount3Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance after delay send coin. - Long deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - Long recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - - Assert.assertTrue(recevierAccountAfterDelayalance == 0); - logger.info("deplayAccountBeforeBalance: " + deplayAccountBeforeBalance); - logger.info("deplayAccountAfterBalance: " + deplayAccountAfterBalance); - - Assert.assertEquals(deplayAccountBeforeBalance,deplayAccountAfterBalance); - - - logger.info("----------------No balance to create account send coin--------------------"); - //Test delay send coin to create account. - deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - Long createAccountFee = 100000L; - Assert.assertTrue(PublicMethed.sendcoinDelayed(receiverAccount4Address, - deplayAccountBeforeBalance - createAccountFee, delaySecond,delayAccount3Address, - delayAccount3Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance after delay send coin. - deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount3Address, blockingStubFull) - .getBalance(); - recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - - Assert.assertTrue(recevierAccountAfterDelayalance == 0); - Assert.assertTrue(deplayAccountBeforeBalance - deplayAccountAfterBalance == 100000); - - - logger.info("---------------Balance enough to create account send coin--------------------"); - //Test delay send coin to create account. - createAccountFee = 100000L; - deplayAccountBeforeBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - recevierAccountBeforeBalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountBeforeBalance " + deplayAccountBeforeBalance); - logger.info("recevierAccountBeforeBalance " + recevierAccountBeforeBalance); - Assert.assertTrue(PublicMethed.sendcoinDelayed(receiverAccount4Address, - deplayAccountBeforeBalance - createAccountFee - delayTransactionFee, - delaySecond,delayAccount3Address, delayAccount3Key, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //Query balance after delay send coin. - deplayAccountAfterBalance = PublicMethed.queryAccount(delayAccount3Address, - blockingStubFull).getBalance(); - recevierAccountAfterDelayalance = PublicMethed.queryAccount(receiverAccount4Address, - blockingStubFull).getBalance(); - logger.info("deplayAccountAfterBalance " + deplayAccountAfterBalance); - logger.info("recevierAccountAfterDelayalance " + recevierAccountAfterDelayalance); - Long receiverBalanceShouldBe = deplayAccountBeforeBalance - createAccountFee - - delayTransactionFee; - - Assert.assertEquals(recevierAccountAfterDelayalance, receiverBalanceShouldBe); - Assert.assertTrue(deplayAccountAfterBalance == 0); - } - - - - - /** - * constructor. - */ - - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/ExtCodeHashStressTest.java b/src/test/java/stest/tron/wallet/onlinestress/ExtCodeHashStressTest.java deleted file mode 100644 index 43028647c2a..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/ExtCodeHashStressTest.java +++ /dev/null @@ -1,636 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class ExtCodeHashStressTest { - - private AtomicLong count = new AtomicLong(); - private AtomicLong errorCount = new AtomicLong(); - private long startTime = System.currentTimeMillis(); - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private byte[] extCodeHashContractAddress = null; - private byte[] normalContractAddress = null; - private byte[] testContractAddress = null; - - private byte[] dev001Address = fromAddress; - private String dev001Key = testKey002; - - private ECKey ecKey2 = new ECKey(Utils.getRandom()); - private byte[] user001Address = ecKey2.getAddress(); - private String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - PublicMethed.printAddress(dev001Key); - PublicMethed.printAddress(user001Key); - } - - - @Test(enabled = true, description = "Deploy a normal contract to be used for stress testing.") - public void test01DeployNormalContract() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHashStress.sol"; - String contractName = "TriggerNormal"; //TBVEkA72g1wFoBBVLSXFZ2Bp944oL17NeU - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - normalContractAddress = deployContract(code, abi, contractName, blockingStubFull); - - SmartContract smartContract = PublicMethed.getContract(normalContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - - @Test(enabled = true, description = "Deploy a extcodehash contract.") - public void test02DeployExtCodeHashContract() { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 100_000_000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - //before deploy, check account resource - AccountResourceMessage accountResource = PublicMethed.getAccountResource(dev001Address, - blockingStubFull); - long energyLimit = accountResource.getEnergyLimit(); - long energyUsage = accountResource.getEnergyUsed(); - long balanceBefore = PublicMethed.queryAccount(dev001Key, blockingStubFull).getBalance(); - logger.info("before energyLimit is " + Long.toString(energyLimit)); - logger.info("before energyUsage is " + Long.toString(energyUsage)); - logger.info("before balanceBefore is " + Long.toString(balanceBefore)); - - String filePath = "./src/test/resources/soliditycode/extCodeHashStress.sol"; - String contractName = "Trigger"; //THAx2PcAtRCerwrLGN237dahqSUfq5wLnR - HashMap retMap = PublicMethed.getBycodeAbi(filePath, contractName); - - String code = retMap.get("byteCode").toString(); - String abi = retMap.get("abI").toString(); - - extCodeHashContractAddress = deployContract(code, abi, contractName, blockingStubFull); - - SmartContract smartContract = PublicMethed.getContract(extCodeHashContractAddress, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - } - - /** - * trigger. - */ - public byte[] deployContract(String bytecode, String abi, String contractName, - WalletGrpc.WalletBlockingStub blockingStubFull) { - - final String transferTokenTxid = PublicMethed - .deployContractAndGetTransactionInfoById(contractName, abi, bytecode, "", - maxFeeLimit, 0L, 0, 10000, - "0", 0, null, dev001Key, - dev001Address, blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(transferTokenTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - if (infoById.get().getResultValue() != 0) { - Assert.fail("deploy transaction failed with message: " + infoById.get().getResMessage() - .toStringUtf8()); - } - - return infoById.get().getContractAddress().toByteArray(); - } - - /** - * trigger. - */ - public String triggerContractWithMaxFeeLimit(byte[] testAddress, byte[] user001Address, - String user001Key, long maxFeeLimit) { - Assert.assertTrue(PublicMethed.sendcoin(user001Address, 10000_000_000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(fromAddress, - PublicMethed.getFreezeBalanceCount(user001Address, user001Key, 50000L, - blockingStubFull), 0, 1, - ByteString.copyFrom(user001Address), testKey002, blockingStubFull)); - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(extCodeHashContractAddress, - "test(address)", param, false, callValue, - maxFeeLimit, "0", 0, user001Address, user001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - - scheduledExecutorService - .schedule(new CheckTask(triggerTxid, blockingStubFull), 15, TimeUnit.SECONDS); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - - logger - .info("transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - - if (infoById.get().getResMessage().toStringUtf8().toLowerCase().contains("cpu")) { - throw new IllegalArgumentException(); - } - if (infoById.get().getResMessage().toStringUtf8().toLowerCase().contains("timeout")) { - throw new IllegalArgumentException(); - } - return "ok"; - } - - - /** - * trigger. - */ - public String triggerAndGetExtCodeHashList(List testAddress, byte[] user001Address, - String user001Key, long maxFeeLimit, WalletGrpc.WalletBlockingStub blockingStubFull) { - - Long callValue = Long.valueOf(0); - List params = new ArrayList<>(); - for (int i = 0; i < testAddress.size(); i++) { - params.add(Base58.encode58Check(testAddress.get(i))); - } - final String triggerTxid = PublicMethed.triggerParamListContract(extCodeHashContractAddress, - "test(address[])", Arrays.asList(params), false, callValue, - maxFeeLimit, "0", 0, user001Address, user001Key, - blockingStubFull); - - scheduledExecutorService - .schedule(new CheckTask(triggerTxid, blockingStubFull), 15, TimeUnit.SECONDS); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - logger - .info( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - - return "ok"; - - } - - /** - * trigger. - */ - public void triggerAndGetExtCodeHash(byte[] testAddress, byte[] user001Address, - String user001Key, long maxFeeLimit, WalletGrpc.WalletBlockingStub blockingStubFull) { - - Long callValue = Long.valueOf(0); - - String param = "\"" + Base58.encode58Check(testAddress) + "\""; - final String triggerTxid = PublicMethed.triggerContract(normalContractAddress, - "test(address)", param, false, callValue, - 314982000, "0", 0, user001Address, user001Key, - blockingStubFull); - - scheduledExecutorService - .schedule(new CheckTask(triggerTxid, blockingStubFull), 15, TimeUnit.SECONDS); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - logger.info("EnergyUsageTotal: " + transactionInfo.getReceipt().getEnergyUsageTotal()); - logger.info("NetUsage: " + transactionInfo.getReceipt().getNetUsage()); - logger - .info( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - - private synchronized void wirteLine(String fileName, String line) { - try { - BufferedWriter out = new BufferedWriter(new FileWriter(fileName, true)); - out.write(line); - out.newLine(); - out.flush(); - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - class DeployTask implements Runnable { - - Map addressList; - CountDownLatch countDownLatch; - WalletGrpc.WalletBlockingStub stub; - int index; - - DeployTask(Map addressList, int index, CountDownLatch countDownLatch, - WalletGrpc.WalletBlockingStub stub) { - this.index = index; - this.addressList = addressList; - this.countDownLatch = countDownLatch; - this.stub = stub; - } - - @Override - public void run() { - logger.info("depoying :" + index); - String code = Configuration.getByPath("testng.conf") - .getString("code.code_veryLarge"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_veryLarge"); - try { - byte[] deployedAddress = deployContract(code, abi, "test" + index, stub); - String address = Base58.encode58Check(deployedAddress); - wirteLine( - "src/test/resources/addresses2", - address); - logger.info("deployed : " + index + " " + address); - } catch (Throwable e) { - logger.error("deploy error: ", e); - } finally { - countDownLatch.countDown(); - } - } - } - - @Test(enabled = true, description = "Deploy multiple long bytecode contract " - + "and write address to file.") - public void test03DeployMultiLongByteCodeContract() { - - ExecutorService pool = Executors.newFixedThreadPool(30); - Map addressMap = new ConcurrentHashMap<>(); - int size = 50_0_000; - int stubSize = 30; - List stubs = new ArrayList<>(); - for (int i = 0; i < stubSize; i++) { - stubs.add(WalletGrpc.newBlockingStub(channelFull)); - } - - CountDownLatch count = new CountDownLatch(size); - for (int i = 0; i < size; i++) { - - String contractName = "extcodehashContract" + i; - logger.info("[" + i + "]contractName: " + contractName); - pool.submit(new DeployTask(addressMap, i, count, stubs.get(i % stubSize))); - - } - - try { - count.await(); - for (String s : addressMap.keySet()) { - System.out.println(s); - } - - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2); - - class CheckTask implements Runnable { - - String txid; - WalletGrpc.WalletBlockingStub client; - - CheckTask(String txid, WalletGrpc.WalletBlockingStub client) { - this.txid = txid; - this.client = client; - } - - @Override - public void run() { - - Optional infoById = PublicMethed - .getTransactionInfoById(this.txid, blockingStubFull); - - TransactionInfo transactionInfo = infoById.get(); - if (infoById.get().getResultValue() != 0) { - logger.error("txid:" + this.txid); - logger.error( - "transaction failed with message: " + infoById.get().getResMessage().toStringUtf8()); - } - logger.info("infoById" + infoById); - } - } - - - @Test(enabled = true, description = "Calculate the contract maxfeelimit.", - threadPoolSize = 1, invocationCount = 1) - public void test04StressGetExtCodeHashContract() { - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - extCodeHashContractAddress = WalletClient - .decodeFromBase58Check("TEsdDpJQrLBDPmJfDF2Ex53iMfzetqHvn9"); - - // long bytecode contract - testContractAddress = WalletClient.decodeFromBase58Check("TDqSAv8gLFXQRfug5Pr1Ev6zrEj1efC8qe"); - - HashMap retMap = new HashMap<>(); - - long feeLimit = 314982000; - // long feeLimit = 393624800; - // long feeLimit = 406731800; - - long base = 100; - long lastSuccess = feeLimit; - int failed = 0; - - for (int i = 0; i < 1000000000; i++) { - try { - String retCode = triggerContractWithMaxFeeLimit(testContractAddress, user001Address, - user001Key, - feeLimit); - logger.info("[" + i + "]retCode: " + retCode); - logger.info("[" + i + "]feeLimit: " + feeLimit); - lastSuccess = feeLimit; - base *= 2; - feeLimit += base; - failed = 0; - } catch (Exception e) { - failed++; - if (failed > 3) { - break; - } - logger.error("cpu timeout"); - feeLimit = lastSuccess; - base = 100; - } - } - } - - - @Test(enabled = true, description = "Trigger extcodeHash contract stress.") - public void test05TriggerContract() throws FileNotFoundException { - - BufferedReader reader = null; - List addresses = new ArrayList<>(); - try { - reader = new BufferedReader(new FileReader("src/test/resources/address2")); - String line = reader.readLine(); - while (line != null) { - System.out.println(line); - // read next line - line = reader.readLine(); - addresses.add(line); - } - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - ExecutorService pool = Executors.newFixedThreadPool(50); - int stubSize = 50; - List stubs = new ArrayList<>(); - for (int i = 0; i < stubSize; i++) { - stubs.add(WalletGrpc.newBlockingStub(channelFull)); - } - - int paramsSize = 75; // the address count per trigger - int trigger = 0; - for (int i = 0; i + paramsSize < addresses.size(); i += paramsSize) { - System.err.println(trigger++); - System.err.println(i + " " + (i + paramsSize)); - pool.submit(new TriggerTask(addresses.subList(i, i + paramsSize), stubs.get( - (int) (Math.random() * 100 % stubSize)))); - } - - try { - Thread.sleep(100000000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - class TriggerTask implements Runnable { - - List addresses; - WalletGrpc.WalletBlockingStub stub; - - TriggerTask(List addresses, WalletGrpc.WalletBlockingStub stub) { - this.addresses = addresses; - this.stub = stub; - } - - @Override - public void run() { - triggerContact(this.addresses.toArray(new String[0]), stub); - } - } - - /** - * trigger. - */ - public void triggerContact(String[] testList, WalletGrpc.WalletBlockingStub stub) { - - final byte[] user001Address = fromAddress; - final String user001Key = testKey002; - - extCodeHashContractAddress = WalletClient - .decodeFromBase58Check("TJGYcUspHrwPgy72YeaVjD4Skep9Ji8Pnn"); - - final long feeLimit = 102471600; - count.getAndAdd(1); - if (count.get() % 100 == 0) { - long cost = (System.currentTimeMillis() - startTime) / 1000; - logger.info("Count:" + count.get() + ", cost:" + cost - + ", avg:" + count.get() / cost + ", errCount:" + errorCount); - } - - List addressList = new ArrayList<>(); - - for (int k = 0; k < testList.length; k++) { - addressList.add(WalletClient.decodeFromBase58Check(testList[k])); - } - triggerAndGetExtCodeHashList(addressList, user001Address, user001Key, feeLimit, stub); - } - - - @Test(enabled = true, description = "Trigger normal contract stress.") - public void test06TriggerNormalContract() throws FileNotFoundException { - - BufferedReader reader = null; - List addresses = new ArrayList<>(); - try { - reader = new BufferedReader(new FileReader( - "src/test/resources/address2")); - String line = reader.readLine(); - while (line != null) { - System.out.println(line); - // read next line - line = reader.readLine(); - addresses.add(line); - } - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - ExecutorService pool = Executors.newFixedThreadPool(50); - int stubSize = 50; - List stubs = new ArrayList<>(); - for (int i = 0; i < stubSize; i++) { - stubs.add(WalletGrpc.newBlockingStub(channelFull)); - } - - int paramsSize = 50; - int trigger = 0; - for (int i = 0; i + paramsSize < addresses.size(); i += 1) { - System.err.println(trigger++); - System.err.println(i + " " + (i + paramsSize)); - pool.submit( - new TriggerNormalTask(addresses.subList(0, 0 + paramsSize), stubs.get( - (int) (Math.random() * 100 % stubSize)))); - } - - try { - Thread.sleep(100000000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - class TriggerNormalTask implements Runnable { - - List addresses; - WalletGrpc.WalletBlockingStub stub; - - TriggerNormalTask(List addresses, WalletGrpc.WalletBlockingStub stub) { - this.addresses = addresses; - this.stub = stub; - } - - @Override - public void run() { - triggerNormalContact(this.addresses.toArray(new String[0]), stub); - } - } - - /** - * trigger. - */ - public void triggerNormalContact(String[] testList, WalletGrpc.WalletBlockingStub stub) { - - final byte[] user001Address = fromAddress; - final String user001Key = testKey002; - - normalContractAddress = WalletClient - .decodeFromBase58Check("TFUSarvJtCSQhDifdRaioytThohLSLCjq4"); - - final long feeLimit = 51079600; - count.getAndAdd(1); - if (count.get() % 100 == 0) { - long cost = (System.currentTimeMillis() - startTime) / 1000; - logger.info("Count:" + count.get() + ", cost:" + cost - + ", avg:" + count.get() / cost + ", errCount:" + errorCount); - } - - List addressList = new ArrayList<>(); - - for (int k = 0; k < testList.length; k++) { - addressList.add(WalletClient.decodeFromBase58Check(testList[k])); - } - - triggerAndGetExtCodeHash(normalContractAddress, user001Address, - user001Key, feeLimit, stub); - } - - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/HttpStressTest.java b/src/test/java/stest/tron/wallet/onlinestress/HttpStressTest.java deleted file mode 100644 index 26612437267..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/HttpStressTest.java +++ /dev/null @@ -1,165 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.params.CoreConnectionPNames; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.HttpMethed; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class HttpStressTest { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private JSONObject responseContent; - private HttpResponse response; - private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list") - .get(0); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] exchangeOwnerAddress = ecKey1.getAddress(); - String exchangeOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] asset2Address = ecKey2.getAddress(); - String asset2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Long amount = 2048000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - private static final long now = System.currentTimeMillis(); - private static String name = "testAssetIssue002_" + Long.toString(now); - private static final long totalSupply = 10000000000000000L; - private static String assetIssueId1; - private static String assetIssueId2; - private static Integer exchangeId; - private static Long beforeInjectBalance; - static Integer connectionTimeout = Configuration.getByPath("testng.conf") - .getInt("defaultParameter.httpConnectionTimeout"); - static Integer soTimeout = Configuration.getByPath("testng.conf") - .getInt("defaultParameter.httpSoTimeout"); - - - /** - * constructor. - */ - @Test(enabled = true, threadPoolSize = 10, invocationCount = 10) - public void test4InjectExchange() { - final long now = System.currentTimeMillis(); - final long totalSupply = 10000000000000000L; - Long beforeInjectBalance; - HttpClient httpClient = new DefaultHttpClient(); - HttpPost httppost; - httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - connectionTimeout); - httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout); - httppost = new HttpPost(url); - httppost.setHeader("Content-type", "application/json; charset=utf-8"); - httppost.setHeader("Connection", "Close"); - - response = HttpMethed - .sendCoin(httpnode, fromAddress, exchangeOwnerAddress, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - response = HttpMethed.sendCoin(httpnode, fromAddress, asset2Address, amount, testKey002); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - //Create an asset issue - response = HttpMethed.assetIssue(httpnode, exchangeOwnerAddress, name, name, totalSupply, 1, 1, - System.currentTimeMillis() + 5000, System.currentTimeMillis() + 50000000, - 2, 3, description, url, 1000L, 1000L, exchangeOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - response = HttpMethed.assetIssue(httpnode, asset2Address, name, name, totalSupply, 1, 1, - System.currentTimeMillis() + 5000, System.currentTimeMillis() + 50000000, - 2, 3, description, url, 1000L, 1000L, asset2Key); - Assert.assertTrue(HttpMethed.verificationResult(response)); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAccount(httpnode, exchangeOwnerAddress); - responseContent = HttpMethed.parseResponseContent(response); - assetIssueId1 = responseContent.getString("asset_issued_ID"); - Assert.assertTrue(Integer.parseInt(assetIssueId1) > 1000000); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.getAccount(httpnode, asset2Address); - responseContent = HttpMethed.parseResponseContent(response); - assetIssueId2 = responseContent.getString("asset_issued_ID"); - Assert.assertTrue(Integer.parseInt(assetIssueId2) > 1000000); - - response = HttpMethed - .transferAsset(httpnode, asset2Address, exchangeOwnerAddress, assetIssueId2, - 100000000000000L, asset2Key); - Assert.assertTrue(HttpMethed.verificationResult(response)); - - HttpMethed.waitToProduceOneBlock(httpnode); - HttpMethed.waitToProduceOneBlock(httpnode); - - //Create exchange. - response = HttpMethed.exchangeCreate(httpnode, exchangeOwnerAddress, assetIssueId1, - 50000000000000L, assetIssueId2, 50000000000000L, exchangeOwnerKey); - Assert.assertTrue(HttpMethed.verificationResult(response)); - - HttpMethed.waitToProduceOneBlock(httpnode); - HttpMethed.waitToProduceOneBlock(httpnode); - response = HttpMethed.listExchanges(httpnode); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("exchanges")); - Assert.assertTrue(jsonArray.size() >= 1); - exchangeId = jsonArray.size(); - - response = HttpMethed.getExchangeById(httpnode, exchangeId); - responseContent = HttpMethed.parseResponseContent(response); - HttpMethed.printJsonContent(responseContent); - - Integer times = 0; - while (times++ <= 10000) { - HttpMethed.sendCoin(httpnode, fromAddress, exchangeOwnerAddress, 100L, testKey002); - HttpMethed.sendCoin(httpnode, fromAddress, asset2Address, 100L, testKey002); - //Inject exchange. - HttpMethed.exchangeInject(httpnode, exchangeOwnerAddress, exchangeId, assetIssueId1, - 10L, exchangeOwnerKey); - HttpMethed.exchangeWithdraw(httpnode, exchangeOwnerAddress, exchangeId, assetIssueId1, - 10L, exchangeOwnerKey); - HttpMethed.exchangeTransaction(httpnode, exchangeOwnerAddress, exchangeId, assetIssueId1, - 100L, 1L, exchangeOwnerKey); - HttpMethed.exchangeTransaction(httpnode, exchangeOwnerAddress, exchangeId, assetIssueId2, - 100L, 1L, exchangeOwnerKey); - HttpMethed.transferAsset(httpnode, asset2Address, exchangeOwnerAddress, assetIssueId2, - 1L, asset2Key); - HttpMethed.transferAsset(httpnode, exchangeOwnerAddress, asset2Address, assetIssueId1, - 1L, exchangeOwnerKey); - HttpMethed.participateAssetIssue(httpnode, exchangeOwnerAddress, asset2Address, - assetIssueId1, 1L, asset2Key); - HttpMethed.participateAssetIssue(httpnode, asset2Address, exchangeOwnerAddress, - assetIssueId2, 1L, exchangeOwnerKey); - HttpMethed.freezeBalance(httpnode, fromAddress, 10000000000L, 0, 0, - exchangeOwnerAddress, testKey002); - HttpMethed.freezeBalance(httpnode, fromAddress, 10000000000L, 0, 1, - exchangeOwnerAddress, testKey002); - HttpMethed.unFreezeBalance(httpnode, fromAddress, 0, exchangeOwnerAddress, testKey002); - HttpMethed.unFreezeBalance(httpnode, fromAddress, 1, exchangeOwnerAddress, testKey002); - } - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - HttpMethed.disConnect(); - } -} diff --git a/src/test/java/stest/tron/wallet/onlinestress/MainNetTransferSendOrAsset.java b/src/test/java/stest/tron/wallet/onlinestress/MainNetTransferSendOrAsset.java deleted file mode 100644 index 0d02851cc70..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/MainNetTransferSendOrAsset.java +++ /dev/null @@ -1,158 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class MainNetTransferSendOrAsset { - - //testng001、testng002、testng003、testng004 - //fromAssetIssue - private final String testKey001 = - "BC70ADC5A0971BA3F7871FBB7249E345D84CE7E5458828BE1E28BF8F98F2795B"; - //toAssetIssue - private final String testKey002 = - "F153A0E1A65193846A3D48A091CD0335594C0A3D9817B3441390FDFF71684C84"; - //fromSend - private final String testKey003 = - "2514B1DD2942FF07F68C2DDC0EE791BC7FBE96FDD95E89B7B9BB3B4C4770FFAC"; - //toSend - private final String testKey004 = - "56244EE6B33C14C46704DFB67ED5D2BBCBED952EE46F1FD88A50C32C8C5C64CE"; - //Default - private final String defaultKey = - "8DFBB4513AECF779A0803C7CEBF2CDCC51585121FAB1E086465C4E0B40724AF1"; - - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey001); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] fromSendAddress = PublicMethed.getFinalAddress(testKey003); - private final byte[] toSendAddress = PublicMethed.getFinalAddress(testKey004); - private final byte[] defaultAddress = PublicMethed.getFinalAddress(defaultKey); - - - private final Long transferAmount = 1L; - private Long start; - private Long end; - private Long beforeToBalance; - private Long afterToBalance; - private Long beforeToAssetBalance = 0L; - private Long afterToAssetBalance = 0L; - private final Long sendAmount = 1L; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Account fromAccount = PublicMethed.queryAccount(testKey001, blockingStubFull); - Account toAccount = PublicMethed.queryAccount(testKey002, blockingStubFull); - if (fromAccount.getBalance() < 10000000000L) { - PublicMethed - .sendcoin(fromAddress, 10000000000L, defaultAddress, defaultKey, blockingStubFull); - } - if (fromAccount.getAssetCount() == 0) { - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - PublicMethed.createAssetIssue(fromAddress, "testNetAsset", 1000000000000L, - 1, 1, start, end, 1, "wwwwww", "wwwwwwww", 100000L, - 100000L, 1L, 1L, testKey001, blockingStubFull); - } - beforeToBalance = toAccount.getBalance(); - beforeToAssetBalance = toAccount.getAssetMap().get("testNetAsset"); - - Account fromSendAccount = PublicMethed.queryAccount(testKey003, blockingStubFull); - Account toSendAccount = PublicMethed.queryAccount(testKey004, blockingStubFull); - if (fromSendAccount.getBalance() < 1000000000L) { - PublicMethed - .sendcoin(fromSendAddress, 1000000000L, defaultAddress, defaultKey, blockingStubFull); - } - beforeToBalance = toAccount.getBalance(); - logger.info("Before From account balance is " + Long.toString(fromAccount.getBalance())); - logger.info("Before To account balance is " + Long.toString(toAccount.getBalance())); - start = System.currentTimeMillis(); - } - - @Test(enabled = false, threadPoolSize = 20, invocationCount = 100000) - public void freezeAnd() throws InterruptedException { - Random rand = new Random(); - Integer randNum = 0; - randNum = rand.nextInt(1000); - try { - Thread.sleep(randNum); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - Integer i = 0; - while (i < 60) { - PublicMethed - .transferAsset(toAddress, "testNetAsset".getBytes(), transferAmount, fromAddress, - testKey001, blockingStubFull); - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - PublicMethed.sendcoin(toSendAddress, sendAmount, fromSendAddress, testKey003, - blockingStubFull); - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - end = System.currentTimeMillis(); - logger.info("Time is " + Long.toString(end - start)); - Account fromAccount = PublicMethed.queryAccount(testKey001, blockingStubFull); - Account toAccount = PublicMethed.queryAccount(testKey002, blockingStubFull); - afterToBalance = toAccount.getBalance(); - afterToAssetBalance = toAccount.getAssetMap().get("testNetAsset"); - - logger.info("Success times is " + Long.toString(afterToAssetBalance - beforeToAssetBalance)); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/MainNetVoteOrFreezeOrCreate.java b/src/test/java/stest/tron/wallet/onlinestress/MainNetVoteOrFreezeOrCreate.java deleted file mode 100644 index 0221b3aad31..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/MainNetVoteOrFreezeOrCreate.java +++ /dev/null @@ -1,366 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.WitnessList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class MainNetVoteOrFreezeOrCreate { - - //testng001、testng002、testng003、testng004 - //Devaccount - private final String testKey001 = - "2514B1DD2942FF07F68C2DDC0EE791BC7FBE96FDD95E89B7B9BB3B4C4770FFAC"; - //Zion - private final String testKey002 = - "56244EE6B33C14C46704DFB67ED5D2BBCBED952EE46F1FD88A50C32C8C5C64CE"; - //Default - private final String defaultKey = - //Mainet - //"8DFBB4513AECF779A0803C7CEBF2CDCC51585121FAB1E086465C4E0B40724AF1"; - //Beta Env - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey001); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey002); - private final byte[] defaultAddress = PublicMethed.getFinalAddress(defaultKey); - - - private final Long sendAmount = 1026000000L; - private Long start; - private Long end; - private Long beforeToBalance; - private Long afterToBalance; - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - - private static final long now = System.currentTimeMillis(); - private static String name = "mainNetAsset_" + Long.toString(now); - long totalSupply = now; - Long freeAssetNetLimit = 30000L; - Long publicFreeAssetNetLimit = 30000L; - String description = "f"; - String url = "h"; - Long startTime; - Long endTime; - Boolean ret = false; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset016Address = ecKey1.getAddress(); - String testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - startTime = System.currentTimeMillis(); - } - - //@Test(enabled = false) - @Test(enabled = false, threadPoolSize = 2, invocationCount = 2) - public void freezeAndSendcoin() throws InterruptedException { - Random rand = new Random(); - Integer randNum = 0; - randNum = rand.nextInt(1000); - try { - Thread.sleep(randNum); - } catch (InterruptedException e) { - e.printStackTrace(); - } - GrpcAPI.WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - Integer i = 0; - while (i++ < 3) { - ret = false; - Integer waitTime = 10; - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] accountAddress = ecKey1.getAddress(); - String testKeyAccount = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - logger.info(Base58.encode58Check(accountAddress)); - logger.info(testKeyAccount); - Integer tryTimes = 0; - - while (!ret) { - ret = PublicMethed - .createAccount(defaultAddress, accountAddress, defaultKey, blockingStubFull); - logger.info("createAccount"); - - if (tryTimes++ == 10) { - break; - } - } - - ret = false; - while (!ret) { - ret = PublicMethed - .sendcoin(accountAddress, sendAmount, defaultAddress, defaultKey, blockingStubFull); - logger.info("sendcoin"); - } - ret = false; - while (!ret) { - name = "mainNetAsset_" + Long.toString(System.currentTimeMillis()); - totalSupply = System.currentTimeMillis(); - start = System.currentTimeMillis() + 2000; - end = System.currentTimeMillis() + 1000000000; - ret = PublicMethed.createAssetIssue(accountAddress, name, totalSupply, 1, 1, start, end, - 1, description, url, 3000L, 3000L, 1L, 1L, - testKeyAccount, blockingStubFull); - logger.info("createAssetIssue"); - } - ret = false; - while (!ret) { - ret = freezeBalance(accountAddress, 1000000L, 3, testKeyAccount, - blockingStubFull); - logger.info("freezeBalance"); - } - /* ret = false; - while (!ret) { - ret = PublicMethed - .transferAsset(toAddress, name.getBytes(), 10L, accountAddress, testKeyAccount, - blockingStubFull); - logger.info("transferAsset"); - }*/ - ret = false; - while (!ret) { - String voteStr = Base58 - .encode58Check(result.get().getWitnesses(i % 5).getAddress().toByteArray()); - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - ret = voteWitness(smallVoteMap, accountAddress, testKeyAccount); - logger.info("voteWitness"); - } - } - } - - /** - * constructor. - */ - - @AfterClass(enabled = false) - public void shutdown() throws InterruptedException { - endTime = System.currentTimeMillis(); - logger.info("Time is " + Long.toString(endTime - startTime)); - Account fromAccount = PublicMethed.queryAccount(testKey001, blockingStubFull); - Account toAccount = PublicMethed.queryAccount(testKey002, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] addRess, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - final long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - logger.info("address = " + ByteArray.toHexString(address)); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - //logger.info("transaction == null,\n contract:{},\n transaction:{}" , contract.toString(), - // transaction.toString()); - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - //logger.info(response.getCode().toString()); - return false; - } - /* try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - }*/ - return true; - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public static Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - Protocol.Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Contract.FreezeBalanceContract.Builder builder = Contract.FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - Contract.FreezeBalanceContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - return true; - } -} - diff --git a/src/test/java/stest/tron/wallet/onlinestress/MutiSignStress.java b/src/test/java/stest/tron/wallet/onlinestress/MutiSignStress.java deleted file mode 100644 index f843824e93c..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/MutiSignStress.java +++ /dev/null @@ -1,153 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class MutiSignStress { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress = PublicMethed.getFinalAddress(witnessKey001); - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - ByteString assetAccountId1; - String[] permissionKeyString = new String[2]; - String[] ownerKeyString = new String[1]; - String accountPermissionJson = ""; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] newAddress = ecKey4.getAddress(); - String newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, threadPoolSize = 20, invocationCount = 20) - public void testMutiSignForAccount() { - Integer i = 0; - while (i < 20) { - ecKey1 = new ECKey(Utils.getRandom()); - manager1Address = ecKey1.getAddress(); - manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - manager2Address = ecKey2.getAddress(); - manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - ecKey3 = new ECKey(Utils.getRandom()); - ownerAddress = ecKey3.getAddress(); - ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - PublicMethed.printAddress(ownerKey); - - ecKey4 = new ECKey(Utils.getRandom()); - newAddress = ecKey4.getAddress(); - newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - PublicMethed.sendcoin(ownerAddress, 4000000L, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(ownerAddress, 4000000L, fromAddress, testKey002, - blockingStubFull); - PublicMethed.sendcoin(ownerAddress, 4000000L, fromAddress, testKey002, - blockingStubFull); - permissionKeyString[0] = manager1Key; - permissionKeyString[1] = manager2Key; - ownerKeyString[0] = ownerKey; - accountPermissionJson = "[{\"keys\":[{\"address\":\"" - + PublicMethed.getAddressString(ownerKey) - + "\",\"weight\":2}],\"name\":\"owner\",\"threshold\":2,\"parent\":\"owner\"}," - + "{\"parent\":\"owner\",\"keys\":[{\"address\":\"" - + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1},{\"address\":\"" - + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}],\"name\":\"active\"," - + "\"threshold\":2}]"; - //logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - String updateName = Long.toString(System.currentTimeMillis()); - - PublicMethedForMutiSign.sendcoin(newAddress, 1000000L, ownerAddress, ownerKey, - blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.sendcoin(newAddress, 1000000L, ownerAddress, ownerKey, - blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.sendcoin(newAddress, 1000000L, ownerAddress, ownerKey, - blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.freezeBalance(ownerAddress, 1000000L, 0, - ownerKey, blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.freezeBalance(ownerAddress, 1000000L, 0, - ownerKey, blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.freezeBalance(ownerAddress, 1000000L, 0, - ownerKey, blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.unFreezeBalance(ownerAddress, ownerKey, 0, null, - blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.unFreezeBalance(ownerAddress, ownerKey, 0, null, - blockingStubFull, permissionKeyString); - PublicMethedForMutiSign.unFreezeBalance(ownerAddress, ownerKey, 0, null, - blockingStubFull, permissionKeyString); - } - - - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestApproveProposal.java b/src/test/java/stest/tron/wallet/onlinestress/TestApproveProposal.java deleted file mode 100644 index 99876303d33..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestApproveProposal.java +++ /dev/null @@ -1,239 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ProposalList; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.core.Wallet; -import org.tron.protos.Contract.TransferContract; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.ChainParameters; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class TestApproveProposal { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - //Witness 47.93.33.201 - private final String witnessKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key2"); - //Witness 123.56.10.6 - private final String witnessKey003 = Configuration.getByPath("testng.conf") - .getString("witness.key3"); - //Wtiness 39.107.80.135 - private final String witnessKey004 = Configuration.getByPath("testng.conf") - .getString("witness.key4"); - //Witness 47.93.184.2 - private final String witnessKey005 = Configuration.getByPath("testng.conf") - .getString("witness.key5"); - - - private final byte[] witness001Address = PublicMethed.getFinalAddress(witnessKey001); - private final byte[] witness002Address = PublicMethed.getFinalAddress(witnessKey002); - private final byte[] witness003Address = PublicMethed.getFinalAddress(witnessKey003); - private final byte[] witness004Address = PublicMethed.getFinalAddress(witnessKey004); - private final byte[] witness005Address = PublicMethed.getFinalAddress(witnessKey005); - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void testApproveProposal() { - HashMap proposalMap = new HashMap(); - //proposalMap.put(25L, 1L); - proposalMap.put(27L, 0L); - //proposalMap.put(28L, 1L); - Assert.assertTrue(PublicMethed.createProposal(witness001Address, witnessKey001, - proposalMap, blockingStubFull)); - try { - Thread.sleep(20000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //Get proposal list - ProposalList proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - Optional listProposals = Optional.ofNullable(proposalList); - final Integer proposalId = listProposals.get().getProposalsCount(); - logger.info(Integer.toString(proposalId)); - - //Get proposal list after approve - proposalList = blockingStubFull.listProposals(EmptyMessage.newBuilder().build()); - listProposals = Optional.ofNullable(proposalList); - logger.info(Integer.toString(listProposals.get().getProposals(0).getApprovalsCount())); - - String[] witnessKey = { - - "369F095838EB6EED45D4F6312AF962D5B9DE52927DA9F04174EE49F9AF54BC77", - "9FD8E129DE181EA44C6129F727A6871440169568ADE002943EAD0E7A16D8EDAC", - - }; - byte[] witnessAddress; - for (String key : witnessKey) { - witnessAddress = PublicMethed.getFinalAddress(key); - PublicMethed.approveProposal(witnessAddress, key, proposalId, - true, blockingStubFull); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - @Test(enabled = true) - public void testGetAllNodeBlockNum() throws InterruptedException { - String[] nodeIp = { - "47.93.14.253:50051", - "39.105.28.73:50051", - "101.200.51.70:50051", - "47.94.209.241:50051", - "47.94.148.150:50051", - "47.94.9.222:50051", - "39.107.87.203:50051" - }; - - for (String ip : nodeIp) { - fullnode = ip; - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Long currentBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - logger.info("ip " + ip + ", block num is : " + currentBlockNum); - - Integer times = 0; - while (times++ <= -100) { - currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Transaction.Contract contract; - TransferContract transferContract; - Integer triggerNum = 0; - Integer transactionNum = 0; - for (Transaction transaction : currentBlock.getTransactionsList()) { - if (transaction.getRawData().getContract(0).getContractName().isEmpty()) { - transactionNum++; - } else { - triggerNum++; - - } - - } - - logger.info("ip " + ip + ", block num is : " + currentBlockNum); - logger.info("Transfer contract num is " + transactionNum); - logger.info("Trigger contract num is " + triggerNum); - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - - } - - - } - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - } - - @Test(enabled = true) - public void testGetChainParameters() { - //Set the default map - HashMap defaultCommitteeMap = new HashMap(); - defaultCommitteeMap.put("MAINTENANCE_TIME_INTERVAL", 300000L); - defaultCommitteeMap.put("ACCOUNT_UPGRADE_COST", 9999000000L); - defaultCommitteeMap.put("CREATE_ACCOUNT_FEE", 100000L); - defaultCommitteeMap.put("TRANSACTION_FEE", 10L); - defaultCommitteeMap.put("ASSET_ISSUE_FEE", 1024000000L); - defaultCommitteeMap.put("WITNESS_PAY_PER_BLOCK", 32000000L); - defaultCommitteeMap.put("WITNESS_STANDBY_ALLOWANCE", 115200000000L); - defaultCommitteeMap.put("CREATE_NEW_ACCOUNT_FEE_IN_SYSTEM_CONTRACT", 0L); - defaultCommitteeMap.put("CREATE_NEW_ACCOUNT_BANDWIDTH_RATE", 1L); - - ChainParameters chainParameters = blockingStubFull - .getChainParameters(EmptyMessage.newBuilder().build()); - Optional getChainParameters = Optional.ofNullable(chainParameters); - logger.info(Long.toString(getChainParameters.get().getChainParameterCount())); - for (Integer i = 0; i < getChainParameters.get().getChainParameterCount(); i++) { - logger.info("Index is:" + i); - logger.info(getChainParameters.get().getChainParameter(i).getKey()); - logger.info(Long.toString(getChainParameters.get().getChainParameter(i).getValue())); - } - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestExceptionCodeAndAbi.java b/src/test/java/stest/tron/wallet/onlinestress/TestExceptionCodeAndAbi.java deleted file mode 100644 index 747edf2c62d..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestExceptionCodeAndAbi.java +++ /dev/null @@ -1,407 +0,0 @@ - -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TestExceptionCodeAndAbi { - - //testng001、testng002、testng003、testng004 - private final String testNetAccountKey = - "6815B367FDDE637E53E9ADC8E69424E07724333C9A2B973CFA469975E20753FC"; - //"FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - //"BC70ADC5A0971BA3F7871FBB7249E345D84CE7E5458828BE1E28BF8F98F2795B"; - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - - private ManagedChannel channelFull2 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull2 = null; - - private ManagedChannel channelFull3 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull3 = null; - - private ManagedChannel channelFull4 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull4 = null; - - - private ManagedChannel channelFull5 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull5 = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode2 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String fullnode3 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(2); - private String fullnode4 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(3); - private String fullnode5 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(4); - - byte[] contractAddress = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] asset016Address = ecKey1.getAddress(); - String testKeyForAssetIssue016 = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - PublicMethed.printAddress(testKeyForAssetIssue016); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelFull2 = ManagedChannelBuilder.forTarget(fullnode2) - .usePlaintext(true) - .build(); - blockingStubFull2 = WalletGrpc.newBlockingStub(channelFull2); - - channelFull3 = ManagedChannelBuilder.forTarget(fullnode3) - .usePlaintext(true) - .build(); - blockingStubFull3 = WalletGrpc.newBlockingStub(channelFull3); - - channelFull4 = ManagedChannelBuilder.forTarget(fullnode4) - .usePlaintext(true) - .build(); - blockingStubFull4 = WalletGrpc.newBlockingStub(channelFull4); - - channelFull5 = ManagedChannelBuilder.forTarget(fullnode5) - .usePlaintext(true) - .build(); - blockingStubFull5 = WalletGrpc.newBlockingStub(channelFull5); - - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - PublicMethed.sendcoin(asset016Address, 10000000000000L, testNetAccountAddress, - testNetAccountKey, blockingStubFull); - Assert.assertTrue(PublicMethed.freezeBalance(asset016Address, 1000000L, 3, - testKeyForAssetIssue016, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(asset016Address, 3000000000L, - 3, 1, testKeyForAssetIssue016, blockingStubFull)); - } - - @Test(enabled = false) - public void testExceptionCodeAndAbi() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(testNetAccountAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - //Long storageLimit = accountResource.getStorageLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - //Long storageUsage = accountResource.getStorageUsed(); - Account account = PublicMethed.queryAccount(testNetAccountKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - //logger.info("before storage limit is " + Long.toString(storageLimit)); - //logger.info("before storage usaged is " + Long.toString(storageUsage)); - Long maxFeeLimit = 100000000000L; - Integer times = 0; - String txid; - byte[] contractAddress; - Optional infoById = null; - Long energyTotal; - - while (times++ < 1) { - String contractName = "Fomo3D"; - String code = "60806040" + getRandomCode(2734) + getRandomCode(1000) + "0029"; - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestExceptionCodeAndAbi_testExceptionCodeAndAbi"); - txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, code, "", - maxFeeLimit, 0L, 100, null, testNetAccountKey, testNetAccountAddress, blockingStubFull); - logger.info("createGen0 " + txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - energyTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - //writeCsv(code,abi,"", "","",txid,energyTotal.toString()); - - } - //final SmartContract smartContract = PublicMethed.getContract(contractAddress, - // blockingStubFull); - accountResource = PublicMethed.getAccountResource(testNetAccountAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - //storageLimit = accountResource.getStorageLimit(); - cpuUsage = accountResource.getEnergyUsed(); - //storageUsage = accountResource.getStorageUsed(); - account = PublicMethed.queryAccount(testNetAccountKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - //logger.info("after storage limit is " + Long.toString(storageLimit)); - //logger.info("after storage usaged is " + Long.toString(storageUsage)); - //Assert.assertTrue(storageUsage > 0); - //Assert.assertTrue(storageLimit > 0); - Assert.assertTrue(cpuLimit > 0); - Assert.assertTrue(cpuUsage > 0); - //Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - //Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - //Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - //logger.info(smartContract.getName()); - //logger.info(smartContract.getAbi().toString()); - } - - @Test(enabled = false) - public void testtimeout() { - String txid = ""; - Long energyTotal; - String contractName = "timeout"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestExceptionCodeAndAbi_testtimeout"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestExceptionCodeAndAbi_testtimeout"); - contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, 0L, - 100, null, testKeyForAssetIssue016, asset016Address, blockingStubFull); - Optional infoById = null; - Integer triggerNum = 10000000; - Long energy; - Integer times = 0; - Account info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - Long beforeBalance; - Long beforeNetLimit; - Long beforeFreeNetLimit; - Long beforeFreeNetUsed; - Long beforeNetUsed; - Long beforeEnergyLimit; - Long beforeEnergyUsed; - - Long afterBalance; - Long afterNetLimit; - Long afterFreeNetLimit; - Long afterFreeNetUsed; - Long afterNetUsed; - Long afterEnergyLimit; - Long afterEnergyUsed; - - Long energyUsed; - Long netUsed; - Long energyFee; - Long fee; - Long energyUsageTotal; - Long netFee; - Long minBalance; - - AccountResourceMessage resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull); - - while (times++ < 10000) { - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull); - beforeBalance = info.getBalance(); - beforeEnergyLimit = resourceInfo.getEnergyLimit(); - beforeEnergyUsed = resourceInfo.getEnergyUsed(); - beforeFreeNetLimit = resourceInfo.getFreeNetLimit(); - beforeNetLimit = resourceInfo.getNetLimit(); - beforeNetUsed = resourceInfo.getNetUsed(); - beforeFreeNetUsed = resourceInfo.getFreeNetUsed(); - logger.info("beofre free net used:" + Long.toString(beforeFreeNetUsed)); - - logger.info("before in 1 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull1).getBalance()); - logger.info("before in 2 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull2).getBalance()); - logger.info("before in 3 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull3).getBalance()); - logger.info("before in 4 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull4).getBalance()); - logger.info("before in 5 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull5).getBalance()); - - txid = PublicMethed.triggerContract(contractAddress, - "testUseCpu(uint256)", triggerNum.toString(), false, - 0, maxFeeLimit, asset016Address, testKeyForAssetIssue016, blockingStubFull); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull2); - energyUsageTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - fee = infoById.get().getFee(); - energyFee = infoById.get().getReceipt().getEnergyFee(); - netUsed = infoById.get().getReceipt().getNetUsage(); - energyUsed = infoById.get().getReceipt().getEnergyUsage(); - netFee = infoById.get().getReceipt().getNetFee(); - - info = PublicMethed.queryAccount(testKeyForAssetIssue016, blockingStubFull3); - afterBalance = info.getBalance(); - afterEnergyLimit = resourceInfo.getEnergyLimit(); - afterEnergyUsed = resourceInfo.getEnergyUsed(); - afterFreeNetLimit = resourceInfo.getFreeNetLimit(); - afterNetLimit = resourceInfo.getNetLimit(); - afterNetUsed = resourceInfo.getNetUsed(); - minBalance = beforeBalance - afterBalance; - resourceInfo = PublicMethed.getAccountResource(asset016Address, - blockingStubFull2); - afterFreeNetUsed = resourceInfo.getFreeNetUsed(); - - serachInfo(txid, blockingStubFull1); - serachInfo(txid, blockingStubFull2); - serachInfo(txid, blockingStubFull3); - serachInfo(txid, blockingStubFull4); - serachInfo(txid, blockingStubFull5); - logger.info("after free net used:" + Long.toString(afterFreeNetUsed)); - - logger.info("after in 1 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull1).getBalance()); - logger.info("after in 2 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull2).getBalance()); - logger.info("after in 3 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull3).getBalance()); - logger.info("after in 4 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull4).getBalance()); - logger.info("after in 5 the balance is " + PublicMethed.queryAccount(asset016Address, - blockingStubFull5).getBalance()); - - writeCsv(minBalance.toString(), beforeBalance.toString(), beforeNetLimit.toString(), - beforeFreeNetLimit.toString(), beforeNetUsed.toString(), - beforeEnergyLimit.toString(), beforeEnergyUsed.toString(), beforeFreeNetUsed.toString(), - energyUsageTotal.toString(), fee.toString(), energyFee.toString(), - netUsed.toString(), energyUsed.toString(), netFee.toString(), afterBalance.toString(), - afterEnergyLimit.toString(), afterEnergyUsed.toString(), afterFreeNetUsed.toString(), - afterFreeNetLimit.toString(), afterNetLimit.toString(), afterNetUsed.toString(), txid, - testKeyForAssetIssue016); - } - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public static void serachInfo(String txid, WalletGrpc.WalletBlockingStub blockingStubFull) { - Optional infoById = PublicMethed.getTransactionInfoById(txid, - blockingStubFull); - logger.info("---------------------------------------------"); - - logger.info("fee is " + infoById.get().getFee()); - logger.info("Energy fee is " + infoById.get().getReceipt().getEnergyFee()); - logger.info("Total energy is " + infoById.get().getReceipt().getEnergyUsageTotal()); - logger.info("Energy used is " + infoById.get().getReceipt().getEnergyUsage()); - logger.info("Net used is " + infoById.get().getReceipt().getNetUsage()); - logger.info("Net fee is " + infoById.get().getReceipt().getNetFee()); - - } - - - /** - * constructor. - */ - - public static String getRandomCode(int length) { - String str = "0123456789"; - Random random = new Random(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < length; i++) { - int number = random.nextInt(10); - sb.append(str.charAt(number)); - } - return sb.toString(); - } - - - /** - * constructor. - */ - - public static void writeCsv(String minBalance, String beforeBalance, String beforeNetLimit, - String beforeFreeNet, String beforeNetUsed, String beforeEnergyLimit, String beforeEnergyUsed, - String beforeFreeNetUsed, String energyUsageTotal, String fee, String energyFee, - String netUsed, String energyUsed, - String netFee, String afterBalance, String afterEnergyLimit, String afterEnergyUsed, - String afterFreeNetUsed, String afterFreeNet, String afterNetLimit, - String afterNetUsed, String txid, String testKeyForAssetIssue016) { - try { - File csv = new File("/Users/wangzihe/Documents/costFee.csv"); - String time = Long.toString(System.currentTimeMillis()); - BufferedWriter bw = new BufferedWriter(new FileWriter(csv, true)); - bw.write("TestTimeoutusefeelimit:(HaveEnergyAndHaveFreezeNet)" + "," + "timestamp" + time - + "," + "min:" + minBalance + "," + "beforeBalance:" + beforeBalance + "," - + "beforeNetLimit:" - + beforeNetLimit + "," + "beforeFreeNet:" + beforeFreeNet + "," + "beforeNetused:" - + beforeNetUsed - + "," + "beforeEnergyLimit:" + beforeEnergyLimit + "," + "beforeEnergyUsed:" - + beforeEnergyUsed - + "," + "beforeFreeNetUsed" + beforeFreeNetUsed + "," + "energyUsageTotal:" - + energyUsageTotal - + "," + "fee:" + fee + "," + "energyFee:" + energyFee + "," + "netUsed:" + netUsed + "," - + "energyUsed:" + energyUsed + "," + "netFee:" + netFee + "," + "afterBalance:" - + afterBalance + "," + "afterEnergyLimit:" + afterEnergyLimit + "," - + "afterEnergyUsed:" + afterEnergyUsed + "," + "afterFreeNetUsed:" + afterFreeNetUsed - + "," + "afterFreeNet:" + afterFreeNet + "," + "afterNetLimit:" + afterNetLimit + "," - + "afterNetUsed:" + afterNetUsed + "," + txid + "," + testKeyForAssetIssue016); - bw.newLine(); - bw.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - } - -} - - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestExchangeTransaction.java b/src/test/java/stest/tron/wallet/onlinestress/TestExchangeTransaction.java deleted file mode 100644 index 844282464fa..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestExchangeTransaction.java +++ /dev/null @@ -1,184 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.ExchangeList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Exchange; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class TestExchangeTransaction { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - Optional listExchange; - Optional exchangeIdInfo; - Integer exchangeId = 0; - Integer exchangeRate = 10; - Long firstTokenInitialBalance = 10000L; - Long secondTokenInitialBalance = firstTokenInitialBalance * exchangeRate; - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - } - - @Test(enabled = true) - public void testCreateShieldToken() { - String tokenOwnerKey = "2925e186bb1e88988855f11ebf20ea3a6e19ed92328b0ffb576122e769d45b68"; - byte[] tokenOwnerAddress = PublicMethed.getFinalAddress(tokenOwnerKey); - PublicMethed.printAddress(tokenOwnerKey); - Assert.assertTrue(PublicMethed.sendcoin(tokenOwnerAddress, 20480000000L, fromAddress, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - String name = "shieldToken"; - Long start = System.currentTimeMillis() + 20000; - Long end = System.currentTimeMillis() + 10000000000L; - Long totalSupply = 1500000000000001L; - String description = "This asset issue is use for exchange transaction stress"; - String url = "This asset issue is use for exchange transaction stress"; - Assert.assertTrue(PublicMethed.createAssetIssue(tokenOwnerAddress, name, totalSupply, 1, 1, - start, end, 1, description, url, 1000L, 1000L, - 1L, 1L, tokenOwnerKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Account getAssetIdFromThisAccount = - PublicMethed.queryAccount(tokenOwnerAddress, blockingStubFull); - ByteString assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - logger.info("AssetId:" + assetAccountId.toString()); - - - - } - - @Test(enabled = true, threadPoolSize = 20, invocationCount = 20) - public void testExchangeTransaction() { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] exchangeAddress = ecKey1.getAddress(); - String exchangeKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - final byte[] transactionAddress = ecKey2.getAddress(); - String transactionKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - PublicMethed.printAddress(exchangeKey); - PublicMethed.printAddress(transactionKey); - - Assert.assertTrue(PublicMethed.sendcoin(exchangeAddress, 1500000000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(transactionAddress, 1500000000000000L, fromAddress, - testKey002, blockingStubFull)); - Long totalSupply = 1500000000000000L; - Random rand = new Random(); - Integer randNum = rand.nextInt(900000000) + 1; - String name = "exchange_" + Long.toString(randNum); - Long start = System.currentTimeMillis() + 20000; - Long end = System.currentTimeMillis() + 10000000000L; - String description = "This asset issue is use for exchange transaction stress"; - String url = "This asset issue is use for exchange transaction stress"; - Assert.assertTrue(PublicMethed.createAssetIssue(exchangeAddress, name, totalSupply, 1, 1, - start, end, 1, description, url, 100000000L, 10000000000L, - 10L, 10L, exchangeKey, blockingStubFull)); - try { - Thread.sleep(30000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Assert.assertTrue(PublicMethed.transferAsset(transactionAddress, name.getBytes(), - 1500000000L, exchangeAddress, exchangeKey, blockingStubFull)); - try { - Thread.sleep(30000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //500000000000000L //5000000L - Assert.assertTrue(PublicMethed.exchangeCreate(name.getBytes(), 500000000000000L, - "_".getBytes(), 500000000000000L, exchangeAddress, exchangeKey, blockingStubFull)); - try { - Thread.sleep(300000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - listExchange = PublicMethed.getExchangeList(blockingStubFull); - exchangeId = listExchange.get().getExchangesCount(); - - Integer i = 0; - while (i++ < 10000) { - PublicMethed.exchangeTransaction(exchangeId, "_".getBytes(), 100000, 99, - transactionAddress, transactionKey, blockingStubFull); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - PublicMethed.exchangeTransaction(exchangeId, name.getBytes(), 100000, 1, - transactionAddress, transactionKey, blockingStubFull); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestMapBigLongAndNumbers.java b/src/test/java/stest/tron/wallet/onlinestress/TestMapBigLongAndNumbers.java deleted file mode 100644 index 9727bece9d3..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestMapBigLongAndNumbers.java +++ /dev/null @@ -1,193 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.Random; -//import java.io.FileWriter; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -//import java.io.BufferedWriter; - -import stest.tron.wallet.common.client.utils.PublicMethed; - - -@Slf4j -public class TestMapBigLongAndNumbers { - - //testng001、testng002、testng003、testng004 - //testng001、testng002、testng003、testng004 - private final String testKey002 = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - //private final String testAddress41 = ByteArray.toHexString(fromAddress); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - String kittyCoreAddressAndCut = ""; - byte[] kittyCoreContractAddress = null; - byte[] saleClockAuctionContractAddress = null; - byte[] siringClockAuctionContractAddress = null; - byte[] geneScienceInterfaceContractAddress = null; - //Integer consumeUserResourcePercent = 20; - Integer consumeUserResourcePercent = 100; - String txid = ""; - Optional infoById = null; - - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] triggerAddress = ecKey2.getAddress(); - String triggerKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(triggerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - - } - - @Test(enabled = true, threadPoolSize = 10, invocationCount = 10) - public void deployErc721KittyCore() { - - Long maxFeeLimit = 1000000000L; - - String contractName = "MappingExample"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestMapBigLongAndNumbers_deployErc721KittyCore"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestMapBigLongAndNumbers_deployErc721KittyCore"); - kittyCoreContractAddress = PublicMethed.deployContract(contractName, abi, code, "", - maxFeeLimit, 0L, consumeUserResourcePercent, null, testKey002, - fromAddress, blockingStubFull); - - String data1 = "a"; - String data2 = "b"; - String data3 = "c"; - String data4 = "d"; - - for (int i = 0; i < 13; i++) { - data1 += data1; - } - - for (int i = 0; i < 12; i++) { - data2 += data2; - } - for (int i = 0; i < 11; i++) { - data3 += data3; - } - for (int i = 0; i < 10; i++) { - data4 += data4; - } - String data; - data = data1 + data2 + data3 + data4; - - String data5 = "a"; - - Account account = PublicMethed.queryAccountByAddress(fromAddress, blockingStubFull); - System.out.println(Long.toString(account.getBalance())); - long accountBalance = account.getBalance(); - - Random random = new Random(); - int randNumber = random.nextInt(15) + 15; - - System.out.println("random number:" + randNumber); - - try { - Thread.sleep(randNumber); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - for (int ii = 1; ii < 111100000; ii++) { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] userAddress = ecKey1.getAddress(); - String inputKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - String addresstest = Base58.encode58Check(userAddress); - - String saleContractString = "\"" + data + "\"" + "," + "\"" - + Base58.encode58Check(userAddress) + "\""; - - System.out.println("long string address:" + addresstest); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, "update2(string,address)", - saleContractString, false, 0, 1000000000L, fromAddress, testKey002, blockingStubFull); - logger.info(txid); - - String saleContractString1 = "\"" + data5 + "\"" + "," + "\"" - + Base58.encode58Check(userAddress) + "\""; - - System.out.println("short string address:" + addresstest); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, "update2(string,address)", - saleContractString1, false, 0, 1000000000L, fromAddress, testKey002, blockingStubFull); - logger.info(txid); - - System.out.println("time out"); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, "testUseCpu(uint256)", - "1000000000", false, 0, 1000000000L, fromAddress, testKey002, blockingStubFull); - - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - - infoById.get().getResultValue(); - - String isSuccess; - - if (infoById.get().getResultValue() == 0) { - logger.info("success:" + " Number:" + ii); - isSuccess = "success"; - } else { - logger.info("failed" + " Number:" + ii); - isSuccess = "fail"; - } - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestMutiSignStress.java b/src/test/java/stest/tron/wallet/onlinestress/TestMutiSignStress.java deleted file mode 100644 index 29544c91312..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestMutiSignStress.java +++ /dev/null @@ -1,154 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign; - -@Slf4j -public class TestMutiSignStress { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress = PublicMethed.getFinalAddress(witnessKey001); - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - ByteString assetAccountId1; - String[] ownerKeyString = new String[1]; - String accountPermissionJson = ""; - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, threadPoolSize = 30, invocationCount = 30) - public void testMutiSignForAccount() { - PublicMethed.printAddress(testKey002); - - ECKey ecKey4 = new ECKey(Utils.getRandom()); - byte[] newAddress = ecKey4.getAddress(); - String newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - - ECKey ecKey3 = new ECKey(Utils.getRandom()); - byte[] ownerAddress = ecKey3.getAddress(); - - Assert.assertTrue(PublicMethed.sendcoin(ownerAddress, 9968981537400L, fromAddress, testKey002, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] manager1Address = ecKey1.getAddress(); - String manager1Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - String[] permissionKeyString = new String[3]; - permissionKeyString[0] = manager1Key; - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] manager2Address = ecKey2.getAddress(); - String manager2Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - permissionKeyString[1] = manager2Key; - String ownerKey = ByteArray.toHexString(ecKey3.getPrivKeyBytes()); - permissionKeyString[2] = ownerKey; - String[] ownerKeyString = new String[1]; - ownerKeyString[0] = ownerKey; - - accountPermissionJson = - "{\"owner_permission\":{\"type\":0,\"permission_name\":\"owner\",\"threshold\":3,\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(ownerKey) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}]}," - + "\"active_permissions\":[{\"type\":2,\"permission_name\":\"active0\",\"threshold\":2," - + "\"operations\":\"7fff1fc0033e0000000000000000000000000000000000000000000000000000\"," - + "\"keys\":[" - + "{\"address\":\"" + PublicMethed.getAddressString(manager1Key) + "\",\"weight\":1}," - + "{\"address\":\"" + PublicMethed.getAddressString(manager2Key) + "\",\"weight\":1}" - + "]}]}"; - logger.info(accountPermissionJson); - PublicMethedForMutiSign.accountPermissionUpdate(accountPermissionJson, ownerAddress, ownerKey, - blockingStubFull, ownerKeyString); - - //permissionKeyString[0] = ownerKey; - - String[] ownerKeyString1 = new String[3]; - ownerKeyString1[0] = ownerKey; - ownerKeyString1[1] = manager1Key; - ownerKeyString1[2] = manager2Key; - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Integer i = 0; - while (i++ <= 1000) { - ecKey4 = new ECKey(Utils.getRandom()); - newAddress = ecKey4.getAddress(); - newKey = ByteArray.toHexString(ecKey4.getPrivKeyBytes()); - PublicMethed.printAddress(newKey); - - PublicMethedForMutiSign.sendcoin( - newAddress, 4000000L, ownerAddress, ownerKey, blockingStubFull, ownerKeyString1); - PublicMethedForMutiSign.freezeBalance( - ownerAddress, 1000000L, 0, ownerKey, blockingStubFull, ownerKeyString1); - PublicMethedForMutiSign.freezeBalanceGetEnergy( - ownerAddress, 1000000L, 0, 1, ownerKey, blockingStubFull, ownerKeyString1); - PublicMethedForMutiSign.freezeBalanceForReceiver( - ownerAddress, 1000000L, 0, 0, ByteString.copyFrom(newAddress), - ownerKey, blockingStubFull, ownerKeyString1); - PublicMethedForMutiSign.unFreezeBalance( - ownerAddress, ownerKey, 0, null, blockingStubFull, ownerKeyString1); - PublicMethedForMutiSign.unFreezeBalance( - ownerAddress, ownerKey, 0, newAddress, blockingStubFull, ownerKeyString1); - PublicMethedForMutiSign.updateAccount( - ownerAddress, Long.toString(System.currentTimeMillis()).getBytes(), ownerKey, - blockingStubFull, ownerKeyString1); - } - - - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestNetErc721Cat.java b/src/test/java/stest/tron/wallet/onlinestress/TestNetErc721Cat.java deleted file mode 100644 index d67db26eca0..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestNetErc721Cat.java +++ /dev/null @@ -1,399 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TestNetErc721Cat { - - //testng001、testng002、testng003、testng004 - //testng001、testng002、testng003、testng004 - private final String testKey002 = - //"7306c6044ad7c03709980aa188b8555288b7e0608f5edbf76ff2381c5a7a15a8"; - //"3a54ba30e3ee41b602eca8fb3a3ca1f99f49a3d3ab5d8d646a2ccdd3ffd9c21d"; - //fromAddress - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - - String kittyCoreAddressAndCut = ""; - byte[] kittyCoreContractAddress = null; - byte[] saleClockAuctionContractAddress = null; - byte[] siringClockAuctionContractAddress = null; - byte[] geneScienceInterfaceContractAddress = null; - Integer consumeUserResourcePercent = 20; - String txid = ""; - Optional infoById = null; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] deployAddress = ecKey1.getAddress(); - String deployKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] triggerAddress = ecKey2.getAddress(); - String triggerKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - PublicMethed.printAddress(deployKey); - PublicMethed.printAddress(triggerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - Assert.assertTrue(PublicMethed.sendcoin(deployAddress, 50000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.sendcoin(triggerAddress, 50000000000L, fromAddress, - testKey002, blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(deployAddress, 100000000L, - 3, 1, deployKey, blockingStubFull)); - /* Assert.assertTrue(PublicMethed.freezeBalanceGetCpu(triggerAddress,100000000L, - 3,1,triggerKey,blockingStubFull));*/ - /*Assert.assertTrue(PublicMethed.buyStorage(500000000L,deployAddress,deployKey, - blockingStubFull)); - Assert.assertTrue(PublicMethed.buyStorage(500000000L,triggerAddress,triggerKey, - blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalance(deployAddress,100000000L,3, - deployKey,blockingStubFull)); - Assert.assertTrue(PublicMethed.freezeBalance(triggerAddress,100000000L,3, - triggerKey,blockingStubFull));*/ - - } - - @Test(enabled = false) - public void deployErc721KittyCore() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - //Long storageLimit = accountResource.getStorageLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - //Long storageUsage = accountResource.getStorageUsed(); - Account account = PublicMethed.queryAccount(deployAddress, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - //logger.info("before storage limit is " + Long.toString(storageLimit)); - //logger.info("before storage usaged is " + Long.toString(storageUsage)); - Long maxFeeLimit = 3900000000L; - String contractName = "KittyCore"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestNetErc721Cat_deployErc721KittyCore"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestNetErc721Cat_deployErc721KittyCore"); - logger.info("Kitty Core"); - kittyCoreContractAddress = PublicMethed.deployContract(contractName, abi, code, "", - maxFeeLimit, 0L, consumeUserResourcePercent, null, deployKey, - deployAddress, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(kittyCoreContractAddress, - blockingStubFull); - - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - //storageLimit = accountResource.getStorageLimit(); - cpuUsage = accountResource.getEnergyUsed(); - //storageUsage = accountResource.getStorageUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - //logger.info("after storage limit is " + Long.toString(storageLimit)); - //logger.info("after storage usaged is " + Long.toString(storageUsage)); - logger.info(ByteArray.toHexString(kittyCoreContractAddress)); - logger.info(ByteArray.toHexString(kittyCoreContractAddress).substring(2)); - - kittyCoreAddressAndCut = "000000000000000000000000" + ByteArray - .toHexString(kittyCoreContractAddress).substring(2); - kittyCoreAddressAndCut = kittyCoreAddressAndCut + "0000000000000000000000000000000000000000000" - + "000000000000000000100"; - } - - @Test(enabled = false) - public void deploySaleClockAuction() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - //Long storageLimit = accountResource.getStorageLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - //Long storageUsage = accountResource.getStorageUsed(); - Account account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - //logger.info("before storage limit is " + Long.toString(storageLimit)); - //logger.info("before storage usaged is " + Long.toString(storageUsage)); - Long maxFeeLimit = 3900000000L; - String contractName = "SaleClockAuction"; - logger.info("Sale Clock Auction"); - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestNetErc721Cat_deploySaleClockAuction"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestNetErc721Cat_deploySaleClockAuction"); - saleClockAuctionContractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, 0L, consumeUserResourcePercent, null, deployKey, - deployAddress, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(saleClockAuctionContractAddress, - blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - //storageLimit = accountResource.getStorageLimit(); - cpuUsage = accountResource.getEnergyUsed(); - //storageUsage = accountResource.getStorageUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - //logger.info("after storage limit is " + Long.toString(storageLimit)); - //logger.info("after storage usaged is " + Long.toString(storageUsage)); - } - - @Test(enabled = false) - public void deploySiringClockAuction() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - //Long storageLimit = accountResource.getStorageLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - //Long storageUsage = accountResource.getStorageUsed(); - Account account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - //logger.info("before storage limit is " + Long.toString(storageLimit)); - //logger.info("before storage usaged is " + Long.toString(storageUsage)); - Long maxFeeLimit = 3900000000L; - String contractName = "SiringClockAuction"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestNetErc721Cat_deploySiringClockAuction"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestNetErc721Cat_deploySiringClockAuction"); - logger.info("Siring Clock Auction"); - siringClockAuctionContractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, 0L, consumeUserResourcePercent, null, deployKey, - deployAddress, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(siringClockAuctionContractAddress, - blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - //storageLimit = accountResource.getStorageLimit(); - cpuUsage = accountResource.getEnergyUsed(); - //storageUsage = accountResource.getStorageUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - //logger.info("after storage limit is " + Long.toString(storageLimit)); - //logger.info("after storage usaged is " + Long.toString(storageUsage)); - } - - @Test(enabled = false) - public void deployGeneScienceInterface() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(deployAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - //Long storageLimit = accountResource.getStorageLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - //Long storageUsage = accountResource.getStorageUsed(); - Account account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - //logger.info("before storage limit is " + Long.toString(storageLimit)); - //logger.info("before storage usaged is " + Long.toString(storageUsage)); - Long maxFeeLimit = 3900000000L; - String contractName = "GeneScienceInterface"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestNetErc721Cat_deployGeneScienceInterface"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestNetErc721Cat_deployGeneScienceInterface"); - logger.info("gene Science Interface"); - geneScienceInterfaceContractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, consumeUserResourcePercent, null, deployKey, deployAddress, blockingStubFull); - SmartContract smartContract = PublicMethed.getContract(geneScienceInterfaceContractAddress, - blockingStubFull); - Assert.assertTrue(smartContract.getAbi() != null); - accountResource = PublicMethed.getAccountResource(deployAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - //storageLimit = accountResource.getStorageLimit(); - cpuUsage = accountResource.getEnergyUsed(); - //storageUsage = accountResource.getStorageUsed(); - account = PublicMethed.queryAccount(deployKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - //logger.info("after storage limit is " + Long.toString(storageLimit)); - //logger.info("after storage usaged is " + Long.toString(storageUsage)); - } - - @Test(enabled = false) - public void triggerToSetThreeContractAddressToKittyCore() { - //Set SaleAuctionAddress to kitty core. - String saleContractString = "\"" + Base58.encode58Check(saleClockAuctionContractAddress) + "\""; - txid = PublicMethed.triggerContract(kittyCoreContractAddress, "setSaleAuctionAddress(address)", - saleContractString, false, 0, 10000000L, deployAddress, deployKey, blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - //Assert.assertTrue(infoById.get().getReceipt().getStorageDelta() > 50); - - //Set SiringAuctionAddress to kitty core. - String siringContractString = "\"" + Base58.encode58Check(siringClockAuctionContractAddress) - + "\""; - txid = PublicMethed - .triggerContract(kittyCoreContractAddress, "setSiringAuctionAddress(address)", - siringContractString, false, 0, 10000000L, - deployAddress, deployKey, blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - //Assert.assertTrue(infoById.get().getReceipt().getStorageDelta() > 50); - - //Set gen contract to kitty core - String genContractString = "\"" + Base58.encode58Check(geneScienceInterfaceContractAddress) - + "\""; - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setGeneScienceAddress(address)", genContractString, - false, 0, 10000000L, deployAddress, deployKey, blockingStubFull); - logger.info(txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - //Assert.assertTrue(infoById.get().getReceipt().getStorageDelta() > 50); - - //Start the game. - txid = PublicMethed.triggerContract(kittyCoreContractAddress, "unpause()", "", false, 0, - 10000000L, deployAddress, deployKey, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - logger.info("start the game " + txid); - - //Create one gen0 cat. - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "createGen0Auction(uint256)", "-1000000000000000", false, - 0, 100000000L, deployAddress, deployKey, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "gen0CreatedCount()", "#", false, - 0, 100000000L, deployAddress, deployKey, blockingStubFull); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - /* txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "name()","#",false,0,10000000,triggerAddress, - triggerKey,blockingStubFull); - logger.info("getname " + txid);*/ - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "getKitty(uint256)", "1", false, 0, 10000000, triggerAddress, - triggerKey, blockingStubFull); - logger.info("getKitty " + txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - String newCxoAddress = "\"" + Base58.encode58Check(triggerAddress) - + "\""; - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCOO(address)", newCxoAddress, false, 0, 10000000, deployAddress, - deployKey, blockingStubFull); - logger.info("COO " + txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCFO(address)", newCxoAddress, false, 0, 10000000, deployAddress, - deployKey, blockingStubFull); - logger.info("CFO " + txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "setCEO(address)", newCxoAddress, false, 0, 1000000, deployAddress, - deployKey, blockingStubFull); - logger.info("CEO " + txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0); - } - - @Test(enabled = false, threadPoolSize = 1, invocationCount = 1) - public void unCreateKitty() { - Integer times = 0; - logger.info("In create kitty, kitty core address is " + ByteArray - .toHexString(kittyCoreContractAddress)); - while (times++ < 20) { - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "createGen0Auction(uint256)", "0", false, - 0, 100000000L, triggerAddress, triggerKey, blockingStubFull); - logger.info("createGen0 " + txid); - infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull); - //Assert.assertTrue(infoById.get().getResultValue() == 0); - /* String promoKitty = "\"" + times.toString() + "\",\"" - + Base58.encode58Check(kittyCoreContractAddress) + "\""; - logger.info(promoKitty); - txid = PublicMethed.triggerContract(kittyCoreContractAddress, - "createPromoKitty(uint256,address)", promoKitty,false, - 0,10000000L,triggerAddress,triggerKey,blockingStubFull); - logger.info("createPromoKitty " + txid); - infoById = PublicMethed.getTransactionInfoById(txid,blockingStubFull); - Assert.assertTrue(infoById.get().getResultValue() == 0);*/ - try { - Thread.sleep(10); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestNetFomo3D.java b/src/test/java/stest/tron/wallet/onlinestress/TestNetFomo3D.java deleted file mode 100644 index 6a336870cb6..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestNetFomo3D.java +++ /dev/null @@ -1,213 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import static stest.tron.wallet.common.client.utils.PublicMethed.getTransactionInfoById; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.AccountResourceMessage; -import org.tron.api.WalletGrpc; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TestNetFomo3D { - - //testng001、testng002、testng003、testng004 - private final String testNetAccountKey = - "FC8BF0238748587B9617EB6D15D47A66C0E07C1A1959033CF249C6532DC29FE6"; - //"BC70ADC5A0971BA3F7871FBB7249E345D84CE7E5458828BE1E28BF8F98F2795B"; - private final byte[] testNetAccountAddress = PublicMethed.getFinalAddress(testNetAccountKey); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - Optional infoById = null; - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = false) - public void beforeClass() { - PublicMethed.printAddress(testNetAccountKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - logger.info(Long.toString(PublicMethed.queryAccount(testNetAccountKey, blockingStubFull) - .getBalance())); - //Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(testNetAccountAddress,10000000L, - //3,1,testNetAccountKey,blockingStubFull)); - /* Assert.assertTrue(PublicMethed.buyStorage(50000000L,testNetAccountAddress, - testNetAccountKey, - blockingStubFull));*/ - - } - - @Test(enabled = false) - public void deployErc721CryptoKitties() { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(testNetAccountAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - //Long storageLimit = accountResource.getStorageLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - //Long storageUsage = accountResource.getStorageUsed(); - Account account = PublicMethed.queryAccount(testNetAccountKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - //logger.info("before storage limit is " + Long.toString(storageLimit)); - //logger.info("before storage usaged is " + Long.toString(storageUsage)); - Long maxFeeLimit = 3900000000L; - String contractName = "Fomo3D"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestNetFomo3D_deployErc721CryptoKitties"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestNetFomo3D_deployErc721CryptoKitties"); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, testNetAccountKey, testNetAccountAddress, blockingStubFull); - - String code1 = Configuration.getByPath("testng.conf") - .getString("code.code1_TestNetFomo3D_deployErc721CryptoKitties"); - String abi1 = Configuration.getByPath("testng.conf") - .getString("abi.abi1_TestNetFomo3D_deployErc721CryptoKitties"); - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi1, - code1, "", maxFeeLimit, 0L, 100, null, - testNetAccountKey, testNetAccountAddress, blockingStubFull); - - final SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - accountResource = PublicMethed.getAccountResource(testNetAccountAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - //storageLimit = accountResource.getStorageLimit(); - cpuUsage = accountResource.getEnergyUsed(); - //storageUsage = accountResource.getStorageUsed(); - account = PublicMethed.queryAccount(testNetAccountKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - //logger.info("after storage limit is " + Long.toString(storageLimit)); - //logger.info("after storage usaged is " + Long.toString(storageUsage)); - //Assert.assertTrue(storageUsage > 0); - //Assert.assertTrue(storageLimit > 0); - Assert.assertTrue(cpuLimit > 0); - Assert.assertTrue(cpuUsage > 0); - - Assert.assertFalse(smartContract.getAbi().toString().isEmpty()); - Assert.assertTrue(smartContract.getName().equalsIgnoreCase(contractName)); - Assert.assertFalse(smartContract.getBytecode().toString().isEmpty()); - //logger.info(smartContract.getName()); - //logger.info(smartContract.getAbi().toString()); - - } - - @Test(enabled = false) - public void tooLargeStorage() throws IOException { - AccountResourceMessage accountResource = PublicMethed.getAccountResource(testNetAccountAddress, - blockingStubFull); - Long cpuLimit = accountResource.getEnergyLimit(); - Long cpuUsage = accountResource.getEnergyUsed(); - Account account = PublicMethed.queryAccount(testNetAccountKey, blockingStubFull); - logger.info("before balance is " + Long.toString(account.getBalance())); - logger.info("before cpu limit is " + Long.toString(cpuLimit)); - logger.info("before cpu usage is " + Long.toString(cpuUsage)); - Long maxFeeLimit = 100000000000000000L; - String contractName = "tooLargeStorage"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestNetFomo3D_tooLargeStorage"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestNetFomo3D_tooLargeStorage"); - String txid = PublicMethed.deployContractAndGetTransactionInfoById(contractName, abi, - code, "", maxFeeLimit, 0L, 100, null, - testNetAccountKey, testNetAccountAddress, blockingStubFull); - infoById = getTransactionInfoById(txid, blockingStubFull); - accountResource = PublicMethed.getAccountResource(testNetAccountAddress, blockingStubFull); - cpuLimit = accountResource.getEnergyLimit(); - //storageLimit = accountResource.getStorageLimit(); - cpuUsage = accountResource.getEnergyUsed(); - //storageUsage = accountResource.getStorageUsed(); - account = PublicMethed.queryAccount(testNetAccountKey, blockingStubFull); - logger.info("after balance is " + Long.toString(account.getBalance())); - logger.info("after cpu limit is " + Long.toString(cpuLimit)); - logger.info("after cpu usage is " + Long.toString(cpuUsage)); - - /* String name = readFromXieChang();*/ - String stringTimes = Integer.toString(7); - byte[] contractAddress = infoById.get().getContractAddress().toByteArray(); - txid = PublicMethed.triggerContract(contractAddress, "slice(uint256)", stringTimes, false, - 0, maxFeeLimit, testNetAccountAddress, testNetAccountKey, blockingStubFull); - logger.info("slice " + txid); - logger.info(Integer.toString(infoById.get().getResultValue())); - infoById = getTransactionInfoById(txid, blockingStubFull); - - txid = PublicMethed.triggerContract(contractAddress, "s()", "#", false, - 0, maxFeeLimit, testNetAccountAddress, testNetAccountKey, blockingStubFull); - logger.info(txid); - logger.info(Integer.toString(infoById.get().getResultValue())); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public String readFromXieChang() throws IOException { - File file = new File( - "/Users/wangzihe/Desktop/ddd.txt"); - FileReader reader = null; - try { - reader = new FileReader(file); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - BufferedReader reAder = new BufferedReader(reader); - StringBuilder sb = new StringBuilder(); - String s = ""; - while ((s = reAder.readLine()) != null) { - sb.append(s); - } - - String code = sb.toString(); - reAder.close(); - return code; - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestStorageAndCpu.java b/src/test/java/stest/tron/wallet/onlinestress/TestStorageAndCpu.java deleted file mode 100644 index 90e0b9612e7..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestStorageAndCpu.java +++ /dev/null @@ -1,206 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.WalletGrpc; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.ChainParameters; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TestStorageAndCpu { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("witness.key5"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("witness.key4"); - private final byte[] testAddress003 = PublicMethed.getFinalAddress(testKey003); - - private final String testKey004 = Configuration.getByPath("testng.conf") - .getString("witness.key3"); - private final byte[] testAddress004 = PublicMethed.getFinalAddress(testKey004); - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - ArrayList txidList = new ArrayList(); - - Optional infoById = null; - Long beforeTime; - Long afterTime; - Long beforeBlockNum; - Long afterBlockNum; - Block currentBlock; - Long currentBlockNum; - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(testKey002); - PublicMethed.printAddress(testKey003); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - currentBlock = blockingStubFull1.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - beforeTime = System.currentTimeMillis(); - } - - @Test(enabled = true, threadPoolSize = 1, invocationCount = 1) - public void storageAndCpu() { - Random rand = new Random(); - Integer randNum = rand.nextInt(30) + 1; - randNum = rand.nextInt(4000); - - Long maxFeeLimit = 1000000000L; - String contractName = "StorageAndCpu" + Integer.toString(randNum); - String code = Configuration.getByPath("testng.conf") - .getString("code.code_TestStorageAndCpu_storageAndCpu"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_TestStorageAndCpu_storageAndCpu"); - PublicMethed - .freezeBalanceGetEnergy(fromAddress, 1000000000000L, 3, 1, testKey002, blockingStubFull); - byte[] contractAddress = PublicMethed.deployContract(contractName, abi, code, - "", maxFeeLimit, - 0L, 100, null, testKey002, fromAddress, blockingStubFull); - try { - Thread.sleep(30000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - SmartContract smartContract = PublicMethed.getContract(contractAddress, blockingStubFull); - String txid; - - ChainParameters chainParameters = blockingStubFull - .getChainParameters(EmptyMessage.newBuilder().build()); - Optional getChainParameters = Optional.ofNullable(chainParameters); - - Integer i = 1; - while (i++ < 8000) { - String initParmes = "\"" + "930" + "\""; - txid = PublicMethed.triggerContract(contractAddress, - "testUseCpu(uint256)", "9100", false, - 0, maxFeeLimit, fromAddress, testKey002, blockingStubFull); - txid = PublicMethed.triggerContract(contractAddress, - "storage8Char()", "", false, - 0, maxFeeLimit, fromAddress, testKey002, blockingStubFull); - //storage 9 EnergyUsageTotal is 211533, 10 is 236674, 5 is 110969,21 is 500000 - txid = PublicMethed.triggerContract(contractAddress, - "testUseStorage(uint256)", "21", false, - 0, maxFeeLimit, fromAddress, testKey002, blockingStubFull); - //logger.info("i is " +Integer.toString(i) + " " + txid); - //txidList.add(txid); - try { - Thread.sleep(50); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (i % 10 == 0) { - chainParameters = blockingStubFull - .getChainParameters(EmptyMessage.newBuilder().build()); - getChainParameters = Optional.ofNullable(chainParameters); - logger.info(getChainParameters.get().getChainParameter(22).getKey()); - logger.info(Long.toString(getChainParameters.get().getChainParameter(22).getValue())); - logger.info(getChainParameters.get().getChainParameter(23).getKey()); - logger.info(Long.toString(getChainParameters.get().getChainParameter(23).getValue())); - - } - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - /* - afterTime = System.currentTimeMillis(); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - currentBlock = blockingStubFull1.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock.getBlockHeader().getRawData().getNumber() + 2; - Long blockNum = beforeBlockNum; - Integer txsNum = 0; - Integer topNum = 0; - Integer totalNum = 0; - Long energyTotal = 0L; - String findOneTxid = ""; - - NumberMessage.Builder builder = NumberMessage.newBuilder(); - while (blockNum <= afterBlockNum) { - builder.setNum(blockNum); - txsNum = blockingStubFull1.getBlockByNum(builder.build()).getTransactionsCount(); - totalNum = totalNum + txsNum; - if (topNum < txsNum) { - topNum = txsNum; - findOneTxid = ByteArray.toHexString(Sha256Hash.hash(blockingStubFull1 - .getBlockByNum(builder.build()).getTransactionsList().get(2) - .getRawData().toByteArray())); - //logger.info("find one txid is " + findOneTxid); - } - - blockNum++; - } - Long costTime = (afterTime - beforeTime - 31000) / 1000; - logger.info("Duration block num is " + (afterBlockNum - beforeBlockNum - 11)); - logger.info("Cost time are " + costTime); - logger.info("Top block txs num is " + topNum); - logger.info("Total transaction is " + (totalNum - 30)); - logger.info("Average Tps is " + (totalNum / costTime)); - - infoById = PublicMethed.getTransactionInfoById(findOneTxid, blockingStubFull1); - Long oneEnergyTotal = infoById.get().getReceipt().getEnergyUsageTotal(); - logger.info("EnergyTotal is " + oneEnergyTotal); - logger.info("Average energy is " + oneEnergyTotal * (totalNum / costTime)); -*/ - - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/onlinestress/TestTransferTokenInContract.java b/src/test/java/stest/tron/wallet/onlinestress/TestTransferTokenInContract.java deleted file mode 100644 index 28cbd8afa9b..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/TestTransferTokenInContract.java +++ /dev/null @@ -1,332 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.AssetIssueList; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class TestTransferTokenInContract { - - private AtomicLong count = new AtomicLong(); - private AtomicLong errorCount = new AtomicLong(); - private long startTime = System.currentTimeMillis(); - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - - private static final long TotalSupply = 1000000L; - - String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { - - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - } - - private static int randomInt(int minInt, int maxInt) { - return (int) Math.round(Math.random() * (maxInt - minInt) + minInt); - } - - /** - * constructor. - */ - - public ByteString createAssetissue(byte[] devAddress, String devKey, String tokenName) { - - ByteString assetAccountId = null; - ByteString addressBS1 = ByteString.copyFrom(devAddress); - Account request1 = Account.newBuilder().setAddress(addressBS1).build(); - GrpcAPI.AssetIssueList assetIssueList1 = blockingStubFull - .getAssetIssueByAccount(request1); - Optional queryAssetByAccount = Optional.ofNullable(assetIssueList1); - if (queryAssetByAccount.get().getAssetIssueCount() == 0) { - Long start = System.currentTimeMillis() + 2000; - Long end = System.currentTimeMillis() + 1000000000; - - logger.info("The token name: " + tokenName); - - //Create a new AssetIssue success. - Assert.assertTrue(PublicMethed.createAssetIssue(devAddress, tokenName, TotalSupply, 1, - 100, start, end, 1, description, url, 10000L, 10000L, - 1L, 1L, devKey, blockingStubFull)); - - Account getAssetIdFromThisAccount = PublicMethed.queryAccount(devAddress, blockingStubFull); - assetAccountId = getAssetIdFromThisAccount.getAssetIssuedID(); - } else { - logger.info("This account already create an assetisue"); - Optional queryAssetByAccount1 = Optional.ofNullable(assetIssueList1); - tokenName = ByteArray.toStr(queryAssetByAccount1.get().getAssetIssue(0) - .getName().toByteArray()); - } - return assetAccountId; - } - - @Test(enabled = true, threadPoolSize = 2, invocationCount = 2) - public void continueRun() { - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] dev001Address = ecKey1.getAddress(); - String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] user001Address = ecKey2.getAddress(); - String user001Key = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Assert - .assertTrue(PublicMethed.sendcoin(dev001Address, 2048000000, fromAddress, - testKey002, blockingStubFull)); - Assert - .assertTrue(PublicMethed.sendcoin(user001Address, 4048000000L, fromAddress, - testKey002, blockingStubFull)); - - // freeze balance - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(dev001Address, 204800000, - 0, 1, dev001Key, blockingStubFull)); - - Assert.assertTrue(PublicMethed.freezeBalanceGetEnergy(user001Address, 2048000000, - 0, 1, user001Key, blockingStubFull)); - - String tokenName = "testAI_" + randomInt(10000, 90000); - ByteString tokenId = createAssetissue(user001Address, user001Key, tokenName); - - // devAddress transfer token to A - PublicMethed.transferAsset(dev001Address, tokenId.toByteArray(), 101, user001Address, - user001Key, blockingStubFull); - - // deploy transferTokenContract - String contractName = "transferTokenContract"; - String code = "608060405260e2806100126000396000f300608060405260043610603e5763ffffffff7c01000000" - + "000000000000000000000000000000000000000000000000006000350416633be9ece781146043575b600080" - + "fd5b606873ffffffffffffffffffffffffffffffffffffffff60043516602435604435606a565b005b604051" - + "73ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083908590600081818185878a8a" - + "d094505050505015801560b0573d6000803e3d6000fd5b505050505600a165627a7a723058200ba246bdb58b" - + "e0f221ad07e1b19de843ab541150b329ddd01558c2f1cefe1e270029"; - String abi = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}," - + "{\"name\":\"id\",\"type\":\"trcToken\"},{\"name\":\"amount\",\"type\":\"uint256\"}]," - + "\"name\":\"TransferTokenTo\",\"outputs\":[],\"payable\":true,\"stateMutability\":" - + "\"payable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true,\"stateMutability\"" - + ":\"payable\",\"type\":\"constructor\"}]"; - byte[] transferTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, 10000, tokenId.toStringUtf8(), - 100, null, dev001Key, dev001Address, - blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // deploy receiveTokenContract - contractName = "recieveTokenContract"; - code = "60806040526000805560c5806100166000396000f30060806040526004361060485763ffffffff7c0100000" - + "00000000000000000000000000000000000000000000000000060003504166362548c7b8114604a578063890" - + "eba68146050575b005b6048608c565b348015605b57600080fd5b50d38015606757600080fd5b50d28015607" - + "357600080fd5b50607a6093565b60408051918252519081900360200190f35b6001600055565b60005481560" - + "0a165627a7a723058204c4f1bb8eca0c4f1678cc7cc1179e03d99da2a980e6792feebe4d55c89c022830029"; - abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"setFlag\",\"outputs\":[],\"payable\":true," - + "\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[]," - + "\"name\":\"flag\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false," - + "\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true," - + "\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"payable\":true," - + "\"stateMutability\":\"payable\",\"type\":\"fallback\"}]"; - byte[] receiveTokenContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, dev001Key, dev001Address, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - // deploy tokenBalanceContract - contractName = "tokenBalanceContract"; - code = "608060405260ff806100126000396000f30060806040526004361060485763ffffffff7c010000000000000" - + "0000000000000000000000000000000000000000000600035041663a730416e8114604d578063b69ef8a8146" - + "081575b600080fd5b606f73ffffffffffffffffffffffffffffffffffffffff6004351660243560ab565b604" - + "08051918252519081900360200190f35b348015608c57600080fd5b50d38015609857600080fd5b50d280156" - + "0a457600080fd5b50606f60cd565b73ffffffffffffffffffffffffffffffffffffffff90911690d16000908" - + "15590565b600054815600a165627a7a723058202b6235122df66c062c2e723ad58a9fea93346f3bc19898971" - + "8f211aa1dbd2d7a0029"; - abi = "[{\"constant\":false,\"inputs\":[{\"name\":\"toAddress\",\"type\":\"address\"}," - + "{\"name\":\"tokenId\",\"type\":\"trcToken\"}],\"name\":\"getTokenBalnce\",\"outputs\":" - + "[{\"name\":\"b\",\"type\":\"uint256\"}],\"payable\":true,\"stateMutability\":" - + "\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":" - + "\"balance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false," - + "\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":true," - + "\"stateMutability\":\"payable\",\"type\":\"constructor\"}]"; - byte[] tokenBalanceContractAddress = PublicMethed - .deployContract(contractName, abi, code, "", maxFeeLimit, - 0L, 100, null, dev001Key, dev001Address, blockingStubFull); - - // devAddress transfer token to userAddress - PublicMethed.transferAsset(user001Address, tokenId.toByteArray(), 100, dev001Address, dev001Key, - blockingStubFull); - - PublicMethed.waitProduceNextBlock(blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull1); - - for (int i = 0; i < 1000000000000L; i++) { - logger.info("** This is " + i + "times --------------------------------------------"); - count.getAndAdd(4); - if (count.get() % 500 == 0) { - long cost = (System.currentTimeMillis() - startTime) / 1000; - logger.info("Count:" + count.get() + ", cost:" + cost - + ", avg:" + count.get() / cost + ", errCount:" + errorCount); - } - PublicMethed.freezeBalanceForReceiver(user001Address, - PublicMethed.getFreezeBalanceCount(user001Address, - user001Key, 300000L, blockingStubFull), 0, - 1, ByteString.copyFrom(fromAddress), testKey002, blockingStubFull); - PublicMethed.freezeBalanceForReceiver(user001Address, 10_000_000L, - 0, 0, ByteString.copyFrom(fromAddress), testKey002, blockingStubFull); - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - // user trigger A to transfer token to B - String param = - "\"" + Base58.encode58Check(receiveTokenContractAddress) + "\",\"" + tokenId - .toStringUtf8() - + "\",\"5\""; - - String triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 100000000L, tokenId.toStringUtf8(), - 10, user001Address, user001Key, - blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - errorCount.incrementAndGet(); - } - - // user trigger A to transfer token to devAddress - param = - "\"" + Base58.encode58Check(dev001Address) + "\",\"" + tokenId.toStringUtf8() - + "\",\"5\""; - - triggerTxid = PublicMethed.triggerContract(transferTokenContractAddress, - "TransferTokenTo(address,trcToken,uint256)", - param, false, 0, 100000000L, user001Address, - user001Key, blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - errorCount.incrementAndGet(); - } - - // user trigger C to get B's token balance - param = - "\"" + Base58.encode58Check(receiveTokenContractAddress) + "\",\"" + tokenId - .toStringUtf8() - + "\""; - - triggerTxid = PublicMethed - .triggerContract(tokenBalanceContractAddress, "getTokenBalnce(address,trcToken)", - param, false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - errorCount.incrementAndGet(); - } - - PublicMethed.triggerContract(tokenBalanceContractAddress, "balance()", - "#", false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - - // user trigger C to get devAddress's token balance - param = "\"" + Base58.encode58Check(dev001Address) + "\",\"" + tokenId.toStringUtf8() + "\""; - - triggerTxid = PublicMethed - .triggerContract(tokenBalanceContractAddress, "getTokenBalnce(address,trcToken)", - param, false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - - infoById = PublicMethed - .getTransactionInfoById(triggerTxid, blockingStubFull); - - if (infoById.get().getResultValue() != 0) { - errorCount.incrementAndGet(); - } - - PublicMethed.triggerContract(tokenBalanceContractAddress, "balance()", - "#", false, 0, 1000000000L, user001Address, - user001Key, blockingStubFull); - - PublicMethed.unFreezeBalance(fromAddress, user001Key, 1, - user001Address, blockingStubFull); - PublicMethed.unFreezeBalance(fromAddress, user001Key, 0, - user001Address, blockingStubFull); - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} - - diff --git a/src/test/java/stest/tron/wallet/onlinestress/WalletTestZenTokenStress.java b/src/test/java/stest/tron/wallet/onlinestress/WalletTestZenTokenStress.java deleted file mode 100644 index e16d2383b56..00000000000 --- a/src/test/java/stest/tron/wallet/onlinestress/WalletTestZenTokenStress.java +++ /dev/null @@ -1,280 +0,0 @@ -package stest.tron.wallet.onlinestress; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.DecryptNotes; -import org.tron.api.GrpcAPI.DiversifierMessage; -import org.tron.api.GrpcAPI.EmptyMessage; -import org.tron.api.GrpcAPI.ExpandedSpendingKeyMessage; -import org.tron.api.GrpcAPI.IncomingViewingKeyDiversifierMessage; -import org.tron.api.GrpcAPI.IncomingViewingKeyMessage; -import org.tron.api.GrpcAPI.Note; -import org.tron.api.GrpcAPI.PaymentAddressMessage; -import org.tron.api.GrpcAPI.ViewingKeyMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.core.config.args.Args; -import org.tron.core.zen.address.DiversifierT; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.ShieldAddressInfo; - - -@Slf4j -public class WalletTestZenTokenStress { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - Optional sendShieldAddressInfo; - Optional receiverShieldAddressInfo; - String sendShieldAddress; - String receiverShieldAddress; - List shieldOutList = new ArrayList<>(); - DecryptNotes notes; - String memo; - Note sendNote; - Note receiverNote; - private static ByteString assetAccountId = null; - - BytesMessage ak; - BytesMessage nk; - BytesMessage sk; - ExpandedSpendingKeyMessage expandedSpendingKeyMessage; - DiversifierMessage diversifierMessage1; - DiversifierMessage diversifierMessage2; - DiversifierMessage diversifierMessage3; - IncomingViewingKeyMessage ivk; - ShieldAddressInfo addressInfo1 = new ShieldAddressInfo(); - ShieldAddressInfo addressInfo2 = new ShieldAddressInfo(); - ShieldAddressInfo addressInfo3 = new ShieldAddressInfo(); - - Optional receiverAddressInfo1; - Optional receiverAddressInfo2; - Optional receiverAddressInfo3; - - - - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private ManagedChannel channelSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private ManagedChannel channelSolidity1 = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity1 = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - private String soliditynode1 = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1); - private String foundationZenTokenKey = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenOwnerKey"); - byte[] foundationZenTokenAddress = PublicMethed.getFinalAddress(foundationZenTokenKey); - private String zenTokenId = Configuration.getByPath("testng.conf") - .getString("defaultParameter.zenTokenId"); - private byte[] tokenId = zenTokenId.getBytes(); - private Long zenTokenFee = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.zenTokenFee"); - private Long costTokenAmount = 1 * zenTokenFee + 1; - private Long sendTokenAmount = 1 * zenTokenFee; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - /** - * constructor. - */ - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - @BeforeClass(enabled = true) - public void beforeClass() { - PublicMethed.printAddress(foundationZenTokenKey); - PublicMethed.printAddress(zenTokenOwnerKey); - channelFull = ManagedChannelBuilder.forTarget(fullnode).usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - channelSolidity1 = ManagedChannelBuilder.forTarget(soliditynode1) - .usePlaintext(true) - .build(); - blockingStubSolidity1 = WalletSolidityGrpc.newBlockingStub(channelSolidity1); - - Assert.assertTrue(PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - costTokenAmount, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - Args.getInstance().setFullNodeAllowShieldedTransaction(true); - - - } - - @Test(enabled = true, threadPoolSize = 3, invocationCount = 3) - public void test1Shield2ShieldTransaction() throws InterruptedException { - List shieldOutList = new ArrayList<>(); - Integer times = 0; - Optional sendShieldAddressInfo = PublicMethed.generateShieldAddress(); - String sendShieldAddress = sendShieldAddressInfo.get().getAddress(); - String memo = "7"; - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + zenTokenFee, memo); - while (times++ < 10000) { - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] zenTokenOwnerAddress = ecKey1.getAddress(); - - PublicMethed.transferAsset(zenTokenOwnerAddress, tokenId, - zenTokenFee * 2, foundationZenTokenAddress, foundationZenTokenKey, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - memo = times + ":shield note number"; - shieldOutList.clear(); - shieldOutList = PublicMethed.addShieldOutputList(shieldOutList, sendShieldAddress, - "" + zenTokenFee, memo); - String zenTokenOwnerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - PublicMethed.sendShieldCoin(zenTokenOwnerAddress, 2 * zenTokenFee, null, - null, shieldOutList, null, 0, zenTokenOwnerKey, blockingStubFull); - /* logger.info("Note number:" - + PublicMethed.getShieldNotesCount(sendShieldAddressInfo,blockingStubFull));*/ - } - - - } - - @Test(enabled = true, threadPoolSize = 30, invocationCount = 30) - public void test2Shield2ShieldTransaction() throws InterruptedException { - BytesMessage ak; - BytesMessage nk; - BytesMessage sk; - ExpandedSpendingKeyMessage expandedSpendingKeyMessage; - DiversifierMessage diversifierMessage1; - DiversifierMessage diversifierMessage2; - DiversifierMessage diversifierMessage3; - IncomingViewingKeyMessage ivk; - ShieldAddressInfo addressInfo1 = new ShieldAddressInfo(); - ShieldAddressInfo addressInfo2 = new ShieldAddressInfo(); - ShieldAddressInfo addressInfo3 = new ShieldAddressInfo(); - - Optional receiverAddressInfo1; - Optional receiverAddressInfo2; - Optional receiverAddressInfo3; - - Integer times = 0; - while (times++ < 10000) { - sk = blockingStubFull.getSpendingKey(EmptyMessage.newBuilder().build()); - //logger.info("sk: " + ByteArray.toHexString(sk.getValue().toByteArray())); - - diversifierMessage1 = blockingStubFull.getDiversifier(EmptyMessage.newBuilder().build()); - //logger.info("d1: " + ByteArray.toHexString(diversifierMessage1.getD().toByteArray())); - diversifierMessage2 = blockingStubFull.getDiversifier(EmptyMessage.newBuilder().build()); - //logger.info("d2: " + ByteArray.toHexString(diversifierMessage2.getD().toByteArray())); - diversifierMessage3 = blockingStubFull.getDiversifier(EmptyMessage.newBuilder().build()); - //logger.info("d3: " + ByteArray.toHexString(diversifierMessage3.getD().toByteArray())); - - expandedSpendingKeyMessage = blockingStubFull.getExpandedSpendingKey(sk); - - BytesMessage.Builder askBuilder = BytesMessage.newBuilder(); - askBuilder.setValue(expandedSpendingKeyMessage.getAsk()); - ak = blockingStubFull.getAkFromAsk(askBuilder.build()); - //logger.info("ak: " + ByteArray.toHexString(ak.getValue().toByteArray())); - - BytesMessage.Builder nskBuilder = BytesMessage.newBuilder(); - nskBuilder.setValue(expandedSpendingKeyMessage.getNsk()); - nk = blockingStubFull.getNkFromNsk(nskBuilder.build()); - //logger.info("nk: " + ByteArray.toHexString(nk.getValue().toByteArray())); - - ViewingKeyMessage.Builder viewBuilder = ViewingKeyMessage.newBuilder(); - viewBuilder.setAk(ak.getValue()); - viewBuilder.setNk(nk.getValue()); - ivk = blockingStubFull.getIncomingViewingKey(viewBuilder.build()); - //logger.info("ivk: " + ByteArray.toHexString(ivk.getIvk().toByteArray())); - - IncomingViewingKeyDiversifierMessage.Builder builder = - IncomingViewingKeyDiversifierMessage.newBuilder(); - builder.setD(diversifierMessage1); - builder.setIvk(ivk); - PaymentAddressMessage addressMessage = blockingStubFull.getZenPaymentAddress(builder.build()); - //System.out.println("address1: " + addressMessage.getPaymentAddress()); - addressInfo1.setSk(sk.getValue().toByteArray()); - addressInfo1.setD(new DiversifierT(diversifierMessage1.getD().toByteArray())); - addressInfo1.setIvk(ivk.getIvk().toByteArray()); - addressInfo1.setOvk(expandedSpendingKeyMessage.getOvk().toByteArray()); - addressInfo1.setPkD(addressMessage.getPkD().toByteArray()); - receiverAddressInfo1 = Optional.of(addressInfo1); - - builder.clear(); - builder = IncomingViewingKeyDiversifierMessage.newBuilder(); - builder.setD(diversifierMessage2); - builder.setIvk(ivk); - addressMessage = blockingStubFull.getZenPaymentAddress(builder.build()); - //System.out.println("address2: " + addressMessage.getPaymentAddress()); - addressInfo2.setSk(sk.getValue().toByteArray()); - addressInfo2.setD(new DiversifierT(diversifierMessage2.getD().toByteArray())); - addressInfo2.setIvk(ivk.getIvk().toByteArray()); - addressInfo2.setOvk(expandedSpendingKeyMessage.getOvk().toByteArray()); - addressInfo2.setPkD(addressMessage.getPkD().toByteArray()); - receiverAddressInfo2 = Optional.of(addressInfo2); - - builder.clear(); - builder = IncomingViewingKeyDiversifierMessage.newBuilder(); - builder.setD(diversifierMessage3); - builder.setIvk(ivk); - addressMessage = blockingStubFull.getZenPaymentAddress(builder.build()); - //System.out.println("address3: " + addressMessage.getPaymentAddress()); - addressInfo3.setSk(sk.getValue().toByteArray()); - addressInfo3.setD(new DiversifierT(diversifierMessage3.getD().toByteArray())); - addressInfo3.setIvk(ivk.getIvk().toByteArray()); - addressInfo3.setOvk(expandedSpendingKeyMessage.getOvk().toByteArray()); - addressInfo3.setPkD(addressMessage.getPkD().toByteArray()); - receiverAddressInfo3 = Optional.of(addressInfo3); - } - - } - - /** - * constructor. - */ - @AfterClass(enabled = true) - public void shutdown() throws InterruptedException { - PublicMethed.transferAsset(foundationZenTokenAddress, tokenId, - PublicMethed.getAssetIssueValue(zenTokenOwnerAddress, - PublicMethed.queryAccount(foundationZenTokenKey, blockingStubFull).getAssetIssuedID(), - blockingStubFull), zenTokenOwnerAddress, zenTokenOwnerKey, blockingStubFull); - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity1 != null) { - channelSolidity1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } -} \ No newline at end of file diff --git a/src/test/java/stest/tron/wallet/other/deployMainGateway.java b/src/test/java/stest/tron/wallet/other/deployMainGateway.java deleted file mode 100644 index 23ddc4bce68..00000000000 --- a/src/test/java/stest/tron/wallet/other/deployMainGateway.java +++ /dev/null @@ -1,138 +0,0 @@ -package stest.tron.wallet.other; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class deployMainGateway { - - - private final String testDepositTrx = "324a2052e491e99026442d81df4d2777292840c1b3949e20696c49096c6bacb7"; - private final byte[] testDepositAddress = PublicMethed.getFinalAddress(testDepositTrx); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] depositAddress = ecKey1.getAddress(); - String testKeyFordeposit = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { -// PublicMethed.printAddress(testKeyFordeposit); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "deploy Main Chain Gateway") - public void test1DepositTrc20001() { - - PublicMethed.printAddress(testKeyFordeposit); - - Assert.assertTrue(PublicMethed - .sendcoin(depositAddress, 1000_000_000L, testDepositAddress, testDepositTrx, - blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Account accountOralce = PublicMethed.queryAccount(depositAddress, blockingStubFull); - long OralceBalance = accountOralce.getBalance(); - logger.info("OralceBalance: " + OralceBalance); - - String contractName = "gateWayContract"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_MainGateway"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_MainGateway"); - String parame = "\"" + Base58.encode58Check(testDepositAddress) + "\""; - - String deployTxid = PublicMethed - .deployContractWithConstantParame(contractName, abi, code, "constructor(address)", - parame, "", - maxFeeLimit, - 0L, 100, null, testKeyFordeposit, depositAddress - , blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(deployTxid, blockingStubFull); - byte[] mainChainGateway = infoById.get().getContractAddress().toByteArray(); - String mainChainGatewayAddress = WalletClient.encode58Check(mainChainGateway); - Assert.assertEquals(0, infoById.get().getResultValue()); - Assert.assertNotNull(mainChainGateway); - - SmartContract smartContract = PublicMethed.getContract(mainChainGateway, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - String outputPath = "./src/test/resources/mainChainGatewayAddress" ; - try { - File mainChainFile = new File(outputPath); - Boolean cun = mainChainFile.createNewFile(); - FileWriter writer = new FileWriter(mainChainFile); - BufferedWriter out = new BufferedWriter(writer); - out.write(mainChainGatewayAddress); - - out.close(); - writer.close(); - }catch (Exception e){ - e.printStackTrace(); - } - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/other/deploySideGateway.java b/src/test/java/stest/tron/wallet/other/deploySideGateway.java deleted file mode 100644 index 80a20dec179..00000000000 --- a/src/test/java/stest/tron/wallet/other/deploySideGateway.java +++ /dev/null @@ -1,130 +0,0 @@ -package stest.tron.wallet.other; - -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Protocol.SmartContract; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class deploySideGateway { - - - private final String testDepositTrx = "324a2052e491e99026442d81df4d2777292840c1b3949e20696c49096c6bacb7"; - private final byte[] testDepositAddress = PublicMethed.getFinalAddress(testDepositTrx); - private Long maxFeeLimit = Configuration.getByPath("testng.conf") - .getLong("defaultParameter.maxFeeLimit"); - private String description = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetDescription"); - private String url = Configuration.getByPath("testng.conf") - .getString("defaultParameter.assetUrl"); - private ManagedChannel channelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - - - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - - private String fullnode = "127.0.0.1:50151"; - - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] depositAddress = ecKey1.getAddress(); - String testKeyFordeposit = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass(enabled = true) - public void beforeClass() { -// PublicMethed.printAddress(testKeyFordeposit); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - } - - @Test(enabled = true, description = "deploy Side Chain Gateway") - public void test1DepositTrc20001() { - - PublicMethed.printAddress(testKeyFordeposit); - - String contractName = "gateWaysidechainContract"; - String code = Configuration.getByPath("testng.conf") - .getString("code.code_SideGateway"); - String abi = Configuration.getByPath("testng.conf") - .getString("abi.abi_SideGateway"); - String parame = "\"" + Base58.encode58Check(testDepositAddress) + "\""; - - String deployTxid = PublicMethed - .deployContractWithConstantParame(contractName, abi, code, "constructor(address)", - parame, "", - maxFeeLimit, - 0L, 100, null, testKeyFordeposit, depositAddress - , blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionInfoById(deployTxid, blockingStubFull); - byte[] mainChainGateway = infoById.get().getContractAddress().toByteArray(); - String mainChainGatewayAddress = WalletClient.encode58Check(mainChainGateway); - Assert.assertEquals(0, infoById.get().getResultValue()); - Assert.assertNotNull(mainChainGateway); - - SmartContract smartContract = PublicMethed.getContract(mainChainGateway, - blockingStubFull); - Assert.assertNotNull(smartContract.getAbi()); - - String outputPath = "./src/test/resources/sideChainGatewayAddress" ; - try { - File mainChainFile = new File(outputPath); - Boolean cun = mainChainFile.createNewFile(); - FileWriter writer = new FileWriter(mainChainFile); - BufferedWriter out = new BufferedWriter(writer); - out.write(mainChainGatewayAddress); - - out.close(); - writer.close(); - }catch (Exception e){ - e.printStackTrace(); - } - - } - - /** - * constructor. - */ - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - -} diff --git a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer001.java b/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer001.java deleted file mode 100644 index 53cd1080f1a..00000000000 --- a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer001.java +++ /dev/null @@ -1,333 +0,0 @@ -package stest.tron.wallet.transfer; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestTransfer001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - //send account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - final byte[] sendAccountAddress = ecKey1.getAddress(); - String sendAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - //receipt account - ECKey ecKey2 = new ECKey(Utils.getRandom()); - final byte[] receiptAccountAddress = ecKey2.getAddress(); - String receiptAccountKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - } - - @Test - public void testSendCoin() { - //send account - ecKey1 = new ECKey(Utils.getRandom()); - final byte[] sendAccountAddress = ecKey1.getAddress(); - sendAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - //receipt account - ecKey2 = new ECKey(Utils.getRandom()); - final byte[] receiptAccountAddress = ecKey2.getAddress(); - receiptAccountKey = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(sendAccountAddress, 90000000000L, - fromAddress, testKey002, blockingStubFull)); - - logger.info(receiptAccountKey); - //Test send coin. - Account sendAccount = PublicMethed.queryAccount(sendAccountKey, blockingStubFull); - Long sendAccountBeforeBalance = sendAccount.getBalance(); - Assert.assertTrue(sendAccountBeforeBalance == 90000000000L); - Account receiptAccount = PublicMethed.queryAccount(receiptAccountKey, blockingStubFull); - Long receiptAccountBeforeBalance = receiptAccount.getBalance(); - Assert.assertTrue(receiptAccountBeforeBalance == 0); - - //Test send coin - PublicMethed.waitProduceNextBlock(blockingStubFull); - Assert.assertTrue(PublicMethed.sendcoin(receiptAccountAddress, 49880000000L, - sendAccountAddress, sendAccountKey, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - sendAccount = PublicMethed.queryAccount(sendAccountKey, blockingStubFull); - Long sendAccountAfterBalance = sendAccount.getBalance(); - logger.info(Long.toString(sendAccountAfterBalance)); - Assert.assertTrue(sendAccountAfterBalance == 90000000000L - 49880000000L - 100000L); - - receiptAccount = PublicMethed.queryAccount(receiptAccountKey, blockingStubFull); - Long receiptAccountAfterBalance = receiptAccount.getBalance(); - logger.info(Long.toString(receiptAccountAfterBalance)); - Assert.assertTrue(receiptAccountAfterBalance == 49880000000L); - - //Send coin failed due to no enough balance. - Assert.assertFalse(sendcoin(toAddress, 9199999999999999999L, fromAddress, testKey002)); - //Send coin failed due to the amount is 0. - Assert.assertFalse(sendcoin(toAddress, 0L, fromAddress, testKey002)); - //Send coin failed due to the amount is -1Trx. - Assert.assertFalse(sendcoin(toAddress, -1000000L, fromAddress, testKey002)); - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - final Long beforeBlockNum = currentBlock.getBlockHeader().getRawData().getNumber(); - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction = null"); - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - - Long afterBlockNum = 0L; - Integer wait = 0; - while (afterBlockNum < beforeBlockNum + 1 && wait < 10) { - Block currentBlock1 = searchBlockingStubFull - .getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - afterBlockNum = currentBlock1.getBlockHeader().getRawData().getNumber(); - wait++; - try { - Thread.sleep(2000); - logger.info("wait 2 second"); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "beforefronen" + beforeFrozenBalance.toString() + " afterfronzen" + afterFrozenBalance - .toString()); - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(afterBandwidth - beforeBandwidth == freezeBalance * frozen_duration); - return true; - - - } - - /** - * constructor. - */ - - public Boolean sendcoin(byte[] to, long amount, byte[] owner, String priKey) { - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer003.java b/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer003.java deleted file mode 100644 index a440e05c6b3..00000000000 --- a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer003.java +++ /dev/null @@ -1,403 +0,0 @@ -package stest.tron.wallet.transfer; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; -import org.spongycastle.util.encoders.Hex; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.Sha256Hash; -import stest.tron.wallet.common.client.utils.TransactionUtils; - - -@Slf4j -public class WalletTestTransfer003 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private final Long createUseFee = 100000L; - - private ManagedChannel channelFull = null; - private ManagedChannel channelFull1 = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull1 = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - - private static final long now = System.currentTimeMillis(); - private static final String name = "transaction007_" + Long.toString(now); - private static Protocol.Transaction sendCoinTransaction; - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String fullnode1 = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - //get account - ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] sendCoinAddress = ecKey1.getAddress(); - String testKeyForSendCoin = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ECKey ecKey2 = new ECKey(Utils.getRandom()); - byte[] newAccountAddress = ecKey2.getAddress(); - String testKeyForNewAccount = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - /* @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - }*/ - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - logger.info(testKeyForSendCoin); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelFull1 = ManagedChannelBuilder.forTarget(fullnode1) - .usePlaintext(true) - .build(); - blockingStubFull1 = WalletGrpc.newBlockingStub(channelFull1); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - - } - - - @Test(enabled = true) - public void test1UseFeeOrNet() { - //get account - ecKey1 = new ECKey(Utils.getRandom()); - sendCoinAddress = ecKey1.getAddress(); - testKeyForSendCoin = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - - ecKey2 = new ECKey(Utils.getRandom()); - newAccountAddress = ecKey2.getAddress(); - testKeyForNewAccount = ByteArray.toHexString(ecKey2.getPrivKeyBytes()); - - Assert.assertTrue(PublicMethed.sendcoin(sendCoinAddress, 200000L, - fromAddress, testKey002, blockingStubFull)); - Long feeNum = 0L; - Long netNum = 0L; - Long sendNum = 0L; - Long feeCost = 0L; - Long times = 0L; - Account sendAccountInfo = PublicMethed.queryAccount(testKeyForSendCoin, blockingStubFull); - final Long beforeBalance = sendAccountInfo.getBalance(); - Long netUsed1 = 0L; - Long netUsed2 = 1L; - logger.info("Before test, the account balance is " + Long.toString(beforeBalance)); - - while (!(netUsed1.equals(netUsed2))) { - sendAccountInfo = PublicMethed.queryAccount(testKeyForSendCoin, blockingStubFull); - netUsed1 = sendAccountInfo.getFreeNetUsage(); - sendCoinTransaction = sendcoin(fromAddress, 1L, sendCoinAddress, - testKeyForSendCoin, blockingStubFull); - - sendAccountInfo = PublicMethed.queryAccount(testKeyForSendCoin, blockingStubFull); - netUsed2 = sendAccountInfo.getFreeNetUsage(); - - if (times++ < 1) { - PublicMethed.waitProduceNextBlock(blockingStubFull); - //PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull,blockingStubSolidity); - String txId = ByteArray.toHexString(Sha256Hash.hash(sendCoinTransaction - .getRawData().toByteArray())); - logger.info(txId); - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - TransactionInfo transactionInfo = blockingStubFull.getTransactionInfoById(request); - Optional getTransactionById = Optional.ofNullable(transactionInfo); - logger.info("solidity block num is " + Long.toString(getTransactionById - .get().getBlockNumber())); - Assert.assertTrue(getTransactionById.get().getBlockNumber() > 0); - } - - logger.info(Long.toString(netUsed1)); - logger.info(Long.toString(netUsed2)); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - Assert.assertTrue(netUsed2 > 4500); - //Next time, use fee - sendCoinTransaction = sendcoin(fromAddress, 1L, sendCoinAddress, - testKeyForSendCoin, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull,blockingStubSolidity); - String txId = ByteArray.toHexString(Sha256Hash.hash(sendCoinTransaction - .getRawData().toByteArray())); - logger.info(txId); - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - TransactionInfo transactionInfo = blockingStubFull.getTransactionInfoById(request); - Optional getTransactionById = Optional.ofNullable(transactionInfo); - logger.info(getTransactionById.get().toString()); - logger.info("when use fee, the block num is " + Long.toString(getTransactionById - .get().getBlockNumber())); - Assert.assertTrue(getTransactionById.get().getFee() > 0); - Assert.assertTrue(getTransactionById.get().getBlockNumber() > 0); - } - - @Test(enabled = true) - public void test2CreateAccountUseFee() { - Account sendAccountInfo = PublicMethed.queryAccount(testKeyForSendCoin, blockingStubFull); - final Long beforeBalance = sendAccountInfo.getBalance(); - logger.info("before balance " + Long.toString(beforeBalance)); - Long times = 0L; - sendCoinTransaction = sendcoin(newAccountAddress, 1L, sendCoinAddress, - testKeyForSendCoin, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull,blockingStubSolidity); - String txId = ByteArray.toHexString(Sha256Hash.hash(sendCoinTransaction - .getRawData().toByteArray())); - logger.info(txId); - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - TransactionInfo transactionInfo = blockingStubFull.getTransactionInfoById(request); - Optional getTransactionById = Optional.ofNullable(transactionInfo); - - logger.info("In create account case, the fee is " + getTransactionById.get().getFee()); - Assert.assertTrue(getTransactionById.get().getFee() == createUseFee); - - sendAccountInfo = PublicMethed.queryAccount(testKeyForSendCoin, blockingStubFull); - final Long afterBalance = sendAccountInfo.getBalance(); - logger.info("after balance " + Long.toString(afterBalance)); - Assert.assertTrue(afterBalance + 1L + createUseFee == beforeBalance); - } - - @Test(enabled = true) - public void test3InvalidGetTransactionById() { - String txId = ""; - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - Transaction transaction = blockingStubFull.getTransactionById(request); - Optional getTransactionById = Optional.ofNullable(transaction); - Assert.assertTrue(getTransactionById.get().getRawData().getContractCount() == 0); - - txId = "1"; - bsTxid = ByteString.copyFrom(ByteArray.fromHexString(txId)); - request = BytesMessage.newBuilder().setValue(bsTxid).build(); - transaction = blockingStubFull.getTransactionById(request); - getTransactionById = Optional.ofNullable(transaction); - Assert.assertTrue(getTransactionById.get().getRawData().getContractCount() == 0); - } - - @Test(enabled = true) - public void test4NoBalanceCanSend() { - Long feeNum = 0L; - Account sendAccountInfo = PublicMethed.queryAccount(testKeyForSendCoin, blockingStubFull); - Long beforeBalance = sendAccountInfo.getBalance(); - logger.info("Before test, the account balance is " + Long.toString(beforeBalance)); - while (feeNum < 250) { - sendCoinTransaction = sendcoin(fromAddress, 10L, sendCoinAddress, - testKeyForSendCoin, blockingStubFull); - feeNum++; - } - Assert.assertTrue(PublicMethed.waitProduceNextBlock(blockingStubFull)); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelFull1 != null) { - channelFull1.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private static Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } - - /** - * constructor. - */ - - public static Protocol.Transaction sendcoin(byte[] to, long amount, byte[] owner, String priKey, - WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - //Protocol.Account search = queryAccount(priKey, blockingStubFull); - - Contract.TransferContract.Builder builder = Contract.TransferContract.newBuilder(); - ByteString bsTo = ByteString.copyFrom(to); - ByteString bsOwner = ByteString.copyFrom(owner); - builder.setToAddress(bsTo); - builder.setOwnerAddress(bsOwner); - builder.setAmount(amount); - - Contract.TransferContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.createTransaction(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - } - - return transaction; - } - - /** - * constructor. - */ - - public Protocol.Transaction updateAccount(byte[] addressBytes, byte[] accountNameBytes, - String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - final ECKey ecKey = temKey; - - Contract.AccountUpdateContract.Builder builder = Contract.AccountUpdateContract.newBuilder(); - ByteString basAddreess = ByteString.copyFrom(addressBytes); - ByteString bsAccountName = ByteString.copyFrom(accountNameBytes); - - builder.setAccountName(bsAccountName); - builder.setOwnerAddress(basAddreess); - - Contract.AccountUpdateContract contract = builder.build(); - Protocol.Transaction transaction = blockingStubFull.updateAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction ==null"); - } - transaction = signTransaction(ecKey, transaction); - GrpcAPI.Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - } - - return transaction; - - - } -} - - diff --git a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer004.java b/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer004.java deleted file mode 100644 index fe406dfd4dd..00000000000 --- a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer004.java +++ /dev/null @@ -1,304 +0,0 @@ -package stest.tron.wallet.transfer; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.GrpcAPI.TimePaginatedMessage; -import org.tron.api.GrpcAPI.TransactionList; -import org.tron.api.WalletExtensionGrpc; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - - -@Slf4j -public class WalletTestTransfer004 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletExtensionGrpc.WalletExtensionBlockingStub blockingStubExtension = null; - - private static final long now = System.currentTimeMillis(); - - private String fullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode).usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - blockingStubExtension = WalletExtensionGrpc.newBlockingStub(channelSolidity); - } - - /* @Test(enabled = true) - public void testGetTransactionsByTimestamp() { - long start = now - 16400000; - long end = now; - GrpcAPI.TimeMessage.Builder timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - TimePaginatedMessage.Builder timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(0); - timePageMessage.setLimit(999); - TransactionList transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - Optional gettransactionbytimestamp = Optional - .ofNullable(transactionList); - - if (gettransactionbytimestamp.get().getTransactionCount() == 0) { - logger.info("Last one day there is no transfaction,please test for manual!!!"); - } - - Assert.assertTrue(gettransactionbytimestamp.isPresent()); - logger.info(Integer.toString(gettransactionbytimestamp.get().getTransactionCount())); - for (Integer j = 0; j < gettransactionbytimestamp.get().getTransactionCount(); j++) { - Assert.assertTrue(gettransactionbytimestamp.get().getTransaction(j).hasRawData()); - Assert.assertFalse(gettransactionbytimestamp.get().getTransaction(j) - .getRawData().getContractList().isEmpty()); - } - } - - @Test(enabled = true) - public void testExceptionTimeToGetGetTransactionsByTimestamp() { - //Start time is below zero. - long start = -10000; - long end = -1; - GrpcAPI.TimeMessage.Builder timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - TimePaginatedMessage.Builder timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(0); - timePageMessage.setLimit(999); - TransactionList transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - Optional gettransactionbytimestamp = Optional - .ofNullable(transactionList); - Assert.assertTrue(gettransactionbytimestamp.get().getTransactionCount() == 0); - - //Start time is equal with end time. - long now = System.currentTimeMillis(); - start = now; - end = now; - timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(0); - timePageMessage.setLimit(999); - transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - gettransactionbytimestamp = Optional - .ofNullable(transactionList); - Assert.assertTrue(gettransactionbytimestamp.get().getTransactionCount() == 0); - - //No transeration occured. - now = System.currentTimeMillis(); - start = now; - end = now + 1; - timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(0); - timePageMessage.setLimit(999); - transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - gettransactionbytimestamp = Optional - .ofNullable(transactionList); - Assert.assertTrue(gettransactionbytimestamp.get().getTransactionCount() == 0); - - - //Start time is late than currently time,no exception. - start = now + 1000000; - end = start + 1000000; - timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(0); - timePageMessage.setLimit(999); - transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - gettransactionbytimestamp = Optional - .ofNullable(transactionList); - Assert.assertTrue(gettransactionbytimestamp.get().getTransactionCount() == 0); - - //Start time is late than the end time, no exception. - start = now; - end = now - 10000000; - timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(0); - timePageMessage.setLimit(999); - transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - gettransactionbytimestamp = Optional - .ofNullable(transactionList); - Assert.assertTrue(gettransactionbytimestamp.get().getTransactionCount() == 0); - - //The offset is -1 - start = now - 10000000; - end = now; - timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(-1); - timePageMessage.setLimit(999); - transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - gettransactionbytimestamp = Optional - .ofNullable(transactionList); - Assert.assertTrue(gettransactionbytimestamp.get().getTransactionCount() == 0); - - //The setLimit is -1 - start = now - 10000000; - end = now; - timeMessage = GrpcAPI.TimeMessage.newBuilder(); - timeMessage.setBeginInMilliseconds(start); - timeMessage.setEndInMilliseconds(end); - timePageMessage = TimePaginatedMessage.newBuilder(); - timePageMessage.setTimeMessage(timeMessage); - timePageMessage.setOffset(0); - timePageMessage.setLimit(-1); - transactionList = blockingStubExtension - .getTransactionsByTimestamp(timePageMessage.build()); - gettransactionbytimestamp = Optional - .ofNullable(transactionList); - Assert.assertTrue(gettransactionbytimestamp.get().getTransactionCount() == 0); - - - }*/ - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer007.java b/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer007.java deleted file mode 100644 index 3619db66a17..00000000000 --- a/src/test/java/stest/tron/wallet/transfer/WalletTestTransfer007.java +++ /dev/null @@ -1,149 +0,0 @@ -package stest.tron.wallet.transfer; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI.BytesMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.common.utils.Utils; -import org.tron.protos.Protocol.Transaction; -import org.tron.protos.Protocol.TransactionInfo; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.utils.PublicMethed; - -@Slf4j -public class WalletTestTransfer007 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidityInFullnode = null; - - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - private ECKey ecKey1 = new ECKey(Utils.getRandom()); - byte[] sendAccountAddress = ecKey1.getAddress(); - String sendAccountKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes()); - private ManagedChannel channelSolidity = null; - private ManagedChannel channelSolidityInFullnode = null; - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - /* private String solidityInFullnode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(1);*/ - - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - - /* channelSolidityInFullnode = ManagedChannelBuilder.forTarget(solidityInFullnode) - .usePlaintext(true) - .build(); - blockingStubSolidityInFullnode = WalletSolidityGrpc.newBlockingStub(channelSolidityInFullnode); - */ - } - - - @Test - public void testSendCoin() { - String transactionId = PublicMethed.sendcoinGetTransactionId(sendAccountAddress, 90000000000L, - fromAddress, testKey002, blockingStubFull); - Optional infoById = PublicMethed - .getTransactionById(transactionId, blockingStubFull); - Long timestamptis = PublicMethed.printTransactionRow(infoById.get().getRawData()); - Long timestamptispBlockOne = PublicMethed.getBlock(1, blockingStubFull).getBlockHeader() - .getRawData().getTimestamp(); - Assert.assertTrue(timestamptis >= timestamptispBlockOne); - } - - @Test - public void testSendCoin2() { - String transactionId = PublicMethed.sendcoinGetTransactionId(sendAccountAddress, 90000000000L, - fromAddress, testKey002, blockingStubFull); - PublicMethed.waitProduceNextBlock(blockingStubFull); - - Optional infoById = PublicMethed - .getTransactionById(transactionId, blockingStubFull); - Long timestamptis = PublicMethed.printTransactionRow(infoById.get().getRawData()); - Long timestampBlockOne = PublicMethed.getBlock(1, blockingStubFull).getBlockHeader() - .getRawData().getTimestamp(); - Assert.assertTrue(timestamptis >= timestampBlockOne); - PublicMethed.waitSolidityNodeSynFullNodeData(blockingStubFull, blockingStubSolidity); - - infoById = PublicMethed.getTransactionById(transactionId, blockingStubSolidity); - timestamptis = PublicMethed.printTransactionRow(infoById.get().getRawData()); - timestampBlockOne = PublicMethed.getBlock(1, blockingStubFull).getBlockHeader() - .getRawData().getTimestamp(); - Assert.assertTrue(timestamptis >= timestampBlockOne); - - ByteString bsTxid = ByteString.copyFrom(ByteArray.fromHexString(transactionId)); - BytesMessage request = BytesMessage.newBuilder().setValue(bsTxid).build(); - TransactionInfo transactionInfo; - - transactionInfo = blockingStubSolidity.getTransactionInfoById(request); - Assert.assertTrue(transactionInfo.getBlockTimeStamp() >= timestampBlockOne); - - transactionInfo = blockingStubFull.getTransactionInfoById(request); - Assert.assertTrue(transactionInfo.getBlockTimeStamp() >= timestampBlockOne); - - //transactionInfo = blockingStubSolidityInFullnode.getTransactionInfoById(request); - //Assert.assertTrue(transactionInfo.getBlockTimeStamp() >= timestampBlockOne); - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - -} diff --git a/src/test/java/stest/tron/wallet/witness/WalletTestWitness001.java b/src/test/java/stest/tron/wallet/witness/WalletTestWitness001.java deleted file mode 100644 index 5d5141022c1..00000000000 --- a/src/test/java/stest/tron/wallet/witness/WalletTestWitness001.java +++ /dev/null @@ -1,408 +0,0 @@ -package stest.tron.wallet.witness; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.GrpcAPI.Return; -import org.tron.api.WalletGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.common.utils.ByteArray; -import org.tron.core.Wallet; -import org.tron.protos.Contract; -import org.tron.protos.Contract.FreezeBalanceContract; -import org.tron.protos.Contract.UnfreezeBalanceContract; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.PublicMethed; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -@Slf4j -public class WalletTestWitness001 { - - private final String testKey002 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key1"); - private final byte[] fromAddress = PublicMethed.getFinalAddress(testKey002); - private final String testKey003 = Configuration.getByPath("testng.conf") - .getString("foundationAccount.key2"); - private final byte[] toAddress = PublicMethed.getFinalAddress(testKey003); - private final String witnessKey001 = Configuration.getByPath("testng.conf") - .getString("witness.key1"); - private final byte[] witnessAddress = PublicMethed.getFinalAddress(witnessKey001); - - - private ManagedChannel channelFull = null; - private ManagedChannel searchChannelFull = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletGrpc.WalletBlockingStub searchBlockingStubFull = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String searchFullnode = Configuration.getByPath("testng.conf") - .getStringList("fullnode.ip.list").get(1); - - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - logger.info("Pre fix byte ===== " + WalletClient.getAddressPreFixByte()); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - searchChannelFull = ManagedChannelBuilder.forTarget(searchFullnode) - .usePlaintext(true) - .build(); - searchBlockingStubFull = WalletGrpc.newBlockingStub(searchChannelFull); - } - - @Test(enabled = true) - public void testVoteWitness() { - String voteStr = Base58.encode58Check(witnessAddress); - HashMap smallVoteMap = new HashMap(); - smallVoteMap.put(voteStr, "1"); - HashMap wrongVoteMap = new HashMap(); - wrongVoteMap.put(voteStr, "-1"); - HashMap zeroVoteMap = new HashMap(); - zeroVoteMap.put(voteStr, "0"); - - HashMap veryLargeMap = new HashMap(); - veryLargeMap.put(voteStr, "1000000000"); - HashMap wrongDropMap = new HashMap(); - wrongDropMap.put(voteStr, "10000000000000000"); - - //Vote failed due to no freeze balance. - //Assert.assertFalse(VoteWitness(smallVoteMap, NO_FROZEN_ADDRESS, no_frozen_balance_testKey)); - - //Freeze balance to get vote ability. - Assert.assertTrue(PublicMethed.freezeBalance(fromAddress, 1200000L, 3L, - testKey002, blockingStubFull)); - PublicMethed.waitProduceNextBlock(blockingStubFull); - //Vote failed when the vote is large than the freeze balance. - Assert.assertFalse(voteWitness(veryLargeMap, fromAddress, testKey002)); - //Vote failed due to 0 vote. - Assert.assertFalse(voteWitness(zeroVoteMap, fromAddress, testKey002)); - //Vote failed duo to -1 vote. - Assert.assertFalse(voteWitness(wrongVoteMap, fromAddress, testKey002)); - //Vote is so large, vote failed. - Assert.assertFalse(voteWitness(wrongDropMap, fromAddress, testKey002)); - - //Vote success - Assert.assertTrue(voteWitness(smallVoteMap, fromAddress, testKey002)); - - - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (searchChannelFull != null) { - searchChannelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - /** - * constructor. - */ - - public Boolean voteWitness(HashMap witness, byte[] addRess, String priKey) { - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeVote = queryAccount(ecKey, blockingStubFull); - Long beforeVoteNum = 0L; - if (beforeVote.getVotesCount() != 0) { - beforeVoteNum = beforeVote.getVotes(0).getVoteCount(); - } - - Contract.VoteWitnessContract.Builder builder = Contract.VoteWitnessContract.newBuilder(); - builder.setOwnerAddress(ByteString.copyFrom(addRess)); - for (String addressBase58 : witness.keySet()) { - String value = witness.get(addressBase58); - final long count = Long.parseLong(value); - Contract.VoteWitnessContract.Vote.Builder voteBuilder = Contract.VoteWitnessContract.Vote - .newBuilder(); - byte[] address = WalletClient.decodeFromBase58Check(addressBase58); - logger.info("address ====== " + ByteArray.toHexString(address)); - if (address == null) { - continue; - } - voteBuilder.setVoteAddress(ByteString.copyFrom(address)); - voteBuilder.setVoteCount(count); - builder.addVotes(voteBuilder.build()); - } - - Contract.VoteWitnessContract contract = builder.build(); - - Transaction transaction = blockingStubFull.voteWitnessAccount(contract); - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - logger.info("transaction == null"); - return false; - } - transaction = signTransaction(ecKey, transaction); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - logger.info(ByteArray.toStr(response.getMessage().toByteArray())); - return false; - } - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Account afterVote = queryAccount(ecKey, searchBlockingStubFull); - //Long afterVoteNum = afterVote.getVotes(0).getVoteCount(); - for (String key : witness.keySet()) { - for (int j = 0; j < afterVote.getVotesCount(); j++) { - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - logger.info(key); - if (key.equals("TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes")) { - logger.info("catch it"); - logger.info(Long.toString(afterVote.getVotes(j).getVoteCount())); - logger.info(Long.toString(Long.parseLong(witness.get(key)))); - Assert - .assertTrue(afterVote.getVotes(j).getVoteCount() == Long.parseLong(witness.get(key))); - } - - } - } - return true; - } - - /** - * constructor. - */ - - public Boolean freezeBalance(byte[] addRess, long freezeBalance, long freezeDuration, - String priKey) { - byte[] address = addRess; - long frozenBalance = freezeBalance; - long frozenDuration = freezeDuration; - - //String priKey = testKey002; - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account beforeFronzen = queryAccount(ecKey, blockingStubFull); - - Long beforeFrozenBalance = 0L; - //Long beforeBandwidth = beforeFronzen.getBandwidth(); - if (beforeFronzen.getFrozenCount() != 0) { - beforeFrozenBalance = beforeFronzen.getFrozen(0).getFrozenBalance(); - //beforeBandwidth = beforeFronzen.getBandwidth(); - //logger.info(Long.toString(beforeFronzen.getBandwidth())); - logger.info(Long.toString(beforeFronzen.getFrozen(0).getFrozenBalance())); - } - - FreezeBalanceContract.Builder builder = FreezeBalanceContract.newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess).setFrozenBalance(frozenBalance) - .setFrozenDuration(frozenDuration); - - FreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.freezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - - if (response.getResult() == false) { - return false; - } - - Block currentBlock = blockingStubFull.getNowBlock(GrpcAPI.EmptyMessage.newBuilder().build()); - Block searchCurrentBlock = searchBlockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - Integer wait = 0; - while (searchCurrentBlock.getBlockHeader().getRawData().getNumber() - < currentBlock.getBlockHeader().getRawData().getNumber() + 1 && wait < 30) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("Another fullnode didn't syn the first fullnode data"); - searchCurrentBlock = searchBlockingStubFull.getNowBlock(GrpcAPI - .EmptyMessage.newBuilder().build()); - wait++; - if (wait == 9) { - logger.info("Didn't syn,skip to next case."); - } - } - - Account afterFronzen = queryAccount(ecKey, searchBlockingStubFull); - Long afterFrozenBalance = afterFronzen.getFrozen(0).getFrozenBalance(); - //Long afterBandwidth = afterFronzen.getBandwidth(); - //logger.info(Long.toString(afterFronzen.getBandwidth())); - //logger.info(Long.toString(afterFronzen.getFrozen(0).getFrozenBalance())); - //logger.info(Integer.toString(search.getFrozenCount())); - logger.info( - "afterfrozenbalance =" + Long.toString(afterFrozenBalance) + "beforefrozenbalance = " - + beforeFrozenBalance + "freezebalance = " + Long.toString(freezeBalance)); - //logger.info("afterbandwidth = " + Long.toString(afterBandwidth) + " beforebandwidth = - // " + Long.toString(beforeBandwidth)); - //if ((afterFrozenBalance - beforeFrozenBalance != freezeBalance) || - // (freezeBalance * frozen_duration -(afterBandwidth - beforeBandwidth) !=0)){ - // logger.info("After 20 second, two node still not synchronous"); - // } - Assert.assertTrue(afterFrozenBalance - beforeFrozenBalance == freezeBalance); - //Assert.assertTrue(freezeBalance * frozen_duration - (afterBandwidth - - // beforeBandwidth) <= 1000000); - return true; - - - } - - /** - * constructor. - */ - - public boolean unFreezeBalance(byte[] addRess, String priKey) { - byte[] address = addRess; - - ECKey temKey = null; - try { - BigInteger priK = new BigInteger(priKey, 16); - temKey = ECKey.fromPrivate(priK); - } catch (Exception ex) { - ex.printStackTrace(); - } - ECKey ecKey = temKey; - Account search = queryAccount(ecKey, blockingStubFull); - - UnfreezeBalanceContract.Builder builder = UnfreezeBalanceContract - .newBuilder(); - ByteString byteAddreess = ByteString.copyFrom(address); - - builder.setOwnerAddress(byteAddreess); - - UnfreezeBalanceContract contract = builder.build(); - - Transaction transaction = blockingStubFull.unfreezeBalance(contract); - - if (transaction == null || transaction.getRawData().getContractCount() == 0) { - return false; - } - - transaction = TransactionUtils.setTimestamp(transaction); - transaction = TransactionUtils.sign(transaction, ecKey); - Return response = blockingStubFull.broadcastTransaction(transaction); - if (response.getResult() == false) { - return false; - } else { - return true; - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - - diff --git a/src/test/java/stest/tron/wallet/witness/WalletTestWitness002.java b/src/test/java/stest/tron/wallet/witness/WalletTestWitness002.java deleted file mode 100644 index 28d5cd313ae..00000000000 --- a/src/test/java/stest/tron/wallet/witness/WalletTestWitness002.java +++ /dev/null @@ -1,215 +0,0 @@ -package stest.tron.wallet.witness; - -import com.google.protobuf.ByteString; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.spongycastle.util.encoders.Hex; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.tron.api.GrpcAPI; -import org.tron.api.GrpcAPI.NumberMessage; -import org.tron.api.WalletGrpc; -import org.tron.api.WalletSolidityGrpc; -import org.tron.common.crypto.ECKey; -import org.tron.core.Wallet; -import org.tron.protos.Protocol; -import org.tron.protos.Protocol.Account; -import org.tron.protos.Protocol.Block; -import org.tron.protos.Protocol.Transaction; -import stest.tron.wallet.common.client.Configuration; -import stest.tron.wallet.common.client.Parameter.CommonConstant; -import stest.tron.wallet.common.client.WalletClient; -import stest.tron.wallet.common.client.utils.Base58; -import stest.tron.wallet.common.client.utils.TransactionUtils; - -//import stest.tron.wallet.common.client.WitnessComparator; - -//import stest.tron.wallet.common.client.WitnessComparator; - -@Slf4j -public class WalletTestWitness002 { - - - private ManagedChannel channelFull = null; - private ManagedChannel channelSolidity = null; - private WalletGrpc.WalletBlockingStub blockingStubFull = null; - private WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity = null; - private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list") - .get(0); - private String soliditynode = Configuration.getByPath("testng.conf") - .getStringList("solidityNode.ip.list").get(0); - - @BeforeSuite - public void beforeSuite() { - Wallet wallet = new Wallet(); - Wallet.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - } - - /** - * constructor. - */ - - @BeforeClass - public void beforeClass() { - WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET); - channelFull = ManagedChannelBuilder.forTarget(fullnode) - .usePlaintext(true) - .build(); - blockingStubFull = WalletGrpc.newBlockingStub(channelFull); - - channelSolidity = ManagedChannelBuilder.forTarget(soliditynode) - .usePlaintext(true) - .build(); - blockingStubSolidity = WalletSolidityGrpc.newBlockingStub(channelSolidity); - } - - @Test(enabled = true) - public void testQueryAllWitness() { - GrpcAPI.WitnessList witnesslist = blockingStubFull - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(witnesslist); - if (result.isPresent()) { - GrpcAPI.WitnessList witnessList = result.get(); - List list = witnessList.getWitnessesList(); - List newList = new ArrayList(); - newList.addAll(list); - newList.sort(new WitnessComparator()); - GrpcAPI.WitnessList.Builder builder = GrpcAPI.WitnessList.newBuilder(); - newList.forEach(witness -> builder.addWitnesses(witness)); - result = Optional.of(builder.build()); - } - logger.info(Integer.toString(result.get().getWitnessesCount())); - Assert.assertTrue(result.get().getWitnessesCount() > 0); - for (int j = 0; j < result.get().getWitnessesCount(); j++) { - Assert.assertFalse(result.get().getWitnesses(j).getAddress().isEmpty()); - Assert.assertFalse(result.get().getWitnesses(j).getUrl().isEmpty()); - //Assert.assertTrue(result.get().getWitnesses(j).getLatestSlotNum() > 0); - result.get().getWitnesses(j).getUrlBytes(); - result.get().getWitnesses(j).getLatestBlockNum(); - result.get().getWitnesses(j).getLatestSlotNum(); - result.get().getWitnesses(j).getTotalMissed(); - result.get().getWitnesses(j).getTotalProduced(); - } - - //Improve coverage. - witnesslist.equals(result.get()); - witnesslist.hashCode(); - witnesslist.getSerializedSize(); - witnesslist.equals(null); - } - - @Test(enabled = true) - public void testSolidityQueryAllWitness() { - GrpcAPI.WitnessList solidityWitnessList = blockingStubSolidity - .listWitnesses(GrpcAPI.EmptyMessage.newBuilder().build()); - Optional result = Optional.ofNullable(solidityWitnessList); - if (result.isPresent()) { - GrpcAPI.WitnessList witnessList = result.get(); - List list = witnessList.getWitnessesList(); - List newList = new ArrayList(); - newList.addAll(list); - newList.sort(new WitnessComparator()); - GrpcAPI.WitnessList.Builder builder = GrpcAPI.WitnessList.newBuilder(); - newList.forEach(witness -> builder.addWitnesses(witness)); - result = Optional.of(builder.build()); - } - logger.info(Integer.toString(result.get().getWitnessesCount())); - Assert.assertTrue(result.get().getWitnessesCount() > 0); - for (int j = 0; j < result.get().getWitnessesCount(); j++) { - Assert.assertFalse(result.get().getWitnesses(j).getAddress().isEmpty()); - Assert.assertFalse(result.get().getWitnesses(j).getUrl().isEmpty()); - } - } - - /** - * constructor. - */ - - @AfterClass - public void shutdown() throws InterruptedException { - if (channelFull != null) { - channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - if (channelSolidity != null) { - channelSolidity.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - } - - class WitnessComparator implements Comparator { - - public int compare(Object o1, Object o2) { - return Long - .compare(((Protocol.Witness) o2).getVoteCount(), ((Protocol.Witness) o1).getVoteCount()); - } - } - - /** - * constructor. - */ - - public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) { - byte[] address; - if (ecKey == null) { - String pubKey = loadPubKey(); //04 PubKey[128] - if (StringUtils.isEmpty(pubKey)) { - logger.warn("Warning: QueryAccount failed, no wallet address !!"); - return null; - } - byte[] pubKeyAsc = pubKey.getBytes(); - byte[] pubKeyHex = Hex.decode(pubKeyAsc); - ecKey = ECKey.fromPublicOnly(pubKeyHex); - } - return grpcQueryAccount(ecKey.getAddress(), blockingStubFull); - } - - public static String loadPubKey() { - char[] buf = new char[0x100]; - return String.valueOf(buf, 32, 130); - } - - public byte[] getAddress(ECKey ecKey) { - return ecKey.getAddress(); - } - - /** - * constructor. - */ - - public Account grpcQueryAccount(byte[] address, WalletGrpc.WalletBlockingStub blockingStubFull) { - ByteString addressBs = ByteString.copyFrom(address); - Account request = Account.newBuilder().setAddress(addressBs).build(); - return blockingStubFull.getAccount(request); - } - - /** - * constructor. - */ - - public Block getBlock(long blockNum, WalletGrpc.WalletBlockingStub blockingStubFull) { - NumberMessage.Builder builder = NumberMessage.newBuilder(); - builder.setNum(blockNum); - return blockingStubFull.getBlockByNum(builder.build()); - - } - - private Transaction signTransaction(ECKey ecKey, Transaction transaction) { - if (ecKey == null || ecKey.getPrivKey() == null) { - logger.warn("Warning: Can't sign,there is no private key !!"); - return null; - } - transaction = TransactionUtils.setTimestamp(transaction); - return TransactionUtils.sign(transaction, ecKey); - } -} - -